Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
9e7da87
Initial PAGBuilder
fabianbs96 Dec 27, 2025
d94d8c0
Add UnionFind + minor
fabianbs96 Dec 29, 2025
2cb583d
Optional type-erasure for PBStrategy + add PBStrategyCombinator
fabianbs96 Dec 30, 2025
ebe4ffa
Add basic union-find based Steensgaard-style alias analysis (WIP)
fabianbs96 Jan 2, 2026
1aa428e
Add utility for UnionFindAAResults intersection and caching + make LL…
fabianbs96 Jan 3, 2026
821b92c
Add alias-iterator for union-find alias-results
fabianbs96 Jan 4, 2026
d918c2d
Add LLVMUnionFindAliasIterator + NonNullPtr
fabianbs96 Jan 4, 2026
2e19484
Start adding unit-tests for union-find-AA
fabianbs96 Jan 5, 2026
70ab854
Fix PBMixin + add some comments
fabianbs96 Jan 6, 2026
101b03b
Added more basic and context tests for pointers
mxHuber Jan 7, 2026
c92d364
Small fix in IndirectionSensUnionFindAA::onAddValue
fabianbs96 Jan 10, 2026
bed07ff
Add summary-based union-find alias-analysis
fabianbs96 Jan 11, 2026
e75f438
context tests with different depth
mxHuber Jan 13, 2026
762619c
Merge remote-tracking branch 'refs/remotes/origin/f-PAG' into f-PAG
mxHuber Jan 13, 2026
294f730
renamed tests
mxHuber Jan 13, 2026
6e49be8
More context tests
mxHuber Jan 13, 2026
eb695c8
fixed error
mxHuber Jan 13, 2026
fa7038c
removed bad basic tests + expanded unittest
mxHuber Jan 15, 2026
2e408d0
added context_08 to unittest, fails
mxHuber Jan 15, 2026
ef4f5a1
added more context tests to unittest
mxHuber Jan 19, 2026
b77cc39
Add soundness to BottomupUnionFindAA
fabianbs96 Jan 19, 2026
494409b
Add convenience-functions to compute union-find alias info for LLVM
fabianbs96 Jan 19, 2026
c803b8d
minor
fabianbs96 Jan 19, 2026
8288b77
added more tests + fixed some old ones
mxHuber Jan 20, 2026
c99e512
Fixed context unit tests
mxHuber Jan 21, 2026
83cd49c
added CtxSens and IndirSens unittests
mxHuber Jan 23, 2026
e865e5f
Some fix in BottomupUnionFindAA
fabianbs96 Jan 23, 2026
912d7fb
Merge branch 'development' into f-PAG
fabianbs96 Jan 26, 2026
dc8fcaf
Fix error due to merge
fabianbs96 Jan 26, 2026
b64fc3b
Start adding LLVMUnionFindAliasSet (WIP)
fabianbs96 Jan 26, 2026
095e157
Continue with LLVMUnionFindAliasSet
fabianbs96 Jan 27, 2026
6219e66
Integrate Union-Find-AA into phasar-cli
fabianbs96 Feb 2, 2026
511201c
debug information
mxHuber Feb 2, 2026
efa5851
Merge remote-tracking branch 'refs/remotes/origin/f-PAG' into f-PAG
mxHuber Feb 2, 2026
70deb00
disabled context_01 indir test due to a crash
mxHuber Feb 2, 2026
44ba407
Add library summar to PAG
fabianbs96 Feb 2, 2026
cd14392
fixed Indir Context01
mxHuber Feb 3, 2026
1563885
Merge remote-tracking branch 'refs/remotes/origin/f-PAG' into f-PAG
mxHuber Feb 3, 2026
cdfd410
fixed LLVMAliasSet tests
mxHuber Feb 3, 2026
c4e15e8
Fixed Indir Context02, 03 and 04_0
mxHuber Feb 3, 2026
7c6d3da
Enable passing LLVMFunctionDataFlowFacts into LLVMPAGBuilder
fabianbs96 Feb 3, 2026
df65742
added missing allocas to ground truths 01 - 04_0
mxHuber Feb 3, 2026
3e43ed5
Merge remote-tracking branch 'refs/remotes/origin/f-PAG' into f-PAG
mxHuber Feb 3, 2026
a6f8ede
Fixed ground truth of Indir Context Tests til 08
mxHuber Feb 3, 2026
98964c4
new basic03, added basic04, gt fixes til 10_1
mxHuber Feb 4, 2026
5d0e90a
Last of Indir Context tests fixed
mxHuber Feb 6, 2026
2fdec14
New tests
mxHuber Feb 10, 2026
7f1d7f9
fixed cmakelists for cpp tests
mxHuber Feb 10, 2026
2c8d8aa
Indir Unittests output comments + 01, 02 half done
mxHuber Feb 10, 2026
ba9f360
indir unittests
mxHuber Feb 11, 2026
674f51d
Add TracingPBStrategy to dump the PAG
fabianbs96 Feb 16, 2026
d33f08a
new indir tests + fixed crashes
mxHuber Feb 17, 2026
6be32a8
Merge remote-tracking branch 'refs/remotes/origin/f-PAG' into f-PAG
mxHuber Feb 17, 2026
25c0bed
fixed some unittests
mxHuber Feb 18, 2026
3d8ccfc
fixed half of ctx-sens Context tests
mxHuber Feb 20, 2026
dda83b7
Nearly all ctx-sens context tests done
mxHuber Feb 20, 2026
dcaf7b9
FuncByName TestingSrcLocation
mxHuber Feb 23, 2026
b6b63d3
Update breaking changes
fabianbs96 Feb 24, 2026
8d041ea
Fix CtxSensUnionFindAATest.Indirection01
fabianbs96 Feb 24, 2026
86860e3
commit for merge
mxHuber Feb 24, 2026
8c6dd81
Merge remote-tracking branch 'refs/remotes/origin/f-PAG' into f-PAG
mxHuber Feb 24, 2026
3be3c1e
Half of Indir Tests fixed
mxHuber Feb 24, 2026
1baa7d1
all unittests working now
mxHuber Feb 24, 2026
921ce1d
test tool
mxHuber Mar 17, 2026
f9b39ce
Fix LLVMUnionFindAliasSet dependency to phasar_llvm_controlflow
fabianbs96 Mar 17, 2026
f088458
Add README
fabianbs96 Mar 17, 2026
9278294
minor
fabianbs96 Mar 17, 2026
aef62f0
added other two analyses + results table
mxHuber Mar 24, 2026
c047f3e
fixed table formatting
mxHuber Mar 25, 2026
bf0449c
Some cleanup
fabianbs96 Mar 26, 2026
56a02e0
Add ValueIdMap to use as cache for alias-sets
fabianbs96 Mar 26, 2026
b8b2afc
minor
fabianbs96 Mar 26, 2026
0db8f4a
pre-commit
fabianbs96 Mar 26, 2026
0906dbf
Cleanup + bug fixing
fabianbs96 Mar 27, 2026
cd3ccb9
Add Doxygen comments to new alias-analysis headers
fabianbs96 Mar 27, 2026
7975144
Merge branch 'development' into f-AnalysesTesting
fabianbs96 Mar 27, 2026
fea1d90
minor
fabianbs96 Mar 27, 2026
0ef96dd
Make ValueIdMap allocator-aware
fabianbs96 Mar 29, 2026
d0173b9
Extend ValueIdMap STL API: range ctor, ilist ctor/assign, erase(const…
fabianbs96 Mar 29, 2026
7ca1838
Merge branch 'development' into f-AnalysesTesting
fabianbs96 Mar 29, 2026
1f6735b
LLVM 17 compatibility
fabianbs96 Mar 29, 2026
feafdff
Fix library-summary relocation with C++20 modules
fabianbs96 Mar 29, 2026
a5725ed
Fix new dependency of phasar_llvm_pointer to phasar_controlflow
fabianbs96 Mar 29, 2026
510eb6b
ci: ccache dedup per llvm version
fabianbs96 Mar 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: ccache # This should always come after the actions/checkout step.
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ${{ github.job }}-${{ matrix.os }}-${{ matrix.build }}
key: ${{ github.job }}-${{ matrix.os }}-llvm${{ matrix.llvm-version }}-${{ matrix.build }}

- name: Install Phasar Dependencies
shell: bash
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ permissions:
contents: write
jobs:
build-and-deploy:
if: github.repository == 'secure-software-engineering/phasar'
runs-on: ubuntu-24.04
strategy:
fail-fast: true
Expand Down
2 changes: 2 additions & 0 deletions BreakingChanges.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## development HEAD

- The function `HelperAnalyses::getAliasInfo()` no longer returns a `LLVMAliasSet &`, but a `LLVMAliasInfoRef`.
- The location of the library summary `FunctionDataFlowFacts` and `LLVMFunctionDataFlowFacts` has moved to `phasar/Utils/` and `phasar/PhasarLLVM/Utils`, respectively.
- `IDESolver::initialize()` does no longer return a `bool`. Now, you are always allowed to call `next()` at least once.
- `IntraMonoProblem` and `InterMonoProblem`, and all reference-implementations of these problems do not receive a TypeHierarchy-pointer anymore in the ctor.
- Requiring C++20 instead of C++17
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ if (PHASAR_ENABLE_WARNINGS)
if (MSVC)
string(APPEND CMAKE_CXX_FLAGS " /W4")
else()
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wno-unused-parameter")
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wno-unused-parameter -Werror=return-type")
endif()
endif (PHASAR_ENABLE_WARNINGS)

Expand Down
92 changes: 92 additions & 0 deletions include/phasar/ControlFlow/CallGraphBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@

#include "phasar/Utils/ByRef.h"
#include "phasar/Utils/CRTPUtils.h"
#include "phasar/Utils/Compressor.h"
#include "phasar/Utils/GraphTraits.h"
#include "phasar/Utils/IotaIterator.h"
#include "phasar/Utils/NonNullPtr.h"
#include "phasar/Utils/TypeTraits.h"

#include "llvm/ADT/STLExtras.h"

#include <concepts>
#include <type_traits>

Expand Down Expand Up @@ -127,6 +133,92 @@ template <typename Derived> class CallGraphBase : public CRTPBase<Derived> {

[[nodiscard]] constexpr bool empty() const noexcept { return size() == 0; }
};

/// A view over a call-graph that implements psr::GraphTraits on the
/// getCallersOf() relation.
/// Useful to compute CG-SCCs.
template <typename CallGraphTy, typename DB> class ReverseCGGraph {
static constexpr bool NeedsMapping = !IdType<typename CallGraphTy::f_t>;

enum class FunctionIdImpl : uint32_t {};

public:
using FunctionId = std::conditional_t<NeedsMapping, FunctionIdImpl,
typename CallGraphTy::f_t>;

constexpr ReverseCGGraph(
NonNullPtr<const CallGraphTy> CGView, NonNullPtr<const DB> IRDB,
Compressor<typename CallGraphTy::f_t, FunctionId> FC) noexcept
requires(NeedsMapping)
: CGView(CGView), IRDB(IRDB), FC(std::move(FC)) {}

constexpr ReverseCGGraph(NonNullPtr<const CallGraphTy> CGView,
NonNullPtr<const DB> IRDB) noexcept
: CGView(CGView), IRDB(IRDB) {
FC.reserve(CGView->getNumVertexFunctions());
for (const auto &Fun : CGView->getAllVertexFunctions()) {
FC.insert(Fun);
}
}

NonNullPtr<const CallGraphTy> CGView;
NonNullPtr<const DB> IRDB;
[[no_unique_address]] std::conditional_t<
NeedsMapping, Compressor<typename CallGraphTy::f_t, FunctionId>,
NoneCompressor> FC{};
};

template <typename CallGraphTy, typename DB>
ReverseCGGraph(NonNullPtr<const CallGraphTy>, NonNullPtr<const DB>)
-> ReverseCGGraph<CallGraphTy, DB>;
template <typename CallGraphTy, typename DB>
ReverseCGGraph(const CallGraphTy *, const DB *)
-> ReverseCGGraph<CallGraphTy, DB>;

template <typename CallGraphTy, typename DB>
struct GraphTraits<ReverseCGGraph<CallGraphTy, DB>> {
using graph_type = ReverseCGGraph<CallGraphTy, DB>;
using value_type = typename CallGraphTy::f_t;
using vertex_t = typename graph_type::FunctionId;
using edge_t = vertex_t;

static constexpr vertex_t Invalid = vertex_t(UINT32_MAX);

static constexpr auto mapToFunction(const graph_type &G) {
return [&G](ByConstRef<typename CallGraphTy::n_t> Inst) {
const auto &Fun = G.IRDB->getFunctionOf(Inst);
return G.FC.getOrNull(Fun).value();
};
}

static constexpr auto outEdges(const graph_type &G, vertex_t Vtx) {
return llvm::map_range(G.CGView->getCallersOf(G.FC[Vtx]), mapToFunction(G));
}

static constexpr decltype(auto) nodes(const graph_type &G) {
return G.CGView->getAllVertexFunctions();
}

// TODO: Roots

static constexpr auto vertices(const graph_type &G) {
return iota<vertex_t>(G.CGView->getNumVertexFunctions());
}

static constexpr decltype(auto) node(const graph_type &G, vertex_t Vtx) {
return G.FC[Vtx];
}

static constexpr size_t size(const graph_type &G) {
return G.CGView->getNumVertexFunctions();
}

static constexpr vertex_t target(edge_t Edge) { return Edge; }
static constexpr vertex_t withEdgeTarget(edge_t /*Edge*/, vertex_t Vtx) {
return Vtx;
}
};

} // namespace psr

#endif // PHASAR_CONTROLFLOW_CALLGRAPHBASE_H
8 changes: 8 additions & 0 deletions include/phasar/DB/ProjectIRDBBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#ifndef PHASAR_DB_PROJECTIRDBBASE_H
#define PHASAR_DB_PROJECTIRDBBASE_H

#include "phasar/Utils/ByRef.h"
#include "phasar/Utils/Nullable.h"
#include "phasar/Utils/TypeTraits.h"

Expand Down Expand Up @@ -84,6 +85,13 @@ class LLVM_DEPRECATED(
return self().hasFunctionImpl(FunctionName);
}

/// Returns the function that contains the given instruction Inst.
/// Each instruction must be part of a function.
[[nodiscard]] f_t getFunctionOf(ByConstRef<n_t> Inst) const {
assert(isValid());
return self().getFunctionOfImpl(Inst);
}

/// Returns the global variable if available, nullptr/nullopt
/// otherwise.
[[nodiscard]] Nullable<g_t>
Expand Down
21 changes: 0 additions & 21 deletions include/phasar/DataFlow/IfdsIde/Solver/Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,6 @@

namespace psr {

struct NoneCompressor final {
constexpr NoneCompressor() noexcept = default;

template <typename T>
requires(!std::is_same_v<NoneCompressor, T>)
constexpr NoneCompressor(const T & /*unused*/) noexcept {}

template <typename T>
[[nodiscard]] decltype(auto) getOrInsert(T &&Val) const noexcept {
return std::forward<T>(Val);
}
template <typename T>
[[nodiscard]] decltype(auto) operator[](T &&Val) const noexcept {
return std::forward<T>(Val);
}
void reserve(size_t /*unused*/) const noexcept {}

[[nodiscard]] size_t size() const noexcept { return 0; }
[[nodiscard]] size_t capacity() const noexcept { return 0; }
};

class LLVMProjectIRDB;

/// Once we have fast instruction IDs (as we already have in IntelliSecPhasar),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define PHASAR_PHASARLLVM_CONTROLFLOW_TYPEPROPAGATOR_H

#include "phasar/PhasarLLVM/ControlFlow/VTA/TypeAssignmentGraph.h"
#include "phasar/Utils/SCCId.h"
#include "phasar/Utils/TypedVector.h"

#include "llvm/ADT/DenseSet.h"
Expand All @@ -22,7 +23,6 @@ class Value;
} // namespace llvm

namespace psr {
template <typename GraphNodeId> struct SCCId;
template <typename GraphNodeId> struct SCCHolder;
template <typename GraphNodeId> struct SCCDependencyGraph;
template <typename GraphNodeId> struct SCCOrder;
Expand Down
5 changes: 5 additions & 0 deletions include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ class LLVMProjectIRDB : public ProjectIRDBBase<LLVMProjectIRDB> {
hasFunctionImpl(llvm::StringRef FunctionName) const noexcept {
return Mod->getFunction(FunctionName) != nullptr;
}
[[nodiscard]] f_t getFunctionOfImpl(n_t Inst) const {
assert(Inst != nullptr);
return Inst->getFunction();
}

[[nodiscard]] g_t
getGlobalVariableImpl(llvm::StringRef GlobalVariableName) const;
[[nodiscard]] g_t
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
#include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h"
#include "phasar/PhasarLLVM/ControlFlow/LLVMBasedICFG.h"
#include "phasar/PhasarLLVM/DB/LLVMProjectIRDB.h"
#include "phasar/PhasarLLVM/DataFlow/IfdsIde/LLVMFunctionDataFlowFacts.h"
#include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h"
#include "phasar/PhasarLLVM/Utils/LLVMFunctionDataFlowFacts.h"

#include <map>
#include <set>
Expand Down
7 changes: 5 additions & 2 deletions include/phasar/PhasarLLVM/HelperAnalyses.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#include "phasar/ControlFlow/CallGraphAnalysisType.h"
#include "phasar/ControlFlow/CallGraphData.h"
#include "phasar/PhasarLLVM/HelperAnalysisConfig.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasSetData.h"
#include "phasar/Pointer/UnionFindAliasAnalysisType.h"

#include "llvm/ADT/Twine.h"

Expand Down Expand Up @@ -60,14 +62,14 @@ class HelperAnalyses { // NOLINT(cppcoreguidelines-special-member-functions)
~HelperAnalyses() noexcept;

[[nodiscard]] LLVMProjectIRDB &getProjectIRDB();
[[nodiscard]] LLVMAliasSet &getAliasInfo();
[[nodiscard]] LLVMAliasInfoRef getAliasInfo();
[[nodiscard]] DIBasedTypeHierarchy &getTypeHierarchy();
[[nodiscard]] LLVMBasedICFG &getICFG();
[[nodiscard]] LLVMBasedCFG &getCFG();

private:
std::unique_ptr<LLVMProjectIRDB> IRDB;
std::unique_ptr<LLVMAliasSet> PT;
LLVMAliasInfo PT{};
std::unique_ptr<DIBasedTypeHierarchy> TH;
std::unique_ptr<LLVMBasedICFG> ICF;
std::unique_ptr<LLVMBasedCFG> CFG;
Expand All @@ -78,6 +80,7 @@ class HelperAnalyses { // NOLINT(cppcoreguidelines-special-member-functions)
// PTS
std::optional<LLVMAliasSetData> PrecomputedPTS;
AliasAnalysisType PTATy{};
UnionFindAliasAnalysisType UFAATy{};
bool AllowLazyPTS{};

// ICF
Expand Down
2 changes: 2 additions & 0 deletions include/phasar/PhasarLLVM/HelperAnalysisConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "phasar/ControlFlow/CallGraphData.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasSetData.h"
#include "phasar/Pointer/AliasAnalysisType.h"
#include "phasar/Pointer/UnionFindAliasAnalysisType.h"
#include "phasar/Utils/Soundness.h"

#include <optional>
Expand All @@ -23,6 +24,7 @@ struct HelperAnalysisConfig {
std::optional<LLVMAliasSetData> PrecomputedPTS = std::nullopt;
std::optional<CallGraphData> PrecomputedCG = std::nullopt;
AliasAnalysisType PTATy = AliasAnalysisType::CFLAnders;
UnionFindAliasAnalysisType UFAATy = UnionFindAliasAnalysisType::CtxIndSens;
CallGraphAnalysisType CGTy = CallGraphAnalysisType::OTF;
Soundness SoundnessLevel = Soundness::Soundy;
bool AutoGlobalSupport = true;
Expand Down
5 changes: 5 additions & 0 deletions include/phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ namespace psr {
using LLVMAliasIteratorRef =
AliasIteratorRef<const llvm::Value *, const llvm::Instruction *>;

template <typename T>
concept IsLLVMAliasIterator =
detail::IsAliasIteratorFor<T, const llvm::Value *,
const llvm::Instruction *>;

using LLVMAliasInfoRef =
AliasInfoRef<const llvm::Value *, const llvm::Instruction *>;

Expand Down
Loading
Loading