Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
81c9d1d
IDETabulationProblem child classes
mxHuber Nov 13, 2024
566d355
get call, ret, calltoret flowfunc impls
mxHuber Nov 17, 2024
69208e5
default flow functions
mxHuber Nov 28, 2024
db3a205
call, ret, calltoret with AliasInfo
mxHuber Dec 3, 2024
2195910
Lambda funcs for retflow
mxHuber Dec 6, 2024
41e9851
PureFlow tests
mxHuber Jan 15, 2025
f9eade1
backup before merge
mxHuber Jan 29, 2025
9348300
More Test Files
mxHuber Feb 5, 2025
4bc6d79
normal and call flow tests
mxHuber Feb 7, 2025
5a6ad46
LLVMAliasSet fix NoAliasImpl
mxHuber Feb 24, 2025
e6d3480
fix + commented out bad code
mxHuber Feb 24, 2025
a168c64
fixed some NoAliasInfoTabProb code
mxHuber Feb 25, 2025
199d85b
temp removed broken tests
mxHuber Feb 25, 2025
64a2b9a
specific value sets fix
mxHuber Feb 26, 2025
ec05759
first retflow test
mxHuber Mar 3, 2025
2e71a46
cleanup
mxHuber Mar 4, 2025
0226f04
fixed NormalFlow01 + ground truth
mxHuber Mar 8, 2025
bf1dc8c
last tests, seqfaults
mxHuber Mar 11, 2025
9b25dea
good progress, few tests fail
mxHuber Mar 24, 2025
5f12d30
Fix compilation issue after merge
fabianbs96 Mar 25, 2025
874e942
Remove unused-variable warning in release mode for CallGraph.h
fabianbs96 Feb 4, 2025
e501c08
tests pass, rebased failed
mxHuber Apr 1, 2025
7d23548
mionr after rebase
fabianbs96 Apr 2, 2025
f40a3be
fixed all tests after rebase
mxHuber Apr 2, 2025
0ddd748
Merge branch 'development' into f-DefaultFlowFunctions
fabianbs96 Apr 2, 2025
f6e4bf3
Some cleanup
fabianbs96 Apr 3, 2025
d025119
Rename the default problems + add IFDS versions
fabianbs96 Apr 3, 2025
276d9b0
minor
fabianbs96 Apr 3, 2025
411adc1
Some cleanup in ll file generation
fabianbs96 Apr 3, 2025
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
3 changes: 1 addition & 2 deletions include/phasar/ControlFlow/CallGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ template <typename N, typename F> class CallGraphBuilder {
[[nodiscard]] FunctionVertexTy *addFunctionVertex(f_t Fun) {
auto [It, Inserted] = CG.CallersOf.try_emplace(std::move(Fun), nullptr);
if (Inserted) {
auto Cap = CG.FunVertexOwner.capacity();
assert(CG.FunVertexOwner.size() < Cap &&
assert(CG.FunVertexOwner.size() < CG.FunVertexOwner.capacity() &&
"Trying to add more than MaxNumFunctions Function Vertices");
It->second = &CG.FunVertexOwner.emplace_back();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDEALIASINFOTABULATIONPROBLEM_H
#define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDEALIASINFOTABULATIONPROBLEM_H

#include "phasar/PhasarLLVM/DataFlow/IfdsIde/DefaultNoAliasIDEProblem.h"
#include "phasar/PhasarLLVM/Pointer/LLVMAliasInfo.h"

#include <cassert>

// Forward declaration of types for which we only use its pointer or ref type
namespace llvm {
class Instruction;
class Function;
class Value;
} // namespace llvm

namespace psr {

namespace detail {
class IDEAliasAwareDefaultFlowFunctionsImpl
: private IDENoAliasDefaultFlowFunctionsImpl {
public:
using typename IDENoAliasDefaultFlowFunctionsImpl::d_t;
using typename IDENoAliasDefaultFlowFunctionsImpl::f_t;
using typename IDENoAliasDefaultFlowFunctionsImpl::FlowFunctionPtrType;
using typename IDENoAliasDefaultFlowFunctionsImpl::FlowFunctionType;
using typename IDENoAliasDefaultFlowFunctionsImpl::n_t;

using IDENoAliasDefaultFlowFunctionsImpl::isFunctionModeled;

[[nodiscard]] constexpr LLVMAliasInfoRef getAliasInfo() const noexcept {
return AS;
}

constexpr IDEAliasAwareDefaultFlowFunctionsImpl(LLVMAliasInfoRef AS) noexcept
: AS(AS) {
assert(AS && "You must provide an alias information handle!");
}

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunctionImpl(n_t Curr,
n_t /*Succ*/);
[[nodiscard]] FlowFunctionPtrType getCallFlowFunctionImpl(n_t CallInst,
f_t CalleeFun);
[[nodiscard]] FlowFunctionPtrType getRetFlowFunctionImpl(n_t CallSite,
f_t /*CalleeFun*/,
n_t ExitInst,
n_t /*RetSite*/);
[[nodiscard]] FlowFunctionPtrType
getCallToRetFlowFunctionImpl(n_t CallSite, n_t /*RetSite*/,
llvm::ArrayRef<f_t> /*Callees*/);

private:
LLVMAliasInfoRef AS;
};
} // namespace detail

template <typename AnalysisDomainTy>
class DefaultAliasAwareIDEProblem
: public IDETabulationProblem<AnalysisDomainTy>,
protected detail::IDEAliasAwareDefaultFlowFunctionsImpl {
public:
using ProblemAnalysisDomain = AnalysisDomainTy;
using d_t = typename AnalysisDomainTy::d_t;
using n_t = typename AnalysisDomainTy::n_t;
using f_t = typename AnalysisDomainTy::f_t;
using t_t = typename AnalysisDomainTy::t_t;
using v_t = typename AnalysisDomainTy::v_t;
using l_t = typename AnalysisDomainTy::l_t;
using i_t = typename AnalysisDomainTy::i_t;
using db_t = typename AnalysisDomainTy::db_t;

using ConfigurationTy = HasNoConfigurationType;

using FlowFunctionType = FlowFunction<d_t>;
using FlowFunctionPtrType = typename FlowFunctionType::FlowFunctionPtrType;

using container_type = typename FlowFunctionType::container_type;

/// Constructs an IDETabulationProblem with the usual arguments + alias
/// information.
///
/// \note It is useful to use an instance of FilteredAliasSet for the alias
/// information to lower suprious aliases
explicit DefaultAliasAwareIDEProblem(
const ProjectIRDBBase<db_t> *IRDB, LLVMAliasInfoRef AS,
std::vector<std::string> EntryPoints,
std::optional<d_t>
ZeroValue) noexcept(std::is_nothrow_move_constructible_v<d_t>)
: IDETabulationProblem<AnalysisDomainTy>(IRDB, std::move(EntryPoints),
std::move(ZeroValue)),
detail::IDEAliasAwareDefaultFlowFunctionsImpl(AS) {}

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunction(n_t Curr,
n_t Succ) override {
return getNormalFlowFunctionImpl(Curr, Succ);
}

[[nodiscard]] FlowFunctionPtrType
getCallFlowFunction(n_t CallInst, f_t CalleeFun) override {
return getCallFlowFunctionImpl(CallInst, CalleeFun);
}

[[nodiscard]] FlowFunctionPtrType getRetFlowFunction(n_t CallSite,
f_t CalleeFun,
n_t ExitInst,
n_t RetSite) override {
return getRetFlowFunctionImpl(CallSite, CalleeFun, ExitInst, RetSite);
}

[[nodiscard]] FlowFunctionPtrType
getCallToRetFlowFunction(n_t CallSite, n_t RetSite,
llvm::ArrayRef<f_t> Callees) override {
return getCallToRetFlowFunctionImpl(CallSite, RetSite, Callees);
}
};

class DefaultAliasAwareIFDSProblem
: public IFDSTabulationProblem<LLVMAnalysisDomainDefault>,
protected detail::IDEAliasAwareDefaultFlowFunctionsImpl {
public:
/// Constructs an IFDSTabulationProblem with the usual arguments + alias
/// information.
///
/// \note It is useful to use an instance of FilteredAliasSet for the alias
/// information to lower suprious aliases
explicit DefaultAliasAwareIFDSProblem(
const ProjectIRDBBase<db_t> *IRDB, LLVMAliasInfoRef AS,
std::vector<std::string> EntryPoints,
d_t ZeroValue) noexcept(std::is_nothrow_move_constructible_v<d_t>)
: IFDSTabulationProblem(IRDB, std::move(EntryPoints), ZeroValue),
detail::IDEAliasAwareDefaultFlowFunctionsImpl(AS) {}

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunction(n_t Curr,
n_t Succ) override {
return getNormalFlowFunctionImpl(Curr, Succ);
}

[[nodiscard]] FlowFunctionPtrType
getCallFlowFunction(n_t CallInst, f_t CalleeFun) override {
return getCallFlowFunctionImpl(CallInst, CalleeFun);
}

[[nodiscard]] FlowFunctionPtrType getRetFlowFunction(n_t CallSite,
f_t CalleeFun,
n_t ExitInst,
n_t RetSite) override {
return getRetFlowFunctionImpl(CallSite, CalleeFun, ExitInst, RetSite);
}

[[nodiscard]] FlowFunctionPtrType
getCallToRetFlowFunction(n_t CallSite, n_t RetSite,
llvm::ArrayRef<f_t> Callees) override {
return getCallToRetFlowFunctionImpl(CallSite, RetSite, Callees);
}
};

} // namespace psr

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#ifndef PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDENOALIASINFOTABULATIONPROBLEM_H
#define PHASAR_PHASARLLVM_DATAFLOW_IFDSIDE_IDENOALIASINFOTABULATIONPROBLEM_H

#include "phasar/DataFlow/IfdsIde/FlowFunctions.h"
#include "phasar/DataFlow/IfdsIde/IDETabulationProblem.h"
#include "phasar/DataFlow/IfdsIde/IFDSTabulationProblem.h"
#include "phasar/PhasarLLVM/Domain/LLVMAnalysisDomain.h"

namespace llvm {
class Value;
class Instruction;
class Function;
} // namespace llvm

namespace psr {

namespace detail {
class IDENoAliasDefaultFlowFunctionsImpl {
public:
using d_t = const llvm::Value *;
using n_t = const llvm::Instruction *;
using f_t = const llvm::Function *;
using FlowFunctionType = FlowFunction<d_t>;
using FlowFunctionPtrType = typename FlowFunctionType::FlowFunctionPtrType;

virtual ~IDENoAliasDefaultFlowFunctionsImpl() = default;

/// True, if the analysis knows this function, either because it is analyzed,
/// or because we have external information about it.
[[nodiscard]] virtual bool isFunctionModeled(f_t Fun) const;

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunctionImpl(n_t Curr,
n_t /*Succ*/);
[[nodiscard]] FlowFunctionPtrType getCallFlowFunctionImpl(n_t CallInst,
f_t CalleeFun);
[[nodiscard]] FlowFunctionPtrType getRetFlowFunctionImpl(n_t CallSite,
f_t /*CalleeFun*/,
n_t ExitInst,
n_t /*RetSite*/);
[[nodiscard]] FlowFunctionPtrType
getCallToRetFlowFunctionImpl(n_t CallSite, n_t /*RetSite*/,
llvm::ArrayRef<f_t> /*Callees*/);
};
} // namespace detail

template <typename AnalysisDomainTy>
class DefaultNoAliasIDEProblem
: public IDETabulationProblem<AnalysisDomainTy>,
protected detail::IDENoAliasDefaultFlowFunctionsImpl {
public:
using ProblemAnalysisDomain = AnalysisDomainTy;
using d_t = typename AnalysisDomainTy::d_t;
using n_t = typename AnalysisDomainTy::n_t;
using f_t = typename AnalysisDomainTy::f_t;
using t_t = typename AnalysisDomainTy::t_t;
using v_t = typename AnalysisDomainTy::v_t;
using l_t = typename AnalysisDomainTy::l_t;
using i_t = typename AnalysisDomainTy::i_t;
using db_t = typename AnalysisDomainTy::db_t;

using ConfigurationTy = HasNoConfigurationType;

using FlowFunctionType = FlowFunction<d_t>;
using FlowFunctionPtrType = typename FlowFunctionType::FlowFunctionPtrType;

using IDETabulationProblem<AnalysisDomainTy>::IDETabulationProblem;

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunction(n_t Curr,
n_t Succ) override {
return getNormalFlowFunctionImpl(Curr, Succ);
}

[[nodiscard]] FlowFunctionPtrType
getCallFlowFunction(n_t CallInst, f_t CalleeFun) override {
return getCallFlowFunctionImpl(CallInst, CalleeFun);
}

[[nodiscard]] FlowFunctionPtrType getRetFlowFunction(n_t CallSite,
f_t CalleeFun,
n_t ExitInst,
n_t RetSite) override {
return getRetFlowFunctionImpl(CallSite, CalleeFun, ExitInst, RetSite);
}

[[nodiscard]] FlowFunctionPtrType
getCallToRetFlowFunction(n_t CallSite, n_t RetSite,
llvm::ArrayRef<f_t> Callees) override {
return getCallToRetFlowFunctionImpl(CallSite, RetSite, Callees);
}
};

class DefaultNoAliasIFDSProblem
: public IFDSTabulationProblem<LLVMIFDSAnalysisDomainDefault>,
protected detail::IDENoAliasDefaultFlowFunctionsImpl {
public:
using IFDSTabulationProblem::IFDSTabulationProblem;

[[nodiscard]] FlowFunctionPtrType getNormalFlowFunction(n_t Curr,
n_t Succ) override {
return getNormalFlowFunctionImpl(Curr, Succ);
}

[[nodiscard]] FlowFunctionPtrType
getCallFlowFunction(n_t CallInst, f_t CalleeFun) override {
return getCallFlowFunctionImpl(CallInst, CalleeFun);
}

[[nodiscard]] FlowFunctionPtrType getRetFlowFunction(n_t CallSite,
f_t CalleeFun,
n_t ExitInst,
n_t RetSite) override {
return getRetFlowFunctionImpl(CallSite, CalleeFun, ExitInst, RetSite);
}

[[nodiscard]] FlowFunctionPtrType
getCallToRetFlowFunction(n_t CallSite, n_t RetSite,
llvm::ArrayRef<f_t> Callees) override {
return getCallToRetFlowFunctionImpl(CallSite, RetSite, Callees);
}
};

} // namespace psr

#endif
3 changes: 2 additions & 1 deletion include/phasar/PhasarLLVM/Pointer/FilteredLLVMAliasSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class FilteredLLVMAliasSet {
typename = std::enable_if_t<
std::is_constructible_v<LLVMAliasSet, ArgsT...>>>
explicit FilteredLLVMAliasSet(ArgsT &&...Args)
: FilteredLLVMAliasSet(std::forward<ArgsT>(Args)...) {}
: FilteredLLVMAliasSet(
std::make_unique<LLVMAliasSet>(std::forward<ArgsT>(Args)...)) {}

// --- API Functions:

Expand Down
Loading
Loading