svf-tools 1.0.976 → 1.0.978
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/Graphs/ThreadCallGraph.h +0 -6
- package/svf/include/MTA/LockAnalysis.h +41 -31
- package/svf/include/MTA/MHP.h +34 -54
- package/svf/include/MTA/MTAStat.h +1 -2
- package/svf/include/MTA/TCT.h +36 -18
- package/svf/include/Util/CxtStmt.h +13 -12
- package/svf/include/Util/Options.h +1 -20
- package/svf/include/Util/SVFUtil.h +8 -43
- package/svf/include/Util/ThreadAPI.h +42 -85
- package/svf/lib/Graphs/ThreadCallGraph.cpp +1 -73
- package/svf/lib/MTA/LockAnalysis.cpp +83 -75
- package/svf/lib/MTA/MHP.cpp +142 -121
- package/svf/lib/MTA/MTA.cpp +2 -40
- package/svf/lib/MTA/MTAStat.cpp +7 -33
- package/svf/lib/MTA/TCT.cpp +30 -30
- package/svf/lib/Util/CallGraphBuilder.cpp +0 -15
- package/svf/lib/Util/Options.cpp +0 -62
- package/svf/lib/Util/ThreadAPI.cpp +27 -6
- package/svf-llvm/lib/SVFIRExtAPI.cpp +0 -26
- package/svf-llvm/tools/MTA/CMakeLists.txt +1 -1
- package/svf-llvm/tools/MTA/mta.cpp +0 -8
- package/svf/include/MTA/FSMPTA.h +0 -270
- package/svf/include/MTA/MTAResultValidator.h +0 -448
- package/svf/include/MTA/PCG.h +0 -229
- package/svf/lib/MTA/FSMPTA.cpp +0 -792
- package/svf/lib/MTA/PCG.cpp +0 -364
- package/svf-llvm/tools/MTA/LockResultValidator.cpp +0 -251
- package/svf-llvm/tools/MTA/LockResultValidator.h +0 -84
- package/svf-llvm/tools/MTA/MTAAnnotator.cpp +0 -293
- package/svf-llvm/tools/MTA/MTAAnnotator.h +0 -120
- package/svf-llvm/tools/MTA/MTAResultValidator.cpp +0 -716
- package/svf-llvm/tools/MTA/MTAResultValidator.h +0 -337
package/svf/lib/MTA/MTA.cpp
CHANGED
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
#include "MTA/LockAnalysis.h"
|
|
36
36
|
#include "MTA/MTAStat.h"
|
|
37
37
|
#include "WPA/Andersen.h"
|
|
38
|
-
#include "MTA/FSMPTA.h"
|
|
39
38
|
#include "Util/SVFUtil.h"
|
|
40
39
|
|
|
41
40
|
using namespace SVF;
|
|
@@ -66,43 +65,6 @@ bool MTA::runOnModule(SVFIR* pag)
|
|
|
66
65
|
|
|
67
66
|
if(Options::RaceCheck())
|
|
68
67
|
detect(pag->getModule());
|
|
69
|
-
/*
|
|
70
|
-
if (Options::AndersenAnno()) {
|
|
71
|
-
pta = mhp->getTCT()->getPTA();
|
|
72
|
-
if (pta->printStat())
|
|
73
|
-
stat->performMHPPairStat(mhp,lsa);
|
|
74
|
-
AndersenWaveDiff::releaseAndersenWaveDiff();
|
|
75
|
-
} else if (Options::FSAnno()) {
|
|
76
|
-
|
|
77
|
-
reportMemoryUsageKB("Mem before analysis");
|
|
78
|
-
DBOUT(DGENERAL, outs() << pasMsg("FSMPTA analysis\n"));
|
|
79
|
-
DBOUT(DMTA, outs() << pasMsg("FSMPTA analysis\n"));
|
|
80
|
-
|
|
81
|
-
DOTIMESTAT(double ptStart = stat->getClk());
|
|
82
|
-
pta = FSMPTA::createFSMPTA(module, mhp,lsa);
|
|
83
|
-
DOTIMESTAT(double ptEnd = stat->getClk());
|
|
84
|
-
DOTIMESTAT(stat->FSMPTATime += (ptEnd - ptStart) / TIMEINTERVAL);
|
|
85
|
-
|
|
86
|
-
reportMemoryUsageKB("Mem after analysis");
|
|
87
|
-
|
|
88
|
-
if (pta->printStat())
|
|
89
|
-
stat->performMHPPairStat(mhp,lsa);
|
|
90
|
-
|
|
91
|
-
FSMPTA::releaseFSMPTA();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (DoInstrumentation) {
|
|
95
|
-
DBOUT(DGENERAL, outs() << pasMsg("ThreadSanitizer Instrumentation\n"));
|
|
96
|
-
DBOUT(DMTA, outs() << pasMsg("ThreadSanitizer Instrumentation\n"));
|
|
97
|
-
TSan tsan;
|
|
98
|
-
tsan.doInitialization(*pta->getModule());
|
|
99
|
-
for (Module::iterator it = pta->getModule()->begin(), eit = pta->getModule()->end(); it != eit; ++it) {
|
|
100
|
-
tsan.runOnFunction(*it);
|
|
101
|
-
}
|
|
102
|
-
if (pta->printStat())
|
|
103
|
-
PrintStatistics();
|
|
104
|
-
}
|
|
105
|
-
*/
|
|
106
68
|
|
|
107
69
|
return false;
|
|
108
70
|
}
|
|
@@ -205,8 +167,8 @@ void MTA::detect(SVFModule* module)
|
|
|
205
167
|
const StoreStmt* store = *sit;
|
|
206
168
|
if(load->getInst()==nullptr || store->getInst()==nullptr)
|
|
207
169
|
continue;
|
|
208
|
-
if(mhp->mayHappenInParallelInst(load->
|
|
209
|
-
if(lsa->isProtectedByCommonLock(load->
|
|
170
|
+
if(mhp->mayHappenInParallelInst(load->getICFGNode(),store->getICFGNode()) && pta->alias(load->getRHSVarID(),store->getLHSVarID()))
|
|
171
|
+
if(lsa->isProtectedByCommonLock(load->getICFGNode(),store->getICFGNode()) == false)
|
|
210
172
|
outs() << SVFUtil::bugMsg1("race pair(") << " store: " << store->toString() << ", load: " << load->toString() << SVFUtil::bugMsg1(")") << "\n";
|
|
211
173
|
}
|
|
212
174
|
}
|
package/svf/lib/MTA/MTAStat.cpp
CHANGED
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
#include "MTA/TCT.h"
|
|
33
33
|
#include "MTA/MHP.h"
|
|
34
34
|
#include "MTA/LockAnalysis.h"
|
|
35
|
-
#include "MTA/FSMPTA.h"
|
|
36
35
|
#include "Graphs/ThreadCallGraph.h"
|
|
37
36
|
|
|
38
37
|
using namespace SVF;
|
|
@@ -115,8 +114,8 @@ void MTAStat::performMHPPairStat(MHP* mhp, LockAnalysis* lsa)
|
|
|
115
114
|
SVFIR* pag = SVFIR::getPAG();
|
|
116
115
|
if(Options::AllPairMHP())
|
|
117
116
|
{
|
|
118
|
-
Set<const
|
|
119
|
-
Set<const
|
|
117
|
+
Set<const ICFGNode*> instSet1;
|
|
118
|
+
Set<const ICFGNode*> instSet2;
|
|
120
119
|
SVFModule* mod = mhp->getTCT()->getSVFModule();
|
|
121
120
|
for (const SVFFunction* fun : mod->getFunctionSet())
|
|
122
121
|
{
|
|
@@ -134,12 +133,12 @@ void MTAStat::performMHPPairStat(MHP* mhp, LockAnalysis* lsa)
|
|
|
134
133
|
{
|
|
135
134
|
if(SVFUtil::isa<LoadStmt>(stmt))
|
|
136
135
|
{
|
|
137
|
-
instSet1.insert(
|
|
136
|
+
instSet1.insert(stmt->getICFGNode());
|
|
138
137
|
}
|
|
139
138
|
else if(SVFUtil::isa<StoreStmt>(stmt))
|
|
140
139
|
{
|
|
141
|
-
instSet1.insert(
|
|
142
|
-
instSet2.insert(
|
|
140
|
+
instSet1.insert(stmt->getICFGNode());
|
|
141
|
+
instSet2.insert(stmt->getICFGNode());
|
|
143
142
|
}
|
|
144
143
|
}
|
|
145
144
|
|
|
@@ -148,9 +147,9 @@ void MTAStat::performMHPPairStat(MHP* mhp, LockAnalysis* lsa)
|
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
|
|
151
|
-
for(Set<const
|
|
150
|
+
for(Set<const ICFGNode*>::const_iterator it1 = instSet1.begin(), eit1 = instSet1.end(); it1!=eit1; ++it1)
|
|
152
151
|
{
|
|
153
|
-
for(Set<const
|
|
152
|
+
for(Set<const ICFGNode*>::const_iterator it2 = instSet2.begin(), eit2 = instSet2.end(); it2!=eit2; ++it2)
|
|
154
153
|
{
|
|
155
154
|
mhp->mayHappenInParallel(*it1,*it2);
|
|
156
155
|
}
|
|
@@ -166,38 +165,13 @@ void MTAStat::performMHPPairStat(MHP* mhp, LockAnalysis* lsa)
|
|
|
166
165
|
PTNumStatMap["TotalLockQueries"] = lsa->numOfTotalQueries;
|
|
167
166
|
PTNumStatMap["NumOfLockedPairs"] = lsa->numOfLockedQueries;
|
|
168
167
|
PTNumStatMap["NumOfCxtLocks"] = lsa->getNumOfCxtLocks();
|
|
169
|
-
PTNumStatMap["NumOfNewSVFGEdges"] = MTASVFGBuilder::numOfNewSVFGEdges;
|
|
170
|
-
PTNumStatMap["NumOfRemovedEdges"] = MTASVFGBuilder::numOfRemovedSVFGEdges;
|
|
171
|
-
PTNumStatMap["NumOfRemovedPTS"] = MTASVFGBuilder::numOfRemovedPTS;
|
|
172
168
|
timeStatMap["InterlevAnaTime"] = mhp->interleavingTime;
|
|
173
169
|
timeStatMap["LockAnaTime"] = lsa->lockTime;
|
|
174
170
|
timeStatMap["InterlevQueryTime"] = mhp->interleavingQueriesTime;
|
|
175
171
|
timeStatMap["LockQueryTime"] = lsa->lockQueriesTime;
|
|
176
172
|
timeStatMap["MHPAnalysisTime"] = MHPTime;
|
|
177
|
-
timeStatMap["MFSPTATime"] = FSMPTATime;
|
|
178
173
|
|
|
179
174
|
SVFUtil::outs() << "\n****MHP Stmt Pairs Statistics****\n";
|
|
180
175
|
PTAStat::printStat();
|
|
181
176
|
}
|
|
182
177
|
|
|
183
|
-
// void MTAStat::performAnnotationStat(MTAAnnotator* anno)
|
|
184
|
-
// {
|
|
185
|
-
|
|
186
|
-
// PTNumStatMap.clear();
|
|
187
|
-
// timeStatMap.clear();
|
|
188
|
-
// PTNumStatMap["TotalNumOfStore"] = anno->numOfAllSt;
|
|
189
|
-
// PTNumStatMap["TotalNumOfLoad"] = anno->numOfAllLd;
|
|
190
|
-
// PTNumStatMap["NumOfNonLocalStore"] = anno->numOfNonLocalSt;
|
|
191
|
-
// PTNumStatMap["NumOfNonLocalLoad"] = anno->numOfNonLocalLd;
|
|
192
|
-
// PTNumStatMap["NumOfAliasStore"] = anno->numOfAliasSt;
|
|
193
|
-
// PTNumStatMap["NumOfAliasLoad"] = anno->numOfAliasLd;
|
|
194
|
-
// PTNumStatMap["NumOfMHPStore"] = anno->numOfMHPSt;
|
|
195
|
-
// PTNumStatMap["NumOfMHPLoad"] = anno->numOfMHPLd;
|
|
196
|
-
// PTNumStatMap["NumOfAnnotatedStore"] = anno->numOfAnnotatedSt;
|
|
197
|
-
// PTNumStatMap["NumOfAnnotatedLoad"] = anno->numOfAnnotatedLd;
|
|
198
|
-
// timeStatMap["AnnotationTime"] = AnnotationTime;
|
|
199
|
-
|
|
200
|
-
// SVFUtil::outs() << "\n****Annotation Statistics****\n";
|
|
201
|
-
// PTAStat::printStat();
|
|
202
|
-
// }
|
|
203
|
-
|
package/svf/lib/MTA/TCT.cpp
CHANGED
|
@@ -42,40 +42,39 @@ using namespace SVFUtil;
|
|
|
42
42
|
* (1) the instruction i itself
|
|
43
43
|
* (2) all the callsites invoke the function where i resides in
|
|
44
44
|
*/
|
|
45
|
-
bool TCT::isInLoopInstruction(const
|
|
45
|
+
bool TCT::isInLoopInstruction(const ICFGNode* inst)
|
|
46
46
|
{
|
|
47
47
|
assert(inst && "null value instruction!!");
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
FIFOWorkList<const
|
|
49
|
+
Set<const ICFGNode*> insts;
|
|
50
|
+
FIFOWorkList<const ICFGNode*> worklist;
|
|
51
51
|
worklist.push(inst);
|
|
52
52
|
|
|
53
53
|
while(!worklist.empty())
|
|
54
54
|
{
|
|
55
|
-
const
|
|
55
|
+
const ICFGNode* inst = worklist.pop();
|
|
56
56
|
insts.insert(inst);
|
|
57
|
-
CallGraphNode* cgnode = tcg->getCallGraphNode(inst->
|
|
57
|
+
CallGraphNode* cgnode = tcg->getCallGraphNode(inst->getFun());
|
|
58
58
|
for(CallGraphNode::const_iterator nit = cgnode->InEdgeBegin(), neit = cgnode->InEdgeEnd(); nit!=neit; nit++)
|
|
59
59
|
{
|
|
60
60
|
for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->directCallsBegin(),
|
|
61
61
|
ecit = (*nit)->directCallsEnd(); cit!=ecit; ++cit)
|
|
62
62
|
{
|
|
63
|
-
if(insts.insert(
|
|
64
|
-
worklist.push(
|
|
63
|
+
if(insts.insert(*cit).second)
|
|
64
|
+
worklist.push(*cit);
|
|
65
65
|
}
|
|
66
66
|
for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->indirectCallsBegin(),
|
|
67
67
|
ecit = (*nit)->indirectCallsEnd(); cit!=ecit; ++cit)
|
|
68
68
|
{
|
|
69
|
-
if(insts.insert(
|
|
70
|
-
worklist.push(
|
|
69
|
+
if(insts.insert(*cit).second)
|
|
70
|
+
worklist.push(*cit);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
for(
|
|
75
|
+
for(const ICFGNode* i : insts)
|
|
76
76
|
{
|
|
77
|
-
|
|
78
|
-
if(i->getFunction()->hasLoopInfo(i->getParent()))
|
|
77
|
+
if(i->getFun()->hasLoopInfo(i->getBB()))
|
|
79
78
|
return true;
|
|
80
79
|
}
|
|
81
80
|
|
|
@@ -88,9 +87,9 @@ bool TCT::isInLoopInstruction(const SVFInstruction* inst)
|
|
|
88
87
|
* (1) the function f where i resides in is in a recursion
|
|
89
88
|
* (2) any caller function starting from the function f in is in a recursion
|
|
90
89
|
*/
|
|
91
|
-
bool TCT::isInRecursion(const
|
|
90
|
+
bool TCT::isInRecursion(const ICFGNode* inst) const
|
|
92
91
|
{
|
|
93
|
-
const SVFFunction* f = inst->
|
|
92
|
+
const SVFFunction* f = inst->getFun();
|
|
94
93
|
FIFOWorkList<const SVFFunction*> worklist;
|
|
95
94
|
Set<const SVFFunction*> visits;
|
|
96
95
|
worklist.push(f);
|
|
@@ -189,7 +188,7 @@ void TCT::collectEntryFunInCallGraph()
|
|
|
189
188
|
for(SVFModule::const_iterator it = getSVFModule()->begin(), eit = getSVFModule()->end(); it!=eit; ++it)
|
|
190
189
|
{
|
|
191
190
|
const SVFFunction* fun = (*it);
|
|
192
|
-
if (isExtCall(fun))
|
|
191
|
+
if (SVFUtil::isExtCall(fun))
|
|
193
192
|
continue;
|
|
194
193
|
CallGraphNode* node = tcg->getCallGraphNode(fun);
|
|
195
194
|
if (!node->hasIncomingEdge())
|
|
@@ -247,7 +246,8 @@ void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, Ca
|
|
|
247
246
|
|
|
248
247
|
CallStrCxt cxt(ctp.getContext());
|
|
249
248
|
CallStrCxt oldCxt = cxt;
|
|
250
|
-
|
|
249
|
+
const CallICFGNode* callNode = SVFUtil::cast<CallICFGNode>(getICFGNode(cs.getInstruction()));
|
|
250
|
+
pushCxt(cxt,callNode,callee);
|
|
251
251
|
|
|
252
252
|
if(cgEdge->getEdgeKind() == CallGraphEdge::CallRetEdge)
|
|
253
253
|
{
|
|
@@ -262,7 +262,7 @@ void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, Ca
|
|
|
262
262
|
else if(cgEdge->getEdgeKind() == CallGraphEdge::TDForkEdge)
|
|
263
263
|
{
|
|
264
264
|
/// Create spawnee TCT node
|
|
265
|
-
TCTNode* spawneeNode = getOrCreateTCTNode(cxt,
|
|
265
|
+
TCTNode* spawneeNode = getOrCreateTCTNode(cxt,callNode, oldCxt, callee);
|
|
266
266
|
CxtThreadProc newctp(spawneeNode->getId(),cxt,callee);
|
|
267
267
|
|
|
268
268
|
if(pushToCTPWorkList(newctp))
|
|
@@ -286,12 +286,12 @@ void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, Ca
|
|
|
286
286
|
* Return true if a join instruction must be executed inside a loop
|
|
287
287
|
* joinbb should post dominate the successive basic block of a loop header
|
|
288
288
|
*/
|
|
289
|
-
bool TCT::isJoinMustExecutedInLoop(const LoopBBs& lp,const
|
|
289
|
+
bool TCT::isJoinMustExecutedInLoop(const LoopBBs& lp,const ICFGNode* join)
|
|
290
290
|
{
|
|
291
291
|
assert(!lp.empty() && "this is not a loop, empty basic block");
|
|
292
|
-
const SVFFunction* svffun = join->
|
|
292
|
+
const SVFFunction* svffun = join->getFun();
|
|
293
293
|
const SVFBasicBlock* loopheadbb = svffun->getLoopHeader(lp);
|
|
294
|
-
const SVFBasicBlock* joinbb = join->
|
|
294
|
+
const SVFBasicBlock* joinbb = join->getBB();
|
|
295
295
|
assert(loopheadbb->getParent()==joinbb->getParent() && "should inside same function");
|
|
296
296
|
|
|
297
297
|
for (const SVFBasicBlock* svf_scc_bb : loopheadbb->getSuccessors())
|
|
@@ -314,9 +314,9 @@ void TCT::collectLoopInfoForJoin()
|
|
|
314
314
|
{
|
|
315
315
|
for(ThreadCallGraph::CallSiteSet::const_iterator it = tcg->joinsitesBegin(), eit = tcg->joinsitesEnd(); it!=eit; ++it)
|
|
316
316
|
{
|
|
317
|
-
const
|
|
318
|
-
const SVFFunction* svffun = join->
|
|
319
|
-
const SVFBasicBlock* svfbb = join->
|
|
317
|
+
const ICFGNode* join = *it;
|
|
318
|
+
const SVFFunction* svffun = join->getFun();
|
|
319
|
+
const SVFBasicBlock* svfbb = join->getBB();
|
|
320
320
|
|
|
321
321
|
if(svffun->hasLoopInfo(svfbb))
|
|
322
322
|
{
|
|
@@ -354,7 +354,7 @@ bool TCT::isLoopExitOfJoinLoop(const SVFBasicBlock* bb)
|
|
|
354
354
|
for(InstToLoopMap::const_iterator it = joinSiteToLoopMap.begin(), eit = joinSiteToLoopMap.end(); it!=eit; ++it)
|
|
355
355
|
{
|
|
356
356
|
std::vector<const SVFBasicBlock*> exitbbs;
|
|
357
|
-
it->first->
|
|
357
|
+
it->first->getFun()->getExitBlocksOfLoop(it->first->getBB(),exitbbs);
|
|
358
358
|
while(!exitbbs.empty())
|
|
359
359
|
{
|
|
360
360
|
const SVFBasicBlock* eb = exitbbs.back();
|
|
@@ -440,11 +440,11 @@ void TCT::build()
|
|
|
440
440
|
/*!
|
|
441
441
|
* Push calling context
|
|
442
442
|
*/
|
|
443
|
-
void TCT::pushCxt(CallStrCxt& cxt, const
|
|
443
|
+
void TCT::pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
|
|
444
444
|
{
|
|
445
445
|
|
|
446
|
-
const SVFFunction* caller = call->
|
|
447
|
-
CallSiteID csId = tcg->getCallSiteID(
|
|
446
|
+
const SVFFunction* caller = call->getFun();
|
|
447
|
+
CallSiteID csId = tcg->getCallSiteID(call, callee);
|
|
448
448
|
|
|
449
449
|
/// handle calling context for candidate functions only
|
|
450
450
|
if(isCandidateFun(caller) == false)
|
|
@@ -461,11 +461,11 @@ void TCT::pushCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction
|
|
|
461
461
|
/*!
|
|
462
462
|
* Match calling context
|
|
463
463
|
*/
|
|
464
|
-
bool TCT::matchCxt(CallStrCxt& cxt, const
|
|
464
|
+
bool TCT::matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
|
|
465
465
|
{
|
|
466
466
|
|
|
467
|
-
const SVFFunction* caller = call->
|
|
468
|
-
CallSiteID csId = tcg->getCallSiteID(
|
|
467
|
+
const SVFFunction* caller = call->getFun();
|
|
468
|
+
CallSiteID csId = tcg->getCallSiteID(call, callee);
|
|
469
469
|
|
|
470
470
|
/// handle calling context for candidate functions only
|
|
471
471
|
if(isCandidateFun(caller) == false)
|
|
@@ -95,21 +95,6 @@ CallGraph* ThreadCallGraphBuilder::buildThreadCallGraph(SVFModule* svfModule)
|
|
|
95
95
|
cg->addThreadForkEdgeSetMap(cs,nullptr);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
else if (tdAPI->isHareParFor(inst))
|
|
99
|
-
{
|
|
100
|
-
const CallICFGNode* cs = icfg->getCallICFGNode(inst);
|
|
101
|
-
cg->addParForSite(cs);
|
|
102
|
-
const SVFFunction* taskFunc = SVFUtil::dyn_cast<SVFFunction>(tdAPI->getTaskFuncAtHareParForSite(inst));
|
|
103
|
-
if (taskFunc)
|
|
104
|
-
{
|
|
105
|
-
cg->addDirectParForEdge(cs);
|
|
106
|
-
}
|
|
107
|
-
// indirect call to the start routine function
|
|
108
|
-
else
|
|
109
|
-
{
|
|
110
|
-
cg->addHareParForEdgeSetMap(cs,nullptr);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
98
|
}
|
|
114
99
|
}
|
|
115
100
|
}
|
package/svf/lib/Util/Options.cpp
CHANGED
|
@@ -445,12 +445,6 @@ const Option<std::string> Options::ReadSVFG(
|
|
|
445
445
|
""
|
|
446
446
|
);
|
|
447
447
|
|
|
448
|
-
// FSMPTA.cpp
|
|
449
|
-
const Option<bool> Options::UsePCG(
|
|
450
|
-
"pcg-td-edge",
|
|
451
|
-
"Use PCG lock for non-sparsely adding SVFG edges",
|
|
452
|
-
false
|
|
453
|
-
);
|
|
454
448
|
|
|
455
449
|
const Option<bool> Options::IntraLock(
|
|
456
450
|
"intra-lock-td-edge",
|
|
@@ -458,18 +452,6 @@ const Option<bool> Options::IntraLock(
|
|
|
458
452
|
true
|
|
459
453
|
);
|
|
460
454
|
|
|
461
|
-
const Option<bool> Options::ReadPrecisionTDEdge(
|
|
462
|
-
"rp-td-edge",
|
|
463
|
-
"perform read precision to refine SVFG edges",
|
|
464
|
-
false
|
|
465
|
-
);
|
|
466
|
-
|
|
467
|
-
const Option<u32_t> Options::AddModelFlag(
|
|
468
|
-
"add-td-edge",
|
|
469
|
-
"Add thread SVFG edges with models: 0 Non Add Edge; 1 NonSparse; 2 All Optimisation; 3 No MHP; 4 No Alias; 5 No Lock; 6 No Read Precision.",
|
|
470
|
-
0
|
|
471
|
-
);
|
|
472
|
-
|
|
473
455
|
|
|
474
456
|
// LockAnalysis.cpp
|
|
475
457
|
const Option<bool> Options::PrintLockSpan(
|
|
@@ -493,42 +475,6 @@ const Option<bool> Options::DoLockAnalysis(
|
|
|
493
475
|
);
|
|
494
476
|
|
|
495
477
|
|
|
496
|
-
// MTA.cpp
|
|
497
|
-
const Option<bool> Options::AndersenAnno(
|
|
498
|
-
"tsan-ander",
|
|
499
|
-
"Add TSan annotation according to Andersen",
|
|
500
|
-
false
|
|
501
|
-
);
|
|
502
|
-
|
|
503
|
-
const Option<bool> Options::FSAnno(
|
|
504
|
-
"tsan-fs",
|
|
505
|
-
"Add TSan annotation according to flow-sensitive analysis",
|
|
506
|
-
false
|
|
507
|
-
);
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
// MTAAnnotator.cpp
|
|
511
|
-
const Option<u32_t> Options::AnnoFlag(
|
|
512
|
-
"anno",
|
|
513
|
-
"prune annotated instructions: 0001 Thread Local; 0002 Alias; 0004 MHP.",
|
|
514
|
-
0
|
|
515
|
-
);
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
// MTAResultValidator.cpp
|
|
519
|
-
const Option<bool> Options::PrintValidRes(
|
|
520
|
-
"mhp-validation",
|
|
521
|
-
"Print MHP Validation Results",
|
|
522
|
-
false
|
|
523
|
-
);
|
|
524
|
-
// LockResultValidator.cpp
|
|
525
|
-
const Option<bool> Options::LockValid(
|
|
526
|
-
"lock-validation",
|
|
527
|
-
"Print Lock Validation Results",
|
|
528
|
-
false
|
|
529
|
-
);
|
|
530
|
-
|
|
531
|
-
|
|
532
478
|
// MTAStat.cpp
|
|
533
479
|
const Option<bool> Options::AllPairMHP(
|
|
534
480
|
"all-pair-mhp",
|
|
@@ -537,14 +483,6 @@ const Option<bool> Options::AllPairMHP(
|
|
|
537
483
|
);
|
|
538
484
|
|
|
539
485
|
|
|
540
|
-
// PCG.cpp
|
|
541
|
-
//const Option<bool> TDPrint(
|
|
542
|
-
// "print-td",
|
|
543
|
-
// "Print Thread Analysis Results",
|
|
544
|
-
// true
|
|
545
|
-
//);
|
|
546
|
-
|
|
547
|
-
|
|
548
486
|
// TCT.cpp
|
|
549
487
|
const Option<bool> Options::TCTDotGraph(
|
|
550
488
|
"dump-tct",
|
|
@@ -132,17 +132,37 @@ void ThreadAPI::init()
|
|
|
132
132
|
/*!
|
|
133
133
|
*
|
|
134
134
|
*/
|
|
135
|
-
const SVFFunction* ThreadAPI::getCallee(const
|
|
135
|
+
const SVFFunction* ThreadAPI::getCallee(const ICFGNode *inst) const
|
|
136
136
|
{
|
|
137
|
-
|
|
137
|
+
if(const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst))
|
|
138
|
+
return SVFUtil::getCallee(call->getCallSite());
|
|
139
|
+
else
|
|
140
|
+
return nullptr;
|
|
138
141
|
}
|
|
139
142
|
|
|
140
143
|
/*!
|
|
141
144
|
*
|
|
142
145
|
*/
|
|
143
|
-
const SVFFunction* ThreadAPI::getCallee(const
|
|
146
|
+
const SVFFunction* ThreadAPI::getCallee(const SVFInstruction *inst) const
|
|
147
|
+
{
|
|
148
|
+
return SVFUtil::getCallee(inst);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
const CallSite ThreadAPI::getSVFCallSite(const ICFGNode *inst) const
|
|
153
|
+
{
|
|
154
|
+
assert(SVFUtil::isa<CallICFGNode>(inst) && "not a callsite?");
|
|
155
|
+
CallSite cs(SVFUtil::cast<CallICFGNode>(inst)->getCallSite());
|
|
156
|
+
return cs;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const SVFValue* ThreadAPI::getLockVal(const ICFGNode *inst) const
|
|
144
160
|
{
|
|
145
|
-
|
|
161
|
+
const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst);
|
|
162
|
+
assert(call && "not a call ICFGNode?");
|
|
163
|
+
assert((isTDAcquire(call->getCallSite()) || isTDRelease(call->getCallSite())) && "not a lock acquire or release function");
|
|
164
|
+
CallSite cs = getSVFCallSite(call->getCallSite());
|
|
165
|
+
return cs.getArgument(0);
|
|
146
166
|
}
|
|
147
167
|
|
|
148
168
|
/*!
|
|
@@ -153,7 +173,7 @@ const CallSite ThreadAPI::getSVFCallSite(const SVFInstruction *inst) const
|
|
|
153
173
|
return SVFUtil::getSVFCallSite(inst);
|
|
154
174
|
}
|
|
155
175
|
|
|
156
|
-
const SVFValue* ThreadAPI::getJoinedThread(const
|
|
176
|
+
const SVFValue* ThreadAPI::getJoinedThread(const ICFGNode *inst) const
|
|
157
177
|
{
|
|
158
178
|
assert(isTDJoin(inst) && "not a thread join function!");
|
|
159
179
|
CallSite cs = getSVFCallSite(inst);
|
|
@@ -231,7 +251,8 @@ void ThreadAPI::performAPIStat(SVFModule* module)
|
|
|
231
251
|
const SVFInstruction* svfInst = *ii;
|
|
232
252
|
if (!SVFUtil::isCallSite(svfInst))
|
|
233
253
|
continue;
|
|
234
|
-
|
|
254
|
+
|
|
255
|
+
const SVFFunction* fun = SVFUtil::getCallee(svfInst);
|
|
235
256
|
TD_TYPE type = getType(fun);
|
|
236
257
|
switch (type)
|
|
237
258
|
{
|
|
@@ -286,31 +286,5 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
|
|
|
286
286
|
/// We don't connect the callgraph here, further investigation is need to handle mod-ref during SVFG construction.
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
/// create inter-procedural SVFIR edges for hare_parallel_for calls
|
|
290
|
-
else if (isHareParForCall(svfInst))
|
|
291
|
-
{
|
|
292
|
-
if (const SVFFunction* taskFunc = SVFUtil::dyn_cast<SVFFunction>(getTaskFuncAtHareParForSite(svfInst)))
|
|
293
|
-
{
|
|
294
|
-
/// The task function of hare_parallel_for has 3 args.
|
|
295
|
-
assert((taskFunc->arg_size() == 3) && "Size of formal parameter of hare_parallel_for's task routine should be 3");
|
|
296
|
-
const SVFValue* actualParm = getTaskDataAtHareParForSite(svfInst);
|
|
297
|
-
const SVFArgument* formalParm = taskFunc->getArg(0);
|
|
298
|
-
/// Connect actual parameter to formal parameter of the start routine
|
|
299
|
-
if (actualParm->getType()->isPointerTy() && formalParm->getType()->isPointerTy())
|
|
300
|
-
{
|
|
301
|
-
CallICFGNode *icfgNode = pag->getICFG()->getCallICFGNode(svfInst);
|
|
302
|
-
FunEntryICFGNode *entry = pag->getICFG()->getFunEntryICFGNode(taskFunc);
|
|
303
|
-
addThreadForkEdge(pag->getValueNode(actualParm), pag->getValueNode(formalParm), icfgNode, entry);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
else
|
|
307
|
-
{
|
|
308
|
-
/// handle indirect calls at hare_parallel_for (e.g., hare_parallel_for(..., fp, ...);
|
|
309
|
-
/// const Value* fun = ThreadAPI::getThreadAPI()->getForkedFun(inst);
|
|
310
|
-
/// if(!SVFUtil::isa<Function>(fun))
|
|
311
|
-
/// pag->addIndirectCallsites(cs,pag->getValueNode(fun));
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
289
|
/// TODO: inter-procedural SVFIR edges for thread joins
|
|
316
290
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
add_llvm_executable(mta mta.cpp
|
|
1
|
+
add_llvm_executable(mta mta.cpp)
|
|
2
2
|
target_link_libraries(mta PUBLIC ${llvm_libs} SvfLLVM)
|
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
#include "MTA/MTA.h"
|
|
26
26
|
#include "Util/CommandLine.h"
|
|
27
27
|
#include "Util/Options.h"
|
|
28
|
-
#include "MTAResultValidator.h"
|
|
29
|
-
#include "LockResultValidator.h"
|
|
30
28
|
|
|
31
29
|
using namespace llvm;
|
|
32
30
|
using namespace std;
|
|
@@ -53,12 +51,6 @@ int main(int argc, char ** argv)
|
|
|
53
51
|
MTA mta;
|
|
54
52
|
mta.runOnModule(pag);
|
|
55
53
|
|
|
56
|
-
MTAResultValidator MTAValidator(mta.getMHP());
|
|
57
|
-
MTAValidator.analyze();
|
|
58
|
-
|
|
59
|
-
// Initialize the validator and perform validation.
|
|
60
|
-
LockResultValidator lockvalidator(mta.getLockAnalysis());
|
|
61
|
-
lockvalidator.analyze();
|
|
62
54
|
LLVMModuleSet::releaseLLVMModuleSet();
|
|
63
55
|
|
|
64
56
|
|