Skip to content

Commit 6a5d3a1

Browse files
committed
Final refactoring with working build
1 parent 8b96890 commit 6a5d3a1

1 file changed

Lines changed: 33 additions & 33 deletions

File tree

  • include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Solver

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Solver/IDESolver.h

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
namespace psr {
5757

5858
// Forward declare the Transformation
59-
template <typename N, typename D, typename M, typename T, typename V,
59+
template <typename N, typename D, typename F, typename T, typename V,
6060
typename I>
6161
class IFDSToIDETabulationProblem;
6262

@@ -68,26 +68,26 @@ class IFDSToIDETabulationProblem;
6868
* @param <N> The type of nodes in the interprocedural control-flow graph.
6969
* @param <D> The type of data-flow facts to be computed by the tabulation
7070
* problem.
71-
* @param <M> The type of objects used to represent methods.
71+
* @param <F> The type of objects used to represent functions.
7272
* @param <T> The type of user-defined types that the type hierarchy consists of
7373
* @param <V> The type of values on which points-to information are computed
7474
* @param <L> The type of values to be computed along flow edges.
7575
* @param <I> The type of inter-procedural control-flow graph being used.
7676
*/
77-
template <typename N, typename D, typename M, typename T, typename V,
77+
template <typename N, typename D, typename F, typename T, typename V,
7878
typename L, typename I>
7979
class IDESolver {
8080
public:
81-
using ProblemTy = IDETabulationProblem<N, D, M, T, V, L, I>;
81+
using ProblemTy = IDETabulationProblem<N, D, F, T, V, L, I>;
8282

83-
IDESolver(IDETabulationProblem<N, D, M, T, V, L, I> &tabulationProblem)
83+
IDESolver(IDETabulationProblem<N, D, F, T, V, L, I> &tabulationProblem)
8484
: ideTabulationProblem(tabulationProblem),
8585
zeroValue(tabulationProblem.getZeroValue()),
8686
ICF(tabulationProblem.getICFG()),
8787
SolverConfig(tabulationProblem.getIFDSIDESolverConfig()),
8888
cachedFlowEdgeFunctions(tabulationProblem),
8989
allTop(tabulationProblem.allTopFunction()),
90-
jumpFn(std::make_shared<JumpFunctions<N, D, M, T, V, L, I>>(
90+
jumpFn(std::make_shared<JumpFunctions<N, D, F, T, V, L, I>>(
9191
allTop, ideTabulationProblem)),
9292
initialSeeds(tabulationProblem.initialSeeds()) {}
9393

@@ -243,8 +243,8 @@ class IDESolver {
243243
// });
244244
N prev = N{};
245245
N curr = N{};
246-
M prevFn = M{};
247-
M currFn = M{};
246+
F prevFn = F{};
247+
F currFn = F{};
248248
for (unsigned i = 0; i < cells.size(); ++i) {
249249
curr = cells[i].r;
250250
currFn = ICF->getFunctionOf(curr);
@@ -315,23 +315,23 @@ class IDESolver {
315315

316316
protected:
317317
// have a shared point to allow for a copy constructor of IDESolver
318-
std::unique_ptr<IFDSToIDETabulationProblem<N, D, M, T, V, I>>
318+
std::unique_ptr<IFDSToIDETabulationProblem<N, D, F, T, V, I>>
319319
transformedProblem;
320-
IDETabulationProblem<N, D, M, T, V, L, I> &ideTabulationProblem;
320+
IDETabulationProblem<N, D, F, T, V, L, I> &ideTabulationProblem;
321321
D zeroValue;
322322
const I *ICF;
323323
const IFDSIDESolverConfig SolverConfig;
324324
unsigned PathEdgeCount = 0;
325325

326-
FlowEdgeFunctionCache<N, D, M, T, V, L, I> cachedFlowEdgeFunctions;
326+
FlowEdgeFunctionCache<N, D, F, T, V, L, I> cachedFlowEdgeFunctions;
327327

328328
Table<N, N, std::map<D, std::set<D>>> computedIntraPathEdges;
329329

330330
Table<N, N, std::map<D, std::set<D>>> computedInterPathEdges;
331331

332332
std::shared_ptr<EdgeFunction<L>> allTop;
333333

334-
std::shared_ptr<JumpFunctions<N, D, M, T, V, L, I>> jumpFn;
334+
std::shared_ptr<JumpFunctions<N, D, F, T, V, L, I>> jumpFn;
335335

336336
std::map<std::tuple<N, D, N, D>,
337337
std::vector<std::shared_ptr<EdgeFunction<L>>>>
@@ -361,17 +361,17 @@ class IDESolver {
361361
// a modifiable l-value reference within the IDESolver implementation leads
362362
// to (massive) undefined behavior (and nightmares):
363363
// https://stackoverflow.com/questions/34240794/understanding-the-warning-binding-r-value-to-l-value-reference
364-
IDESolver(IFDSTabulationProblem<N, D, M, T, V, I> &tabulationProblem)
364+
IDESolver(IFDSTabulationProblem<N, D, F, T, V, I> &tabulationProblem)
365365
: transformedProblem(
366-
std::make_unique<IFDSToIDETabulationProblem<N, D, M, T, V, I>>(
366+
std::make_unique<IFDSToIDETabulationProblem<N, D, F, T, V, I>>(
367367
tabulationProblem)),
368368
ideTabulationProblem(*transformedProblem),
369369
zeroValue(ideTabulationProblem.getZeroValue()),
370370
ICF(ideTabulationProblem.getICFG()),
371371
SolverConfig(ideTabulationProblem.getIFDSIDESolverConfig()),
372372
cachedFlowEdgeFunctions(ideTabulationProblem),
373373
allTop(ideTabulationProblem.allTopFunction()),
374-
jumpFn(std::make_shared<JumpFunctions<N, D, M, T, V, L, I>>(
374+
jumpFn(std::make_shared<JumpFunctions<N, D, F, T, V, L, I>>(
375375
allTop, ideTabulationProblem)),
376376
initialSeeds(ideTabulationProblem.initialSeeds()) {}
377377

@@ -405,7 +405,7 @@ class IDESolver {
405405
D d2 = edge.factAtTarget();
406406
std::shared_ptr<EdgeFunction<L>> f = jumpFunction(edge);
407407
std::set<N> returnSiteNs = ICF->getReturnSitesOfCallAt(n);
408-
std::set<M> callees = ICF->getCalleesOfCallAt(n);
408+
std::set<F> callees = ICF->getCalleesOfCallAt(n);
409409
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG) << "Possible callees:");
410410
for (auto callee : callees) {
411411
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
@@ -418,7 +418,7 @@ class IDESolver {
418418
}
419419
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG) << ' ');
420420
// for each possible callee
421-
for (M sCalledProcN : callees) { // still line 14
421+
for (F sCalledProcN : callees) { // still line 14
422422
// check if a special summary for the called procedure exists
423423
std::shared_ptr<FlowFunction<D>> specialSum =
424424
cachedFlowEdgeFunctions.getSummaryFlowFunction(n, sCalledProcN);
@@ -620,38 +620,38 @@ class IDESolver {
620620
D d2 = edge.factAtTarget();
621621
std::shared_ptr<EdgeFunction<L>> f = jumpFunction(edge);
622622
auto successorInst = ICF->getSuccsOf(n);
623-
for (auto m : successorInst) {
623+
for (auto fn : successorInst) {
624624
std::shared_ptr<FlowFunction<D>> flowFunction =
625-
cachedFlowEdgeFunctions.getNormalFlowFunction(n, m);
625+
cachedFlowEdgeFunctions.getNormalFlowFunction(n, fn);
626626
INC_COUNTER("FF Queries", 1, PAMM_SEVERITY_LEVEL::Full);
627627
std::set<D> res = computeNormalFlowFunction(flowFunction, d1, d2);
628628
ADD_TO_HISTOGRAM("Data-flow facts", res.size(), 1,
629629
PAMM_SEVERITY_LEVEL::Full);
630-
saveEdges(n, m, d2, res, false);
630+
saveEdges(n, fn, d2, res, false);
631631
for (D d3 : res) {
632632
std::shared_ptr<EdgeFunction<L>> g =
633-
cachedFlowEdgeFunctions.getNormalEdgeFunction(n, d2, m, d3);
633+
cachedFlowEdgeFunctions.getNormalEdgeFunction(n, d2, fn, d3);
634634
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
635635
<< "Queried Normal Edge Function: " << g->str());
636636
std::shared_ptr<EdgeFunction<L>> fprime = f->composeWith(g);
637637
if (SolverConfig.emitESG) {
638-
intermediateEdgeFunctions[std::make_tuple(n, d2, m, d3)].push_back(
638+
intermediateEdgeFunctions[std::make_tuple(n, d2, fn, d3)].push_back(
639639
fprime);
640640
}
641641
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
642642
<< "Compose: " << g->str() << " * " << f->str() << " = "
643643
<< fprime->str());
644644
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG) << ' ');
645645
INC_COUNTER("EF Queries", 1, PAMM_SEVERITY_LEVEL::Full);
646-
propagate(d1, m, d3, fprime, nullptr, false);
646+
propagate(d1, fn, d3, fprime, nullptr, false);
647647
}
648648
}
649649
}
650650

651651
void propagateValueAtStart(std::pair<N, D> nAndD, N n) {
652652
PAMM_GET_INSTANCE;
653653
D d = nAndD.second;
654-
M p = ICF->getFunctionOf(n);
654+
F p = ICF->getFunctionOf(n);
655655
for (N c : ICF->getCallsFromWithin(p)) {
656656
for (auto entry : jumpFn->forwardLookup(d, c)) {
657657
D dPrime = entry.first;
@@ -668,7 +668,7 @@ class IDESolver {
668668
PAMM_GET_INSTANCE;
669669
auto &lg = lg::get();
670670
D d = nAndD.second;
671-
for (M q : ICF->getCalleesOfCallAt(n)) {
671+
for (F q : ICF->getCalleesOfCallAt(n)) {
672672
std::shared_ptr<FlowFunction<D>> callFlowFunction =
673673
cachedFlowEdgeFunctions.getCallFlowFunction(n, q);
674674
INC_COUNTER("FF Queries", 1, PAMM_SEVERITY_LEVEL::Full);
@@ -935,11 +935,11 @@ class IDESolver {
935935
<< ideTabulationProblem.NtoString(edge.getTarget()));
936936
N n = edge.getTarget(); // an exit node; line 21...
937937
std::shared_ptr<EdgeFunction<L>> f = jumpFunction(edge);
938-
M methodThatNeedsSummary = ICF->getFunctionOf(n);
938+
F functionThatNeedsSummary = ICF->getFunctionOf(n);
939939
D d1 = edge.factAtSource();
940940
D d2 = edge.factAtTarget();
941941
// for each of the method's start points, determine incoming calls
942-
std::set<N> startPointsOf = ICF->getStartPointsOf(methodThatNeedsSummary);
942+
std::set<N> startPointsOf = ICF->getStartPointsOf(functionThatNeedsSummary);
943943
std::map<N, std::set<D>> inc;
944944
for (N sP : startPointsOf) {
945945
// line 21.1 of Naeem/Lhotak/Rodriguez
@@ -961,7 +961,7 @@ class IDESolver {
961961
// compute return-flow function
962962
std::shared_ptr<FlowFunction<D>> retFunction =
963963
cachedFlowEdgeFunctions.getRetFlowFunction(
964-
c, methodThatNeedsSummary, n, retSiteC);
964+
c, functionThatNeedsSummary, n, retSiteC);
965965
INC_COUNTER("FF Queries", 1, PAMM_SEVERITY_LEVEL::Full);
966966
// for each incoming-call value
967967
for (D d4 : entry.second) {
@@ -1033,12 +1033,12 @@ class IDESolver {
10331033
// condition
10341034
if (SolverConfig.followReturnsPastSeeds && inc.empty() &&
10351035
ideTabulationProblem.isZeroValue(d1)) {
1036-
std::set<N> callers = ICF->getCallersOf(methodThatNeedsSummary);
1036+
std::set<N> callers = ICF->getCallersOf(functionThatNeedsSummary);
10371037
for (N c : callers) {
10381038
for (N retSiteC : ICF->getReturnSitesOfCallAt(c)) {
10391039
std::shared_ptr<FlowFunction<D>> retFunction =
10401040
cachedFlowEdgeFunctions.getRetFlowFunction(
1041-
c, methodThatNeedsSummary, n, retSiteC);
1041+
c, functionThatNeedsSummary, n, retSiteC);
10421042
INC_COUNTER("FF Queries", 1, PAMM_SEVERITY_LEVEL::Full);
10431043
std::set<D> targets = computeReturnFlowFunction(
10441044
retFunction, d1, d2, c, std::set<D>{zeroValue});
@@ -1072,7 +1072,7 @@ class IDESolver {
10721072
if (callers.empty()) {
10731073
std::shared_ptr<FlowFunction<D>> retFunction =
10741074
cachedFlowEdgeFunctions.getRetFlowFunction(
1075-
nullptr, methodThatNeedsSummary, n, nullptr);
1075+
nullptr, functionThatNeedsSummary, n, nullptr);
10761076
INC_COUNTER("FF Queries", 1, PAMM_SEVERITY_LEVEL::Full);
10771077
retFunction->computeTargets(d2);
10781078
}
@@ -1361,7 +1361,7 @@ class IDESolver {
13611361
}
13621362

13631363
std::cout << "\n**********************************************************";
1364-
std::cout << "\n* Computed inter-procedural path egdes *";
1364+
std::cout << "\n* Computed inter-procedural path edges *";
13651365
std::cout
13661366
<< "\n**********************************************************\n";
13671367

@@ -1716,7 +1716,7 @@ class IDESolver {
17161716
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
17171717
<< "=============================================");
17181718
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
1719-
<< "Process inter-procedural path egdes");
1719+
<< "Process inter-procedural path edges");
17201720
LOG_IF_ENABLE(BOOST_LOG_SEV(lg, DEBUG)
17211721
<< "=============================================");
17221722
cells = computedInterPathEdges.cellVec();

0 commit comments

Comments
 (0)