svf-tools 1.0.975 → 1.0.976
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/svf/include/AE/Svfexe/AbstractInterpretation.h +1 -1
- package/svf/include/DDA/ContextDDA.h +2 -2
- package/svf/include/DDA/DDAVFSolver.h +5 -5
- package/svf/include/DDA/FlowDDA.h +1 -1
- package/svf/include/Graphs/{PTACallGraph.h → CallGraph.h} +41 -41
- package/svf/include/Graphs/ICFG.h +2 -2
- package/svf/include/Graphs/ThreadCallGraph.h +24 -24
- package/svf/include/Graphs/VFG.h +4 -4
- package/svf/include/MSSA/MemRegion.h +4 -4
- package/svf/include/MTA/LockAnalysis.h +1 -1
- package/svf/include/MTA/MHP.h +2 -2
- package/svf/include/MTA/PCG.h +3 -3
- package/svf/include/MTA/TCT.h +7 -7
- package/svf/include/MemoryModel/PointerAnalysis.h +13 -13
- package/svf/include/SABER/SaberSVFGBuilder.h +1 -1
- package/svf/include/SABER/SrcSnkDDA.h +7 -7
- package/svf/include/Util/CallGraphBuilder.h +5 -5
- package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +1 -1
- package/svf/lib/CFL/CFLSVFGBuilder.cpp +1 -1
- package/svf/lib/DDA/ContextDDA.cpp +9 -9
- package/svf/lib/DDA/DDAClient.cpp +3 -3
- package/svf/lib/DDA/DDAPass.cpp +4 -4
- package/svf/lib/DDA/FlowDDA.cpp +2 -2
- package/svf/lib/Graphs/{PTACallGraph.cpp → CallGraph.cpp} +66 -66
- package/svf/lib/Graphs/ICFG.cpp +6 -6
- package/svf/lib/Graphs/SVFG.cpp +7 -7
- package/svf/lib/Graphs/SVFGReadWrite.cpp +6 -6
- package/svf/lib/Graphs/SVFGStat.cpp +1 -1
- package/svf/lib/Graphs/ThreadCallGraph.cpp +17 -17
- package/svf/lib/Graphs/VFG.cpp +1 -1
- package/svf/lib/MSSA/MemRegion.cpp +7 -7
- package/svf/lib/MTA/LockAnalysis.cpp +18 -18
- package/svf/lib/MTA/MHP.cpp +19 -19
- package/svf/lib/MTA/MTA.cpp +1 -1
- package/svf/lib/MTA/PCG.cpp +12 -12
- package/svf/lib/MTA/TCT.cpp +23 -23
- package/svf/lib/MemoryModel/PointerAnalysis.cpp +12 -12
- package/svf/lib/SABER/LeakChecker.cpp +4 -4
- package/svf/lib/SABER/SaberSVFGBuilder.cpp +4 -4
- package/svf/lib/SABER/SrcSnkDDA.cpp +1 -1
- package/svf/lib/Util/CallGraphBuilder.cpp +2 -2
- package/svf/lib/Util/PTAStat.cpp +7 -7
- package/svf/lib/WPA/VersionedFlowSensitive.cpp +2 -2
- package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +1 -1
- package/svf-llvm/lib/SVFIRBuilder.cpp +5 -5
- package/svf-llvm/tools/AE/ae.cpp +1 -1
- package/svf-llvm/tools/Example/svf-ex.cpp +1 -1
- package/svf-llvm/tools/MTA/LockResultValidator.cpp +2 -2
|
@@ -97,12 +97,12 @@ void LockAnalysis::buildCandidateFuncSetforLock()
|
|
|
97
97
|
ThreadCallGraph* tcg=tct->getThreadCallGraph();
|
|
98
98
|
|
|
99
99
|
TCT::PTACGNodeSet visited;
|
|
100
|
-
FIFOWorkList<const
|
|
100
|
+
FIFOWorkList<const CallGraphNode*> worklist;
|
|
101
101
|
|
|
102
102
|
for (InstSet::iterator it = locksites.begin(), eit = locksites.end(); it != eit; ++it)
|
|
103
103
|
{
|
|
104
104
|
const SVFFunction* fun=(*it)->getParent()->getParent();
|
|
105
|
-
|
|
105
|
+
CallGraphNode* cgnode = tcg->getCallGraphNode(fun);
|
|
106
106
|
if (visited.find(cgnode) == visited.end())
|
|
107
107
|
{
|
|
108
108
|
worklist.push(cgnode);
|
|
@@ -112,7 +112,7 @@ void LockAnalysis::buildCandidateFuncSetforLock()
|
|
|
112
112
|
for (InstSet::iterator it = unlocksites.begin(), eit = unlocksites.end(); it != eit; ++it)
|
|
113
113
|
{
|
|
114
114
|
const SVFFunction* fun = (*it)->getParent()->getParent();
|
|
115
|
-
|
|
115
|
+
CallGraphNode* cgnode = tcg->getCallGraphNode(fun);
|
|
116
116
|
if (visited.find(cgnode) == visited.end())
|
|
117
117
|
{
|
|
118
118
|
worklist.push(cgnode);
|
|
@@ -121,11 +121,11 @@ void LockAnalysis::buildCandidateFuncSetforLock()
|
|
|
121
121
|
}
|
|
122
122
|
while (!worklist.empty())
|
|
123
123
|
{
|
|
124
|
-
const
|
|
124
|
+
const CallGraphNode* node = worklist.pop();
|
|
125
125
|
lockcandidateFuncSet.insert(node->getFunction());
|
|
126
|
-
for (
|
|
126
|
+
for (CallGraphNode::const_iterator nit = node->InEdgeBegin(), neit = node->InEdgeEnd(); nit != neit; nit++)
|
|
127
127
|
{
|
|
128
|
-
const
|
|
128
|
+
const CallGraphNode* srcNode = (*nit)->getSrcNode();
|
|
129
129
|
if (visited.find(srcNode) == visited.end())
|
|
130
130
|
{
|
|
131
131
|
visited.insert(srcNode);
|
|
@@ -266,16 +266,16 @@ void LockAnalysis::collectCxtLock()
|
|
|
266
266
|
while (!clpList.empty())
|
|
267
267
|
{
|
|
268
268
|
CxtLockProc clp = popFromCTPWorkList();
|
|
269
|
-
|
|
269
|
+
CallGraphNode* cgNode = getTCG()->getCallGraphNode(clp.getProc());
|
|
270
270
|
// lzh TODO.
|
|
271
271
|
if (!isLockCandidateFun(cgNode->getFunction()))
|
|
272
272
|
continue;
|
|
273
273
|
|
|
274
|
-
for (
|
|
274
|
+
for (CallGraphNode::const_iterator nit = cgNode->OutEdgeBegin(), neit = cgNode->OutEdgeEnd(); nit != neit; nit++)
|
|
275
275
|
{
|
|
276
|
-
const
|
|
276
|
+
const CallGraphEdge* cgEdge = (*nit);
|
|
277
277
|
|
|
278
|
-
for (
|
|
278
|
+
for (CallGraphEdge::CallInstSet::const_iterator cit = cgEdge->directCallsBegin(), ecit = cgEdge->directCallsEnd();
|
|
279
279
|
cit != ecit; ++cit)
|
|
280
280
|
{
|
|
281
281
|
DBOUT(DMTA,
|
|
@@ -283,7 +283,7 @@ void LockAnalysis::collectCxtLock()
|
|
|
283
283
|
<< "-->" << cgEdge->getDstNode()->getFunction()->getName() << "\n");
|
|
284
284
|
handleCallRelation(clp, cgEdge, getSVFCallSite((*cit)->getCallSite()));
|
|
285
285
|
}
|
|
286
|
-
for (
|
|
286
|
+
for (CallGraphEdge::CallInstSet::const_iterator ind = cgEdge->indirectCallsBegin(), eind = cgEdge->indirectCallsEnd();
|
|
287
287
|
ind != eind; ++ind)
|
|
288
288
|
{
|
|
289
289
|
DBOUT(DMTA,
|
|
@@ -300,7 +300,7 @@ void LockAnalysis::collectCxtLock()
|
|
|
300
300
|
/*!
|
|
301
301
|
* Handling call relations when collecting context-sensitive locks
|
|
302
302
|
*/
|
|
303
|
-
void LockAnalysis::handleCallRelation(CxtLockProc& clp, const
|
|
303
|
+
void LockAnalysis::handleCallRelation(CxtLockProc& clp, const CallGraphEdge* cgEdge, CallSite cs)
|
|
304
304
|
{
|
|
305
305
|
|
|
306
306
|
CallStrCxt cxt(clp.getContext());
|
|
@@ -429,7 +429,7 @@ void LockAnalysis::handleCall(const CxtStmt& cts)
|
|
|
429
429
|
CallICFGNode* cbn = tct->getCallICFGNode(call);
|
|
430
430
|
if (getTCG()->hasCallGraphEdge(cbn))
|
|
431
431
|
{
|
|
432
|
-
for (
|
|
432
|
+
for (CallGraph::CallGraphEdgeSet::const_iterator cgIt = getTCG()->getCallEdgeBegin(cbn), ecgIt = getTCG()->getCallEdgeEnd(cbn);
|
|
433
433
|
cgIt != ecgIt; ++cgIt)
|
|
434
434
|
{
|
|
435
435
|
const SVFFunction* svfcallee = (*cgIt)->getDstNode()->getFunction();
|
|
@@ -451,14 +451,14 @@ void LockAnalysis::handleRet(const CxtStmt& cts)
|
|
|
451
451
|
const SVFInstruction* curInst = cts.getStmt();
|
|
452
452
|
const CallStrCxt& curCxt = cts.getContext();
|
|
453
453
|
const SVFFunction* svffun = curInst->getFunction();
|
|
454
|
-
|
|
454
|
+
CallGraphNode* curFunNode = getTCG()->getCallGraphNode(svffun);
|
|
455
455
|
|
|
456
|
-
for (
|
|
456
|
+
for (CallGraphNode::const_iterator it = curFunNode->getInEdges().begin(), eit = curFunNode->getInEdges().end(); it != eit; ++it)
|
|
457
457
|
{
|
|
458
|
-
|
|
458
|
+
CallGraphEdge* edge = *it;
|
|
459
459
|
if (SVFUtil::isa<ThreadForkEdge, ThreadJoinEdge>(edge))
|
|
460
460
|
continue;
|
|
461
|
-
for (
|
|
461
|
+
for (CallGraphEdge::CallInstSet::const_iterator cit = (edge)->directCallsBegin(), ecit = (edge)->directCallsEnd(); cit != ecit;
|
|
462
462
|
++cit)
|
|
463
463
|
{
|
|
464
464
|
CallStrCxt newCxt = curCxt;
|
|
@@ -473,7 +473,7 @@ void LockAnalysis::handleRet(const CxtStmt& cts)
|
|
|
473
473
|
}
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
|
-
for (
|
|
476
|
+
for (CallGraphEdge::CallInstSet::const_iterator cit = (edge)->indirectCallsBegin(), ecit = (edge)->indirectCallsEnd();
|
|
477
477
|
cit != ecit; ++cit)
|
|
478
478
|
{
|
|
479
479
|
CallStrCxt newCxt = curCxt;
|
package/svf/lib/MTA/MHP.cpp
CHANGED
|
@@ -115,7 +115,7 @@ void MHP::analyzeInterleaving()
|
|
|
115
115
|
else if (SVFUtil::isCallSite(curInst) && !isExtCall(curInst))
|
|
116
116
|
{
|
|
117
117
|
handleCall(cts, rootTid);
|
|
118
|
-
|
|
118
|
+
CallGraph::FunctionSet callees;
|
|
119
119
|
if (!tct->isCandidateFun(getCallee(curInst, callees)))
|
|
120
120
|
handleIntra(cts);
|
|
121
121
|
}
|
|
@@ -183,8 +183,8 @@ void MHP::handleNonCandidateFun(const CxtThreadStmt& cts)
|
|
|
183
183
|
const SVFFunction* curfun = curInst->getParent()->getParent();
|
|
184
184
|
assert((curInst == curfun->getEntryBlock()->front()) && "curInst is not the entry of non candidate function.");
|
|
185
185
|
const CallStrCxt& curCxt = cts.getContext();
|
|
186
|
-
|
|
187
|
-
for (
|
|
186
|
+
CallGraphNode* node = tcg->getCallGraphNode(curfun);
|
|
187
|
+
for (CallGraphNode::const_iterator nit = node->OutEdgeBegin(), neit = node->OutEdgeEnd(); nit != neit; nit++)
|
|
188
188
|
{
|
|
189
189
|
const SVFFunction* callee = (*nit)->getDstNode()->getFunction();
|
|
190
190
|
if (!isExtCall(callee))
|
|
@@ -293,7 +293,7 @@ void MHP::handleCall(const CxtThreadStmt& cts, NodeID rootTid)
|
|
|
293
293
|
CallICFGNode* cbn = getCBN(call);
|
|
294
294
|
if (tct->getThreadCallGraph()->hasCallGraphEdge(cbn))
|
|
295
295
|
{
|
|
296
|
-
for (
|
|
296
|
+
for (CallGraph::CallGraphEdgeSet::const_iterator cgIt = tcg->getCallEdgeBegin(cbn),
|
|
297
297
|
ecgIt = tcg->getCallEdgeEnd(cbn);
|
|
298
298
|
cgIt != ecgIt; ++cgIt)
|
|
299
299
|
{
|
|
@@ -315,12 +315,12 @@ void MHP::handleCall(const CxtThreadStmt& cts, NodeID rootTid)
|
|
|
315
315
|
*/
|
|
316
316
|
void MHP::handleRet(const CxtThreadStmt& cts)
|
|
317
317
|
{
|
|
318
|
-
|
|
319
|
-
for (
|
|
318
|
+
CallGraphNode* curFunNode = tcg->getCallGraphNode(cts.getStmt()->getParent()->getParent());
|
|
319
|
+
for (CallGraphEdge* edge : curFunNode->getInEdges())
|
|
320
320
|
{
|
|
321
321
|
if (SVFUtil::isa<ThreadForkEdge, ThreadJoinEdge>(edge))
|
|
322
322
|
continue;
|
|
323
|
-
for (
|
|
323
|
+
for (CallGraphEdge::CallInstSet::const_iterator cit = (edge)->directCallsBegin(),
|
|
324
324
|
ecit = (edge)->directCallsEnd();
|
|
325
325
|
cit != ecit; ++cit)
|
|
326
326
|
{
|
|
@@ -335,7 +335,7 @@ void MHP::handleRet(const CxtThreadStmt& cts)
|
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
for (
|
|
338
|
+
for (CallGraphEdge::CallInstSet::const_iterator cit = (edge)->indirectCallsBegin(),
|
|
339
339
|
ecit = (edge)->indirectCallsEnd();
|
|
340
340
|
cit != ecit; ++cit)
|
|
341
341
|
{
|
|
@@ -508,19 +508,19 @@ bool MHP::isHBPair(NodeID tid1, NodeID tid2)
|
|
|
508
508
|
|
|
509
509
|
bool MHP::isConnectedfromMain(const SVFFunction* fun)
|
|
510
510
|
{
|
|
511
|
-
|
|
512
|
-
FIFOWorkList<const
|
|
511
|
+
CallGraphNode* cgnode = tcg->getCallGraphNode(fun);
|
|
512
|
+
FIFOWorkList<const CallGraphNode*> worklist;
|
|
513
513
|
TCT::PTACGNodeSet visited;
|
|
514
514
|
worklist.push(cgnode);
|
|
515
515
|
visited.insert(cgnode);
|
|
516
516
|
while (!worklist.empty())
|
|
517
517
|
{
|
|
518
|
-
const
|
|
518
|
+
const CallGraphNode* node = worklist.pop();
|
|
519
519
|
if ("main" == node->getFunction()->getName())
|
|
520
520
|
return true;
|
|
521
|
-
for (
|
|
521
|
+
for (CallGraphNode::const_iterator nit = node->InEdgeBegin(), neit = node->InEdgeEnd(); nit != neit; nit++)
|
|
522
522
|
{
|
|
523
|
-
const
|
|
523
|
+
const CallGraphNode* srcNode = (*nit)->getSrcNode();
|
|
524
524
|
if (visited.find(srcNode) == visited.end())
|
|
525
525
|
{
|
|
526
526
|
visited.insert(srcNode);
|
|
@@ -733,7 +733,7 @@ void ForkJoinAnalysis::analyzeForkJoinPair()
|
|
|
733
733
|
DBOUT(DMTA, outs() << "-----\nForkJoinAnalysis root thread: " << tpair.first << " ");
|
|
734
734
|
DBOUT(DMTA, cts.dump());
|
|
735
735
|
DBOUT(DMTA, outs() << "-----\n");
|
|
736
|
-
|
|
736
|
+
CallGraph::FunctionSet callees;
|
|
737
737
|
if (isTDFork(curInst))
|
|
738
738
|
{
|
|
739
739
|
handleFork(cts, rootTid);
|
|
@@ -869,7 +869,7 @@ void ForkJoinAnalysis::handleCall(const CxtStmt& cts, NodeID rootTid)
|
|
|
869
869
|
CallICFGNode* cbn = getCBN(call);
|
|
870
870
|
if (getTCG()->hasCallGraphEdge(cbn))
|
|
871
871
|
{
|
|
872
|
-
for (
|
|
872
|
+
for (CallGraph::CallGraphEdgeSet::const_iterator cgIt = getTCG()->getCallEdgeBegin(cbn),
|
|
873
873
|
ecgIt = getTCG()->getCallEdgeEnd(cbn);
|
|
874
874
|
cgIt != ecgIt; ++cgIt)
|
|
875
875
|
{
|
|
@@ -892,12 +892,12 @@ void ForkJoinAnalysis::handleRet(const CxtStmt& cts)
|
|
|
892
892
|
const SVFInstruction* curInst = cts.getStmt();
|
|
893
893
|
const CallStrCxt& curCxt = cts.getContext();
|
|
894
894
|
|
|
895
|
-
|
|
896
|
-
for (
|
|
895
|
+
CallGraphNode* curFunNode = getTCG()->getCallGraphNode(curInst->getFunction());
|
|
896
|
+
for (CallGraphEdge* edge : curFunNode->getInEdges())
|
|
897
897
|
{
|
|
898
898
|
if (SVFUtil::isa<ThreadForkEdge, ThreadJoinEdge>(edge))
|
|
899
899
|
continue;
|
|
900
|
-
for (
|
|
900
|
+
for (CallGraphEdge::CallInstSet::const_iterator cit = edge->directCallsBegin(),
|
|
901
901
|
ecit = edge->directCallsEnd();
|
|
902
902
|
cit != ecit; ++cit)
|
|
903
903
|
{
|
|
@@ -912,7 +912,7 @@ void ForkJoinAnalysis::handleRet(const CxtStmt& cts)
|
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
|
-
for (
|
|
915
|
+
for (CallGraphEdge::CallInstSet::const_iterator cit = edge->indirectCallsBegin(),
|
|
916
916
|
ecit = edge->indirectCallsEnd();
|
|
917
917
|
cit != ecit; ++cit)
|
|
918
918
|
{
|
package/svf/lib/MTA/MTA.cpp
CHANGED
|
@@ -124,7 +124,7 @@ MHP* MTA::computeMHP(SVFModule* module)
|
|
|
124
124
|
DBOUT(DMTA, outs() << pasMsg("MTA analysis\n"));
|
|
125
125
|
SVFIR* pag = PAG::getPAG();
|
|
126
126
|
PointerAnalysis* pta = AndersenWaveDiff::createAndersenWaveDiff(pag);
|
|
127
|
-
pta->
|
|
127
|
+
pta->getCallGraph()->dump("ptacg");
|
|
128
128
|
|
|
129
129
|
DBOUT(DGENERAL, outs() << pasMsg("Build TCT\n"));
|
|
130
130
|
DBOUT(DMTA, outs() << pasMsg("Build TCT\n"));
|
package/svf/lib/MTA/PCG.cpp
CHANGED
|
@@ -49,7 +49,7 @@ using namespace SVFUtil;
|
|
|
49
49
|
bool PCG::analyze()
|
|
50
50
|
{
|
|
51
51
|
|
|
52
|
-
//callgraph = new
|
|
52
|
+
//callgraph = new CallGraph(mod);
|
|
53
53
|
|
|
54
54
|
DBOUT(DMTA, outs() << pasMsg("Starting MHP analysis\n"));
|
|
55
55
|
|
|
@@ -155,11 +155,11 @@ void PCG::collectSpawners()
|
|
|
155
155
|
while (!worklist.empty())
|
|
156
156
|
{
|
|
157
157
|
const SVFFunction* svffun = worklist.pop();
|
|
158
|
-
|
|
159
|
-
for (
|
|
158
|
+
CallGraphNode* funNode = callgraph->getCallGraphNode(svffun);
|
|
159
|
+
for (CallGraphNode::const_iterator it = funNode->InEdgeBegin(), eit = funNode->InEdgeEnd(); it != eit;
|
|
160
160
|
++it)
|
|
161
161
|
{
|
|
162
|
-
|
|
162
|
+
CallGraphEdge* callEdge = (*it);
|
|
163
163
|
const SVFFunction* caller = callEdge->getSrcNode()->getFunction();
|
|
164
164
|
if (isSpawnerFun(caller) == false)
|
|
165
165
|
{
|
|
@@ -167,12 +167,12 @@ void PCG::collectSpawners()
|
|
|
167
167
|
addSpawnerFun(caller);
|
|
168
168
|
}
|
|
169
169
|
/// add all the callsites from callers to callee (spawner) as a spawn site.
|
|
170
|
-
for (
|
|
170
|
+
for (CallGraphEdge::CallInstSet::const_iterator dit = callEdge->directCallsBegin(), deit =
|
|
171
171
|
callEdge->directCallsEnd(); dit != deit; ++dit)
|
|
172
172
|
{
|
|
173
173
|
addSpawnsite((*dit)->getCallSite());
|
|
174
174
|
}
|
|
175
|
-
for (
|
|
175
|
+
for (CallGraphEdge::CallInstSet::const_iterator dit = callEdge->indirectCallsBegin(), deit =
|
|
176
176
|
callEdge->indirectCallsEnd(); dit != deit; ++dit)
|
|
177
177
|
{
|
|
178
178
|
addSpawnsite((*dit)->getCallSite());
|
|
@@ -196,8 +196,8 @@ void PCG::collectSpawnees()
|
|
|
196
196
|
while (!worklist.empty())
|
|
197
197
|
{
|
|
198
198
|
const SVFFunction* svffun = worklist.pop();
|
|
199
|
-
|
|
200
|
-
for (
|
|
199
|
+
CallGraphNode* funNode = callgraph->getCallGraphNode(svffun);
|
|
200
|
+
for (CallGraphNode::const_iterator it = funNode->OutEdgeBegin(), eit = funNode->OutEdgeEnd(); it != eit;
|
|
201
201
|
++it)
|
|
202
202
|
{
|
|
203
203
|
const SVFFunction* caller = (*it)->getDstNode()->getFunction();
|
|
@@ -236,10 +236,10 @@ void PCG::identifyFollowers()
|
|
|
236
236
|
CallICFGNode* cbn = getCallICFGNode(inst);
|
|
237
237
|
if (callgraph->hasCallGraphEdge(cbn))
|
|
238
238
|
{
|
|
239
|
-
for (
|
|
239
|
+
for (CallGraph::CallGraphEdgeSet::const_iterator cgIt = callgraph->getCallEdgeBegin(cbn),
|
|
240
240
|
ecgIt = callgraph->getCallEdgeEnd(cbn); cgIt != ecgIt; ++cgIt)
|
|
241
241
|
{
|
|
242
|
-
const
|
|
242
|
+
const CallGraphEdge* edge = *cgIt;
|
|
243
243
|
addFollowerFun(edge->getDstNode()->getFunction());
|
|
244
244
|
}
|
|
245
245
|
}
|
|
@@ -277,8 +277,8 @@ void PCG::collectFollowers()
|
|
|
277
277
|
while (!worklist.empty())
|
|
278
278
|
{
|
|
279
279
|
const SVFFunction* svffun = worklist.pop();
|
|
280
|
-
|
|
281
|
-
for (
|
|
280
|
+
CallGraphNode* funNode = callgraph->getCallGraphNode(svffun);
|
|
281
|
+
for (CallGraphNode::const_iterator it = funNode->OutEdgeBegin(), eit = funNode->OutEdgeEnd(); it != eit;
|
|
282
282
|
++it)
|
|
283
283
|
{
|
|
284
284
|
const SVFFunction* caller = (*it)->getDstNode()->getFunction();
|
package/svf/lib/MTA/TCT.cpp
CHANGED
|
@@ -54,16 +54,16 @@ bool TCT::isInLoopInstruction(const SVFInstruction* inst)
|
|
|
54
54
|
{
|
|
55
55
|
const SVFInstruction* inst = worklist.pop();
|
|
56
56
|
insts.insert(inst);
|
|
57
|
-
|
|
58
|
-
for(
|
|
57
|
+
CallGraphNode* cgnode = tcg->getCallGraphNode(inst->getFunction());
|
|
58
|
+
for(CallGraphNode::const_iterator nit = cgnode->InEdgeBegin(), neit = cgnode->InEdgeEnd(); nit!=neit; nit++)
|
|
59
59
|
{
|
|
60
|
-
for(
|
|
60
|
+
for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->directCallsBegin(),
|
|
61
61
|
ecit = (*nit)->directCallsEnd(); cit!=ecit; ++cit)
|
|
62
62
|
{
|
|
63
63
|
if(insts.insert((*cit)->getCallSite()).second)
|
|
64
64
|
worklist.push((*cit)->getCallSite());
|
|
65
65
|
}
|
|
66
|
-
for(
|
|
66
|
+
for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->indirectCallsBegin(),
|
|
67
67
|
ecit = (*nit)->indirectCallsEnd(); cit!=ecit; ++cit)
|
|
68
68
|
{
|
|
69
69
|
if(insts.insert((*cit)->getCallSite()).second)
|
|
@@ -102,18 +102,18 @@ bool TCT::isInRecursion(const SVFInstruction* inst) const
|
|
|
102
102
|
if(tcgSCC->isInCycle(tcg->getCallGraphNode(svffun)->getId()))
|
|
103
103
|
return true;
|
|
104
104
|
|
|
105
|
-
const
|
|
105
|
+
const CallGraphNode* cgnode = tcg->getCallGraphNode(svffun);
|
|
106
106
|
|
|
107
|
-
for(
|
|
107
|
+
for(CallGraphNode::const_iterator nit = cgnode->InEdgeBegin(), neit = cgnode->InEdgeEnd(); nit!=neit; nit++)
|
|
108
108
|
{
|
|
109
|
-
for(
|
|
109
|
+
for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->directCallsBegin(),
|
|
110
110
|
ecit = (*nit)->directCallsEnd(); cit!=ecit; ++cit)
|
|
111
111
|
{
|
|
112
112
|
const SVFFunction* caller = (*cit)->getCallSite()->getFunction();
|
|
113
113
|
if(visits.find(caller)==visits.end())
|
|
114
114
|
worklist.push(caller);
|
|
115
115
|
}
|
|
116
|
-
for(
|
|
116
|
+
for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->indirectCallsBegin(),
|
|
117
117
|
ecit = (*nit)->indirectCallsEnd(); cit!=ecit; ++cit)
|
|
118
118
|
{
|
|
119
119
|
const SVFFunction* caller = (*cit)->getCallSite()->getFunction();
|
|
@@ -139,7 +139,7 @@ void TCT::markRelProcs()
|
|
|
139
139
|
|
|
140
140
|
for(ThreadCallGraph::ForkEdgeSet::const_iterator nit = tcg->getForkEdgeBegin(*it), neit = tcg->getForkEdgeEnd(*it); nit!=neit; nit++)
|
|
141
141
|
{
|
|
142
|
-
const
|
|
142
|
+
const CallGraphNode* forkeeNode = (*nit)->getDstNode();
|
|
143
143
|
candidateFuncSet.insert(forkeeNode->getFunction());
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -160,18 +160,18 @@ void TCT::markRelProcs()
|
|
|
160
160
|
*/
|
|
161
161
|
void TCT::markRelProcs(const SVFFunction* svffun)
|
|
162
162
|
{
|
|
163
|
-
|
|
164
|
-
FIFOWorkList<const
|
|
163
|
+
CallGraphNode* cgnode = tcg->getCallGraphNode(svffun);
|
|
164
|
+
FIFOWorkList<const CallGraphNode*> worklist;
|
|
165
165
|
PTACGNodeSet visited;
|
|
166
166
|
worklist.push(cgnode);
|
|
167
167
|
visited.insert(cgnode);
|
|
168
168
|
while(!worklist.empty())
|
|
169
169
|
{
|
|
170
|
-
const
|
|
170
|
+
const CallGraphNode* node = worklist.pop();
|
|
171
171
|
candidateFuncSet.insert(node->getFunction());
|
|
172
|
-
for(
|
|
172
|
+
for(CallGraphNode::const_iterator nit = node->InEdgeBegin(), neit = node->InEdgeEnd(); nit!=neit; nit++)
|
|
173
173
|
{
|
|
174
|
-
const
|
|
174
|
+
const CallGraphNode* srcNode = (*nit)->getSrcNode();
|
|
175
175
|
if(visited.find(srcNode)==visited.end())
|
|
176
176
|
{
|
|
177
177
|
visited.insert(srcNode);
|
|
@@ -191,7 +191,7 @@ void TCT::collectEntryFunInCallGraph()
|
|
|
191
191
|
const SVFFunction* fun = (*it);
|
|
192
192
|
if (isExtCall(fun))
|
|
193
193
|
continue;
|
|
194
|
-
|
|
194
|
+
CallGraphNode* node = tcg->getCallGraphNode(fun);
|
|
195
195
|
if (!node->hasIncomingEdge())
|
|
196
196
|
{
|
|
197
197
|
entryFuncSet.insert(fun);
|
|
@@ -241,7 +241,7 @@ void TCT::collectMultiForkedThreads()
|
|
|
241
241
|
/*!
|
|
242
242
|
* Handle call relations
|
|
243
243
|
*/
|
|
244
|
-
void TCT::handleCallRelation(CxtThreadProc& ctp, const
|
|
244
|
+
void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, CallSite cs)
|
|
245
245
|
{
|
|
246
246
|
const SVFFunction* callee = cgEdge->getDstNode()->getFunction();
|
|
247
247
|
|
|
@@ -249,7 +249,7 @@ void TCT::handleCallRelation(CxtThreadProc& ctp, const PTACallGraphEdge* cgEdge,
|
|
|
249
249
|
CallStrCxt oldCxt = cxt;
|
|
250
250
|
pushCxt(cxt,cs.getInstruction(),callee);
|
|
251
251
|
|
|
252
|
-
if(cgEdge->getEdgeKind() ==
|
|
252
|
+
if(cgEdge->getEdgeKind() == CallGraphEdge::CallRetEdge)
|
|
253
253
|
{
|
|
254
254
|
CxtThreadProc newctp(ctp.getTid(),cxt,callee);
|
|
255
255
|
if(pushToCTPWorkList(newctp))
|
|
@@ -259,7 +259,7 @@ void TCT::handleCallRelation(CxtThreadProc& ctp, const PTACallGraphEdge* cgEdge,
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
else if(cgEdge->getEdgeKind() ==
|
|
262
|
+
else if(cgEdge->getEdgeKind() == CallGraphEdge::TDForkEdge)
|
|
263
263
|
{
|
|
264
264
|
/// Create spawnee TCT node
|
|
265
265
|
TCTNode* spawneeNode = getOrCreateTCTNode(cxt,cs.getInstruction(), oldCxt, callee);
|
|
@@ -404,21 +404,21 @@ void TCT::build()
|
|
|
404
404
|
while(!ctpList.empty())
|
|
405
405
|
{
|
|
406
406
|
CxtThreadProc ctp = popFromCTPWorkList();
|
|
407
|
-
|
|
407
|
+
CallGraphNode* cgNode = tcg->getCallGraphNode(ctp.getProc());
|
|
408
408
|
if(isCandidateFun(cgNode->getFunction()) == false)
|
|
409
409
|
continue;
|
|
410
410
|
|
|
411
|
-
for(
|
|
411
|
+
for(CallGraphNode::const_iterator nit = cgNode->OutEdgeBegin(), neit = cgNode->OutEdgeEnd(); nit!=neit; nit++)
|
|
412
412
|
{
|
|
413
|
-
const
|
|
413
|
+
const CallGraphEdge* cgEdge = (*nit);
|
|
414
414
|
|
|
415
|
-
for(
|
|
415
|
+
for(CallGraphEdge::CallInstSet::const_iterator cit = cgEdge->directCallsBegin(),
|
|
416
416
|
ecit = cgEdge->directCallsEnd(); cit!=ecit; ++cit)
|
|
417
417
|
{
|
|
418
418
|
DBOUT(DMTA,outs() << "\nTCT handling direct call:" << **cit << "\t" << cgEdge->getSrcNode()->getFunction()->getName() << "-->" << cgEdge->getDstNode()->getFunction()->getName() << "\n");
|
|
419
419
|
handleCallRelation(ctp,cgEdge,getSVFCallSite((*cit)->getCallSite()));
|
|
420
420
|
}
|
|
421
|
-
for(
|
|
421
|
+
for(CallGraphEdge::CallInstSet::const_iterator ind = cgEdge->indirectCallsBegin(),
|
|
422
422
|
eind = cgEdge->indirectCallsEnd(); ind!=eind; ++ind)
|
|
423
423
|
{
|
|
424
424
|
DBOUT(DMTA,outs() << "\nTCT handling indirect call:" << **ind << "\t" << cgEdge->getSrcNode()->getFunction()->getName() << "-->" << cgEdge->getDstNode()->getFunction()->getName() << "\n");
|
|
@@ -66,7 +66,7 @@ const std::string PointerAnalysis::aliasTestFailNoAliasMangled = "_Z20EXPECTEDF
|
|
|
66
66
|
* Constructor
|
|
67
67
|
*/
|
|
68
68
|
PointerAnalysis::PointerAnalysis(SVFIR* p, PTATY ty, bool alias_check) :
|
|
69
|
-
svfMod(nullptr),ptaTy(ty),stat(nullptr),
|
|
69
|
+
svfMod(nullptr),ptaTy(ty),stat(nullptr),callgraph(nullptr),callGraphSCC(nullptr),icfg(nullptr),chgraph(nullptr)
|
|
70
70
|
{
|
|
71
71
|
pag = p;
|
|
72
72
|
OnTheFlyIterBudgetForStat = Options::StatBudget();
|
|
@@ -88,8 +88,8 @@ PointerAnalysis::~PointerAnalysis()
|
|
|
88
88
|
|
|
89
89
|
void PointerAnalysis::destroy()
|
|
90
90
|
{
|
|
91
|
-
delete
|
|
92
|
-
|
|
91
|
+
delete callgraph;
|
|
92
|
+
callgraph = nullptr;
|
|
93
93
|
|
|
94
94
|
delete callGraphSCC;
|
|
95
95
|
callGraphSCC = nullptr;
|
|
@@ -113,19 +113,19 @@ void PointerAnalysis::initialize()
|
|
|
113
113
|
{
|
|
114
114
|
ThreadCallGraph* cg = new ThreadCallGraph();
|
|
115
115
|
ThreadCallGraphBuilder bd(cg, pag->getICFG());
|
|
116
|
-
|
|
116
|
+
callgraph = bd.buildThreadCallGraph(pag->getModule());
|
|
117
117
|
}
|
|
118
118
|
else
|
|
119
119
|
{
|
|
120
|
-
|
|
120
|
+
CallGraph* cg = new CallGraph();
|
|
121
121
|
CallGraphBuilder bd(cg,pag->getICFG());
|
|
122
|
-
|
|
122
|
+
callgraph = bd.buildCallGraph(pag->getModule());
|
|
123
123
|
}
|
|
124
124
|
callGraphSCCDetection();
|
|
125
125
|
|
|
126
126
|
// dump callgraph
|
|
127
127
|
if (Options::CallGraphDotGraph())
|
|
128
|
-
|
|
128
|
+
getCallGraph()->dump("callgraph_initial");
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
|
|
@@ -140,7 +140,7 @@ bool PointerAnalysis::isLocalVarInRecursiveFun(NodeID id) const
|
|
|
140
140
|
{
|
|
141
141
|
if(const SVFFunction* svffun = pag->getGNode(id)->getFunction())
|
|
142
142
|
{
|
|
143
|
-
return callGraphSCC->isInCycle(
|
|
143
|
+
return callGraphSCC->isInCycle(getCallGraph()->getCallGraphNode(svffun)->getId());
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
return false;
|
|
@@ -198,10 +198,10 @@ void PointerAnalysis::finalize()
|
|
|
198
198
|
if (Options::FuncPointerPrint())
|
|
199
199
|
printIndCSTargets();
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
getCallGraph()->verifyCallGraph();
|
|
202
202
|
|
|
203
203
|
if (Options::CallGraphDotGraph())
|
|
204
|
-
|
|
204
|
+
getCallGraph()->dump("callgraph_final");
|
|
205
205
|
|
|
206
206
|
if(!pag->isBuiltFromFile() && alias_validation)
|
|
207
207
|
validateTests();
|
|
@@ -412,7 +412,7 @@ void PointerAnalysis::resolveIndCalls(const CallICFGNode* cs, const PointsTo& ta
|
|
|
412
412
|
newEdges[cs].insert(callee);
|
|
413
413
|
getIndCallMap()[cs].insert(callee);
|
|
414
414
|
|
|
415
|
-
|
|
415
|
+
callgraph->addIndirectCallGraphEdge(cs, cs->getCaller(), callee);
|
|
416
416
|
// FIXME: do we need to update llvm call graph here?
|
|
417
417
|
// The indirect call is maintained by ourself, We may update llvm's when we need to
|
|
418
418
|
//CallGraphNode* callgraphNode = callgraph->getOrInsertFunction(cs.getCaller());
|
|
@@ -477,7 +477,7 @@ void PointerAnalysis::connectVCallToVFns(const CallICFGNode* cs, const VFunSet &
|
|
|
477
477
|
newEdges[cs].insert(callee);
|
|
478
478
|
getIndCallMap()[cs].insert(callee);
|
|
479
479
|
const CallICFGNode* callBlockNode = pag->getICFG()->getCallICFGNode(cs->getCallSite());
|
|
480
|
-
|
|
480
|
+
callgraph->addIndirectCallGraphEdge(callBlockNode, cs->getCaller(),callee);
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
}
|
|
@@ -52,9 +52,9 @@ void LeakChecker::initSrcs()
|
|
|
52
52
|
if(cs->getCallSite()->ptrInUncalledFunction() || !cs->getCallSite()->getType()->isPointerTy())
|
|
53
53
|
continue;
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
CallGraph::FunctionSet callees;
|
|
56
56
|
getCallgraph()->getCallees(cs->getCallICFGNode(),callees);
|
|
57
|
-
for(
|
|
57
|
+
for(CallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++)
|
|
58
58
|
{
|
|
59
59
|
const SVFFunction* fun = *cit;
|
|
60
60
|
if (isSourceLikeFun(fun))
|
|
@@ -112,9 +112,9 @@ void LeakChecker::initSnks()
|
|
|
112
112
|
eit = pag->getCallSiteArgsMap().end(); it!=eit; ++it)
|
|
113
113
|
{
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
CallGraph::FunctionSet callees;
|
|
116
116
|
getCallgraph()->getCallees(it->first,callees);
|
|
117
|
-
for(
|
|
117
|
+
for(CallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++)
|
|
118
118
|
{
|
|
119
119
|
const SVFFunction* fun = *cit;
|
|
120
120
|
if (isSinkLikeFun(fun))
|
|
@@ -57,7 +57,7 @@ void SaberSVFGBuilder::buildSVFG()
|
|
|
57
57
|
|
|
58
58
|
DBOUT(DGENERAL, outs() << pasMsg("\tAdd Sink SVFG Nodes\n"));
|
|
59
59
|
|
|
60
|
-
AddExtActualParmSVFGNodes(pta->
|
|
60
|
+
AddExtActualParmSVFGNodes(pta->getCallGraph());
|
|
61
61
|
|
|
62
62
|
if(pta->printStat())
|
|
63
63
|
svfg->performStat();
|
|
@@ -291,15 +291,15 @@ void SaberSVFGBuilder::rmIncomingEdgeForSUStore(BVDataPTAImpl* pta)
|
|
|
291
291
|
|
|
292
292
|
|
|
293
293
|
/// Add actual parameter SVFGNode for 1st argument of a deallocation like external function
|
|
294
|
-
void SaberSVFGBuilder::AddExtActualParmSVFGNodes(
|
|
294
|
+
void SaberSVFGBuilder::AddExtActualParmSVFGNodes(CallGraph* callgraph)
|
|
295
295
|
{
|
|
296
296
|
SVFIR* pag = SVFIR::getPAG();
|
|
297
297
|
for(SVFIR::CSToArgsListMap::iterator it = pag->getCallSiteArgsMap().begin(),
|
|
298
298
|
eit = pag->getCallSiteArgsMap().end(); it!=eit; ++it)
|
|
299
299
|
{
|
|
300
|
-
|
|
300
|
+
CallGraph::FunctionSet callees;
|
|
301
301
|
callgraph->getCallees(it->first, callees);
|
|
302
|
-
for (
|
|
302
|
+
for (CallGraph::FunctionSet::const_iterator cit = callees.begin(),
|
|
303
303
|
ecit = callees.end(); cit != ecit; cit++)
|
|
304
304
|
{
|
|
305
305
|
|
|
@@ -49,7 +49,7 @@ void SrcSnkDDA::initialize(SVFModule* module)
|
|
|
49
49
|
else
|
|
50
50
|
svfg = memSSA.buildPTROnlySVFG(ander);
|
|
51
51
|
setGraph(memSSA.getSVFG());
|
|
52
|
-
|
|
52
|
+
callgraph = ander->getCallGraph();
|
|
53
53
|
//AndersenWaveDiff::releaseAndersenWaveDiff();
|
|
54
54
|
/// allocate control-flow graph branch conditions
|
|
55
55
|
getSaberCondAllocator()->allocate(getPAG()->getModule());
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
using namespace SVF;
|
|
36
36
|
using namespace SVFUtil;
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
CallGraph* CallGraphBuilder::buildCallGraph(SVFModule* svfModule)
|
|
39
39
|
{
|
|
40
40
|
/// create nodes
|
|
41
41
|
for (SVFModule::const_iterator F = svfModule->begin(), E = svfModule->end(); F != E; ++F)
|
|
@@ -65,7 +65,7 @@ PTACallGraph* CallGraphBuilder::buildCallGraph(SVFModule* svfModule)
|
|
|
65
65
|
return callgraph;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
CallGraph* ThreadCallGraphBuilder::buildThreadCallGraph(SVFModule* svfModule)
|
|
69
69
|
{
|
|
70
70
|
|
|
71
71
|
buildCallGraph(svfModule);
|