Skip to content

Commit

Permalink
Merge branch 'development' into f-GetAsJsonRefactor
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianbs96 committed Aug 9, 2024
2 parents a2cfbe1 + 6e0f6f6 commit a38035f
Show file tree
Hide file tree
Showing 38 changed files with 374 additions and 365 deletions.
1 change: 1 addition & 0 deletions BreakingChanges.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## development HEAD

- Removed the phasar-library `phasar_controller`. It is now part of the tool `phasar-cli`.
- The API of the `TypeHierarchy` interface (and thus the `LLVMTypeHierarchy` and `DIBasedTypeHierarchy` as well) has changed:
- No handling of the super-type relation (only sub-types)
- No VTable handling anymore -- has been out-sourced into `LLVMVFTableProvider`
Expand Down
1 change: 0 additions & 1 deletion Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ set(PHASAR_COMPONENTS
llvm
llvm_ifdside
analysis_strategy
controller
)

list(REMOVE_DUPLICATES phasar_FIND_COMPONENTS)
Expand Down
1 change: 0 additions & 1 deletion include/phasar.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "phasar/AnalysisStrategy.h"
#include "phasar/Config.h"
#include "phasar/ControlFlow.h"
#include "phasar/Controller.h"
#include "phasar/DB.h"
#include "phasar/DataFlow.h"
#include "phasar/Domain.h"
Expand Down
16 changes: 0 additions & 16 deletions include/phasar/Controller.h

This file was deleted.

37 changes: 37 additions & 0 deletions include/phasar/DataFlow/IfdsIde/EdgeFunctionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,23 @@ defaultComposeOrNull(EdgeFunctionRef<ConcreteEF> This,
return nullptr;
}

template <typename L>
EdgeFunction<L>
defaultComposeOrNull(const EdgeFunction<L> &This,
const EdgeFunction<L> &SecondFunction) noexcept {
if (llvm::isa<EdgeIdentity<L>>(SecondFunction)) {
return This;
}
if (SecondFunction.isConstant() || llvm::isa<AllTop<L>>(This) ||
llvm::isa<EdgeIdentity<L>>(This)) {
return SecondFunction;
}
if (llvm::isa<AllBottom<L>>(This)) {
return This;
}
return nullptr;
}

template <typename L> struct ConstantEdgeFunction {
using l_t = L;
using JLattice = JoinLatticeTraits<L>;
Expand Down Expand Up @@ -409,6 +426,26 @@ EdgeFunction<L> defaultJoinOrNull(EdgeFunctionRef<ConcreteEF> This,
return nullptr;
}

template <typename L, uint8_t N = 0>
EdgeFunction<L> defaultJoinOrNull(const EdgeFunction<L> &This,
const EdgeFunction<L> &OtherFunction) {
if (llvm::isa<AllBottom<L>>(OtherFunction) || llvm::isa<AllTop<L>>(This)) {
return OtherFunction;
}
if (llvm::isa<AllTop<L>>(OtherFunction) || OtherFunction == This ||
llvm::isa<AllBottom<L>>(This)) {
return This;
}
if (llvm::isa<EdgeIdentity<L>>(OtherFunction)) {
if constexpr (N > 0) {
return JoinEdgeFunction<L, N>::create(This, OtherFunction);
} else if constexpr (HasJoinLatticeTraits<L>) {
return AllBottom<L>{};
}
}
return nullptr;
}

template <typename L>
EdgeFunction<L> EdgeIdentity<L>::join(EdgeFunctionRef<EdgeIdentity> This,
const EdgeFunction<L> &OtherFunction) {
Expand Down
2 changes: 2 additions & 0 deletions include/phasar/DataFlow/IfdsIde/IDETabulationProblem.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "phasar/Utils/JoinLattice.h"
#include "phasar/Utils/NullAnalysisPrinter.h"
#include "phasar/Utils/Printer.h"
#include "phasar/Utils/SemiRing.h"
#include "phasar/Utils/Soundness.h"

#include "llvm/ADT/StringRef.h"
Expand Down Expand Up @@ -62,6 +63,7 @@ template <typename AnalysisDomainTy,
class IDETabulationProblem : public FlowFunctions<AnalysisDomainTy, Container>,
public EdgeFunctions<AnalysisDomainTy>,
public JoinLattice<AnalysisDomainTy>,
public SemiRing<AnalysisDomainTy>,
public AllTopFnProvider<AnalysisDomainTy> {
public:
using ProblemAnalysisDomain = AnalysisDomainTy;
Expand Down
21 changes: 11 additions & 10 deletions include/phasar/DataFlow/IfdsIde/Solver/IDESolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class IDESolver
PHASAR_LOG_LEVEL(DEBUG,
"Compose: " << SumEdgFnE << " * " << f << '\n');
WorkList.emplace_back(PathEdge(d1, ReturnSiteN, std::move(d3)),
f.composeWith(SumEdgFnE));
IDEProblem.extend(f, SumEdgFnE));
}
}
} else {
Expand Down Expand Up @@ -498,15 +498,15 @@ class IDESolver
<< f4);
PHASAR_LOG_LEVEL(DEBUG,
" (return * calleeSummary * call)");
EdgeFunction<l_t> fPrime =
f4.composeWith(fCalleeSummary).composeWith(f5);
EdgeFunction<l_t> fPrime = IDEProblem.extend(
IDEProblem.extend(f4, fCalleeSummary), f5);
PHASAR_LOG_LEVEL(DEBUG, " = " << fPrime);
d_t d5_restoredCtx = restoreContextOnReturnedFact(n, d2, d5);
// propagte the effects of the entire call
PHASAR_LOG_LEVEL(DEBUG, "Compose: " << fPrime << " * " << f);
WorkList.emplace_back(
PathEdge(d1, RetSiteN, std::move(d5_restoredCtx)),
f.composeWith(fPrime));
IDEProblem.extend(f, fPrime));
}
}
}
Expand Down Expand Up @@ -538,7 +538,7 @@ class IDESolver
.push_back(EdgeFnE);
}
INC_COUNTER("EF Queries", 1, Full);
auto fPrime = f.composeWith(EdgeFnE);
auto fPrime = IDEProblem.extend(f, EdgeFnE);
PHASAR_LOG_LEVEL(DEBUG, "Compose: " << EdgeFnE << " * " << f << " = "
<< fPrime);
WorkList.emplace_back(PathEdge(d1, ReturnSiteN, std::move(d3)),
Expand Down Expand Up @@ -570,7 +570,7 @@ class IDESolver
EdgeFunction<l_t> g =
CachedFlowEdgeFunctions.getNormalEdgeFunction(n, d2, nPrime, d3);
PHASAR_LOG_LEVEL(DEBUG, "Queried Normal Edge Function: " << g);
EdgeFunction<l_t> fPrime = f.composeWith(g);
EdgeFunction<l_t> fPrime = IDEProblem.extend(f, g);
if (SolverConfig.emitESG()) {
IntermediateEdgeFunctions[std::make_tuple(n, d2, nPrime, d3)]
.push_back(g);
Expand Down Expand Up @@ -950,7 +950,8 @@ class IDESolver
PHASAR_LOG_LEVEL(DEBUG,
"Compose: " << f5 << " * " << f << " * " << f4);
PHASAR_LOG_LEVEL(DEBUG, " (return * function * call)");
EdgeFunction<l_t> fPrime = f4.composeWith(f).composeWith(f5);
EdgeFunction<l_t> fPrime =
IDEProblem.extend(IDEProblem.extend(f4, f), f5);
PHASAR_LOG_LEVEL(DEBUG, " = " << fPrime);
// for each jump function coming into the call, propagate to
// return site using the composed function
Expand All @@ -965,7 +966,7 @@ class IDESolver
PHASAR_LOG_LEVEL(DEBUG, "Compose: " << fPrime << " * " << f3);
WorkList.emplace_back(PathEdge(std::move(d3), RetSiteC,
std::move(d5_restoredCtx)),
f3.composeWith(fPrime));
IDEProblem.extend(f3, fPrime));
}
}
}
Expand Down Expand Up @@ -1004,7 +1005,7 @@ class IDESolver
}
INC_COUNTER("EF Queries", 1, Full);
PHASAR_LOG_LEVEL(DEBUG, "Compose: " << f5 << " * " << f);
propagteUnbalancedReturnFlow(RetSiteC, d5, f.composeWith(f5),
propagteUnbalancedReturnFlow(RetSiteC, d5, IDEProblem.extend(f, f5),
Caller);
// register for value processing (2nd IDE phase)
UnbalancedRetSites.insert(RetSiteC);
Expand Down Expand Up @@ -1153,7 +1154,7 @@ class IDESolver
// was found
return AllTop;
}();
EdgeFunction<l_t> fPrime = JumpFnE.joinWith(f);
EdgeFunction<l_t> fPrime = IDEProblem.combine(JumpFnE, f);
bool NewFunction = fPrime != JumpFnE;

IF_LOG_LEVEL_ENABLED(DEBUG, {
Expand Down
Loading

0 comments on commit a38035f

Please sign in to comment.