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
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
namespace SVF
|
|
36
36
|
{
|
|
37
37
|
|
|
38
|
+
class ICFGNode;
|
|
38
39
|
/*!
|
|
39
40
|
* Context-sensitive thread statement <c,s>
|
|
40
41
|
*/
|
|
@@ -42,7 +43,7 @@ class CxtStmt
|
|
|
42
43
|
{
|
|
43
44
|
public:
|
|
44
45
|
/// Constructor
|
|
45
|
-
CxtStmt(const CallStrCxt& c, const
|
|
46
|
+
CxtStmt(const CallStrCxt& c, const ICFGNode* f) :cxt(c), inst(f)
|
|
46
47
|
{
|
|
47
48
|
}
|
|
48
49
|
/// Copy constructor
|
|
@@ -59,7 +60,7 @@ public:
|
|
|
59
60
|
return cxt;
|
|
60
61
|
}
|
|
61
62
|
/// Return current statement
|
|
62
|
-
inline const
|
|
63
|
+
inline const ICFGNode* getStmt() const
|
|
63
64
|
{
|
|
64
65
|
return inst;
|
|
65
66
|
}
|
|
@@ -108,12 +109,12 @@ public:
|
|
|
108
109
|
/// Dump CxtStmt
|
|
109
110
|
inline void dump() const
|
|
110
111
|
{
|
|
111
|
-
SVFUtil::outs() << "[ Current Stmt: " << inst->
|
|
112
|
+
SVFUtil::outs() << "[ Current Stmt: " << inst->toString() << "\t Contexts: " << cxtToStr() << " ]\n";
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
protected:
|
|
115
116
|
CallStrCxt cxt;
|
|
116
|
-
const
|
|
117
|
+
const ICFGNode* inst;
|
|
117
118
|
};
|
|
118
119
|
|
|
119
120
|
|
|
@@ -124,7 +125,7 @@ class CxtThreadStmt : public CxtStmt
|
|
|
124
125
|
{
|
|
125
126
|
public:
|
|
126
127
|
/// Constructor
|
|
127
|
-
CxtThreadStmt(NodeID t, const CallStrCxt& c, const
|
|
128
|
+
CxtThreadStmt(NodeID t, const CallStrCxt& c, const ICFGNode* f) :CxtStmt(c,f), tid(t)
|
|
128
129
|
{
|
|
129
130
|
}
|
|
130
131
|
/// Copy constructor
|
|
@@ -174,7 +175,7 @@ public:
|
|
|
174
175
|
/// Dump CxtThreadStmt
|
|
175
176
|
inline void dump() const
|
|
176
177
|
{
|
|
177
|
-
SVFUtil::outs() << "[ Current Thread id: " << tid << " Stmt: " << inst->
|
|
178
|
+
SVFUtil::outs() << "[ Current Thread id: " << tid << " Stmt: " << inst->toString() << "\t Contexts: " << cxtToStr() << " ]\n";
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
private:
|
|
@@ -189,7 +190,7 @@ class CxtThread
|
|
|
189
190
|
{
|
|
190
191
|
public:
|
|
191
192
|
/// Constructor
|
|
192
|
-
CxtThread(const CallStrCxt& c, const
|
|
193
|
+
CxtThread(const CallStrCxt& c, const ICFGNode* fork) : cxt(c), forksite(fork), inloop(false), incycle(false)
|
|
193
194
|
{
|
|
194
195
|
}
|
|
195
196
|
/// Copy constructor
|
|
@@ -207,7 +208,7 @@ public:
|
|
|
207
208
|
return cxt;
|
|
208
209
|
}
|
|
209
210
|
/// Return forksite
|
|
210
|
-
inline const
|
|
211
|
+
inline const ICFGNode* getThread() const
|
|
211
212
|
{
|
|
212
213
|
return forksite;
|
|
213
214
|
}
|
|
@@ -282,7 +283,7 @@ public:
|
|
|
282
283
|
|
|
283
284
|
if(forksite)
|
|
284
285
|
{
|
|
285
|
-
SVFUtil::outs() << "[ Thread:
|
|
286
|
+
SVFUtil::outs() << "[ Thread: "
|
|
286
287
|
<< forksite->toString() << "\t Contexts: " << cxtToStr()
|
|
287
288
|
<< loop << cycle <<" ]\n";
|
|
288
289
|
}
|
|
@@ -294,7 +295,7 @@ public:
|
|
|
294
295
|
}
|
|
295
296
|
protected:
|
|
296
297
|
CallStrCxt cxt;
|
|
297
|
-
const
|
|
298
|
+
const ICFGNode* forksite;
|
|
298
299
|
bool inloop;
|
|
299
300
|
bool incycle;
|
|
300
301
|
};
|
|
@@ -484,8 +485,8 @@ template <> struct std::hash<SVF::CxtStmt>
|
|
|
484
485
|
{
|
|
485
486
|
size_t operator()(const SVF::CxtStmt& cs) const
|
|
486
487
|
{
|
|
487
|
-
std::hash<SVF::
|
|
488
|
-
SVF::
|
|
488
|
+
std::hash<SVF::ICFGNode*> h;
|
|
489
|
+
SVF::ICFGNode* inst = const_cast<SVF::ICFGNode*> (cs.getStmt());
|
|
489
490
|
return h(inst);
|
|
490
491
|
}
|
|
491
492
|
};
|
|
@@ -151,36 +151,17 @@ public:
|
|
|
151
151
|
static const Option<std::string> WriteSVFG;
|
|
152
152
|
static const Option<std::string> ReadSVFG;
|
|
153
153
|
|
|
154
|
-
// FSMPTA.cpp
|
|
155
|
-
static const Option<bool> UsePCG;
|
|
156
|
-
static const Option<bool> IntraLock;
|
|
157
|
-
static const Option<bool> ReadPrecisionTDEdge;
|
|
158
|
-
static const Option<u32_t> AddModelFlag;
|
|
159
|
-
|
|
160
154
|
// LockAnalysis.cpp
|
|
155
|
+
static const Option<bool> IntraLock;
|
|
161
156
|
static const Option<bool> PrintLockSpan;
|
|
162
157
|
|
|
163
158
|
// MHP.cpp
|
|
164
159
|
static const Option<bool> PrintInterLev;
|
|
165
160
|
static const Option<bool> DoLockAnalysis;
|
|
166
161
|
|
|
167
|
-
// MTA.cpp
|
|
168
|
-
static const Option<bool> AndersenAnno;
|
|
169
|
-
static const Option<bool> FSAnno;
|
|
170
|
-
|
|
171
|
-
// MTAAnnotator.cpp
|
|
172
|
-
static const Option<u32_t> AnnoFlag;
|
|
173
|
-
|
|
174
|
-
// MTAResultValidator.cpp
|
|
175
|
-
static const Option<bool> PrintValidRes;
|
|
176
|
-
|
|
177
|
-
static const Option<bool> LockValid;
|
|
178
162
|
//MTAStat.cpp
|
|
179
163
|
static const Option<bool> AllPairMHP;
|
|
180
164
|
|
|
181
|
-
// PCG.cpp
|
|
182
|
-
//const Option<bool> TDPrint
|
|
183
|
-
|
|
184
165
|
// TCT.cpp
|
|
185
166
|
static const Option<bool> TCTDotGraph;
|
|
186
167
|
|
|
@@ -404,7 +404,7 @@ inline bool isArgOfUncalledFunction(const SVFValue* svfval)
|
|
|
404
404
|
//@{
|
|
405
405
|
inline const SVFValue* getForkedFun(const CallSite cs)
|
|
406
406
|
{
|
|
407
|
-
return ThreadAPI::getThreadAPI()->getForkedFun(cs);
|
|
407
|
+
return ThreadAPI::getThreadAPI()->getForkedFun(cs.getInstruction());
|
|
408
408
|
}
|
|
409
409
|
inline const SVFValue* getForkedFun(const SVFInstruction *inst)
|
|
410
410
|
{
|
|
@@ -490,7 +490,7 @@ inline bool isReallocExtCall(const SVFInstruction *inst)
|
|
|
490
490
|
///@{
|
|
491
491
|
inline bool isThreadForkCall(const CallSite cs)
|
|
492
492
|
{
|
|
493
|
-
return ThreadAPI::getThreadAPI()->isTDFork(cs);
|
|
493
|
+
return ThreadAPI::getThreadAPI()->isTDFork(cs.getInstruction());
|
|
494
494
|
}
|
|
495
495
|
inline bool isThreadForkCall(const SVFInstruction *inst)
|
|
496
496
|
{
|
|
@@ -498,23 +498,11 @@ inline bool isThreadForkCall(const SVFInstruction *inst)
|
|
|
498
498
|
}
|
|
499
499
|
//@}
|
|
500
500
|
|
|
501
|
-
/// Return true if this is a hare_parallel_for call
|
|
502
|
-
///@{
|
|
503
|
-
inline bool isHareParForCall(const CallSite cs)
|
|
504
|
-
{
|
|
505
|
-
return ThreadAPI::getThreadAPI()->isHareParFor(cs);
|
|
506
|
-
}
|
|
507
|
-
inline bool isHareParForCall(const SVFInstruction *inst)
|
|
508
|
-
{
|
|
509
|
-
return ThreadAPI::getThreadAPI()->isHareParFor(inst);
|
|
510
|
-
}
|
|
511
|
-
//@}
|
|
512
|
-
|
|
513
501
|
/// Return true if this is a thread join call
|
|
514
502
|
///@{
|
|
515
503
|
inline bool isThreadJoinCall(const CallSite cs)
|
|
516
504
|
{
|
|
517
|
-
return ThreadAPI::getThreadAPI()->isTDJoin(cs);
|
|
505
|
+
return ThreadAPI::getThreadAPI()->isTDJoin(cs.getInstruction());
|
|
518
506
|
}
|
|
519
507
|
inline bool isThreadJoinCall(const SVFInstruction *inst)
|
|
520
508
|
{
|
|
@@ -526,7 +514,7 @@ inline bool isThreadJoinCall(const SVFInstruction *inst)
|
|
|
526
514
|
///@{
|
|
527
515
|
inline bool isThreadExitCall(const CallSite cs)
|
|
528
516
|
{
|
|
529
|
-
return ThreadAPI::getThreadAPI()->isTDExit(cs);
|
|
517
|
+
return ThreadAPI::getThreadAPI()->isTDExit(cs.getInstruction());
|
|
530
518
|
}
|
|
531
519
|
inline bool isThreadExitCall(const SVFInstruction *inst)
|
|
532
520
|
{
|
|
@@ -538,7 +526,7 @@ inline bool isThreadExitCall(const SVFInstruction *inst)
|
|
|
538
526
|
///@{
|
|
539
527
|
inline bool isLockAquireCall(const CallSite cs)
|
|
540
528
|
{
|
|
541
|
-
return ThreadAPI::getThreadAPI()->isTDAcquire(cs);
|
|
529
|
+
return ThreadAPI::getThreadAPI()->isTDAcquire(cs.getInstruction());
|
|
542
530
|
}
|
|
543
531
|
inline bool isLockAquireCall(const SVFInstruction *inst)
|
|
544
532
|
{
|
|
@@ -550,7 +538,7 @@ inline bool isLockAquireCall(const SVFInstruction *inst)
|
|
|
550
538
|
///@{
|
|
551
539
|
inline bool isLockReleaseCall(const CallSite cs)
|
|
552
540
|
{
|
|
553
|
-
return ThreadAPI::getThreadAPI()->isTDRelease(cs);
|
|
541
|
+
return ThreadAPI::getThreadAPI()->isTDRelease(cs.getInstruction());
|
|
554
542
|
}
|
|
555
543
|
inline bool isLockReleaseCall(const SVFInstruction *inst)
|
|
556
544
|
{
|
|
@@ -562,7 +550,7 @@ inline bool isLockReleaseCall(const SVFInstruction *inst)
|
|
|
562
550
|
//@{
|
|
563
551
|
inline bool isBarrierWaitCall(const CallSite cs)
|
|
564
552
|
{
|
|
565
|
-
return ThreadAPI::getThreadAPI()->isTDBarWait(cs);
|
|
553
|
+
return ThreadAPI::getThreadAPI()->isTDBarWait(cs.getInstruction());
|
|
566
554
|
}
|
|
567
555
|
inline bool isBarrierWaitCall(const SVFInstruction *inst)
|
|
568
556
|
{
|
|
@@ -574,7 +562,7 @@ inline bool isBarrierWaitCall(const SVFInstruction *inst)
|
|
|
574
562
|
//@{
|
|
575
563
|
inline const SVFValue* getActualParmAtForkSite(const CallSite cs)
|
|
576
564
|
{
|
|
577
|
-
return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(cs);
|
|
565
|
+
return ThreadAPI::getThreadAPI()->getActualParmAtForkSite(cs.getInstruction());
|
|
578
566
|
}
|
|
579
567
|
inline const SVFValue* getActualParmAtForkSite(const SVFInstruction *inst)
|
|
580
568
|
{
|
|
@@ -582,29 +570,6 @@ inline const SVFValue* getActualParmAtForkSite(const SVFInstruction *inst)
|
|
|
582
570
|
}
|
|
583
571
|
//@}
|
|
584
572
|
|
|
585
|
-
/// Return the task function of the parallel_for routine
|
|
586
|
-
//@{
|
|
587
|
-
inline const SVFValue* getTaskFuncAtHareParForSite(const CallSite cs)
|
|
588
|
-
{
|
|
589
|
-
return ThreadAPI::getThreadAPI()->getTaskFuncAtHareParForSite(cs);
|
|
590
|
-
}
|
|
591
|
-
inline const SVFValue* getTaskFuncAtHareParForSite(const SVFInstruction *inst)
|
|
592
|
-
{
|
|
593
|
-
return ThreadAPI::getThreadAPI()->getTaskFuncAtHareParForSite(inst);
|
|
594
|
-
}
|
|
595
|
-
//@}
|
|
596
|
-
|
|
597
|
-
/// Return the task data argument of the parallel_for routine
|
|
598
|
-
//@{
|
|
599
|
-
inline const SVFValue* getTaskDataAtHareParForSite(const CallSite cs)
|
|
600
|
-
{
|
|
601
|
-
return ThreadAPI::getThreadAPI()->getTaskDataAtHareParForSite(cs);
|
|
602
|
-
}
|
|
603
|
-
inline const SVFValue* getTaskDataAtHareParForSite(const SVFInstruction *inst)
|
|
604
|
-
{
|
|
605
|
-
return ThreadAPI::getThreadAPI()->getTaskDataAtHareParForSite(inst);
|
|
606
|
-
}
|
|
607
|
-
//@}
|
|
608
573
|
|
|
609
574
|
inline bool isProgExitCall(const CallSite cs)
|
|
610
575
|
{
|
|
@@ -36,6 +36,7 @@ namespace SVF
|
|
|
36
36
|
{
|
|
37
37
|
|
|
38
38
|
class SVFModule;
|
|
39
|
+
class ICFGNode;
|
|
39
40
|
|
|
40
41
|
/*
|
|
41
42
|
* ThreadAPI class contains interfaces for pthread programs
|
|
@@ -119,32 +120,21 @@ public:
|
|
|
119
120
|
|
|
120
121
|
/// Return the callee/callsite/func
|
|
121
122
|
//@{
|
|
123
|
+
const SVFFunction* getCallee(const ICFGNode *inst) const;
|
|
122
124
|
const SVFFunction* getCallee(const SVFInstruction *inst) const;
|
|
123
|
-
const SVFFunction* getCallee(const CallSite cs) const;
|
|
124
125
|
const CallSite getSVFCallSite(const SVFInstruction *inst) const;
|
|
126
|
+
const CallSite getSVFCallSite(const ICFGNode *inst) const;
|
|
125
127
|
//@}
|
|
126
128
|
|
|
127
129
|
/// Return true if this call create a new thread
|
|
128
130
|
//@{
|
|
129
|
-
inline bool isTDFork(const
|
|
131
|
+
inline bool isTDFork(const ICFGNode *inst) const
|
|
130
132
|
{
|
|
131
133
|
return getType(getCallee(inst)) == TD_FORK;
|
|
132
134
|
}
|
|
133
|
-
inline bool isTDFork(
|
|
135
|
+
inline bool isTDFork(const SVFInstruction* cs) const
|
|
134
136
|
{
|
|
135
|
-
return
|
|
136
|
-
}
|
|
137
|
-
//@}
|
|
138
|
-
|
|
139
|
-
/// Return true if this call proceeds a hare_parallel_for
|
|
140
|
-
//@{
|
|
141
|
-
inline bool isHareParFor(const SVFInstruction *inst) const
|
|
142
|
-
{
|
|
143
|
-
return getType(getCallee(inst)) == HARE_PAR_FOR;
|
|
144
|
-
}
|
|
145
|
-
inline bool isHareParFor(CallSite cs) const
|
|
146
|
-
{
|
|
147
|
-
return isTDFork(cs.getInstruction());
|
|
137
|
+
return getType(getCallee(cs)) == TD_FORK;
|
|
148
138
|
}
|
|
149
139
|
//@}
|
|
150
140
|
|
|
@@ -152,81 +142,59 @@ public:
|
|
|
152
142
|
//@{
|
|
153
143
|
/// Return the first argument of the call,
|
|
154
144
|
/// Note that, it is the pthread_t pointer
|
|
155
|
-
inline const SVFValue* getForkedThread(const
|
|
145
|
+
inline const SVFValue* getForkedThread(const ICFGNode *inst) const
|
|
156
146
|
{
|
|
157
147
|
assert(isTDFork(inst) && "not a thread fork function!");
|
|
158
148
|
CallSite cs = getSVFCallSite(inst);
|
|
159
149
|
return cs.getArgument(0);
|
|
160
150
|
}
|
|
161
|
-
inline const SVFValue* getForkedThread(
|
|
151
|
+
inline const SVFValue* getForkedThread(const SVFInstruction* inst) const
|
|
162
152
|
{
|
|
163
|
-
|
|
153
|
+
assert(isTDFork(inst) && "not a thread fork function!");
|
|
154
|
+
CallSite cs = getSVFCallSite(inst);
|
|
155
|
+
return cs.getArgument(0);
|
|
164
156
|
}
|
|
165
157
|
|
|
166
158
|
/// Return the third argument of the call,
|
|
167
159
|
/// Note that, it could be function type or a void* pointer
|
|
168
|
-
inline const SVFValue* getForkedFun(const
|
|
160
|
+
inline const SVFValue* getForkedFun(const ICFGNode *inst) const
|
|
169
161
|
{
|
|
170
162
|
assert(isTDFork(inst) && "not a thread fork function!");
|
|
171
163
|
CallSite cs = getSVFCallSite(inst);
|
|
172
164
|
return cs.getArgument(2);
|
|
173
165
|
}
|
|
174
|
-
inline const SVFValue* getForkedFun(
|
|
166
|
+
inline const SVFValue* getForkedFun(const SVFInstruction* inst) const
|
|
175
167
|
{
|
|
176
|
-
|
|
168
|
+
assert(isTDFork(inst) && "not a thread fork function!");
|
|
169
|
+
CallSite cs = getSVFCallSite(inst);
|
|
170
|
+
return cs.getArgument(2);
|
|
177
171
|
}
|
|
178
172
|
|
|
179
173
|
/// Return the forth argument of the call,
|
|
180
174
|
/// Note that, it is the sole argument of start routine ( a void* pointer )
|
|
181
|
-
inline const SVFValue* getActualParmAtForkSite(const
|
|
175
|
+
inline const SVFValue* getActualParmAtForkSite(const ICFGNode *inst) const
|
|
182
176
|
{
|
|
183
177
|
assert(isTDFork(inst) && "not a thread fork function!");
|
|
184
178
|
CallSite cs = getSVFCallSite(inst);
|
|
185
179
|
return cs.getArgument(3);
|
|
186
180
|
}
|
|
187
|
-
inline const SVFValue* getActualParmAtForkSite(
|
|
188
|
-
{
|
|
189
|
-
return getActualParmAtForkSite(cs.getInstruction());
|
|
190
|
-
}
|
|
191
|
-
//@}
|
|
192
|
-
|
|
193
|
-
/// Get the task function (i.e., the 5th parameter) of the hare_parallel_for call
|
|
194
|
-
//@{
|
|
195
|
-
inline const SVFValue* getTaskFuncAtHareParForSite(const SVFInstruction *inst) const
|
|
196
|
-
{
|
|
197
|
-
assert(isHareParFor(inst) && "not a hare_parallel_for function!");
|
|
198
|
-
CallSite cs = getSVFCallSite(inst);
|
|
199
|
-
return cs.getArgument(4);
|
|
200
|
-
}
|
|
201
|
-
inline const SVFValue* getTaskFuncAtHareParForSite(CallSite cs) const
|
|
202
|
-
{
|
|
203
|
-
return getTaskFuncAtHareParForSite(cs.getInstruction());
|
|
204
|
-
}
|
|
205
|
-
//@}
|
|
206
|
-
|
|
207
|
-
/// Get the task data (i.e., the 6th parameter) of the hare_parallel_for call
|
|
208
|
-
//@{
|
|
209
|
-
inline const SVFValue* getTaskDataAtHareParForSite(const SVFInstruction *inst) const
|
|
181
|
+
inline const SVFValue* getActualParmAtForkSite(const SVFInstruction* inst) const
|
|
210
182
|
{
|
|
211
|
-
assert(
|
|
183
|
+
assert(isTDFork(inst) && "not a thread fork function!");
|
|
212
184
|
CallSite cs = getSVFCallSite(inst);
|
|
213
|
-
return cs.getArgument(
|
|
214
|
-
}
|
|
215
|
-
inline const SVFValue* getTaskDataAtHareParForSite(CallSite cs) const
|
|
216
|
-
{
|
|
217
|
-
return getTaskDataAtHareParForSite(cs.getInstruction());
|
|
185
|
+
return cs.getArgument(3);
|
|
218
186
|
}
|
|
219
187
|
//@}
|
|
220
188
|
|
|
221
189
|
/// Return true if this call wait for a worker thread
|
|
222
190
|
//@{
|
|
223
|
-
inline bool isTDJoin(const
|
|
191
|
+
inline bool isTDJoin(const ICFGNode *inst) const
|
|
224
192
|
{
|
|
225
193
|
return getType(getCallee(inst)) == TD_JOIN;
|
|
226
194
|
}
|
|
227
|
-
inline bool isTDJoin(
|
|
195
|
+
inline bool isTDJoin(const SVFInstruction* inst) const
|
|
228
196
|
{
|
|
229
|
-
return
|
|
197
|
+
return getType(getCallee(inst)) == TD_JOIN;
|
|
230
198
|
}
|
|
231
199
|
//@}
|
|
232
200
|
|
|
@@ -234,90 +202,79 @@ public:
|
|
|
234
202
|
//@{
|
|
235
203
|
/// Return the first argument of the call,
|
|
236
204
|
/// Note that, it is the pthread_t pointer
|
|
237
|
-
const SVFValue* getJoinedThread(const
|
|
238
|
-
inline const SVFValue* getJoinedThread(CallSite cs) const
|
|
239
|
-
{
|
|
240
|
-
return getJoinedThread(cs.getInstruction());
|
|
241
|
-
}
|
|
205
|
+
const SVFValue* getJoinedThread(const ICFGNode *inst) const;
|
|
242
206
|
/// Return the send argument of the call,
|
|
243
207
|
/// Note that, it is the pthread_t pointer
|
|
244
|
-
inline const SVFValue* getRetParmAtJoinedSite(const
|
|
208
|
+
inline const SVFValue* getRetParmAtJoinedSite(const ICFGNode *inst) const
|
|
245
209
|
{
|
|
246
210
|
assert(isTDJoin(inst) && "not a thread join function!");
|
|
247
211
|
CallSite cs = getSVFCallSite(inst);
|
|
248
212
|
return cs.getArgument(1);
|
|
249
213
|
}
|
|
250
|
-
inline const SVFValue* getRetParmAtJoinedSite(
|
|
214
|
+
inline const SVFValue* getRetParmAtJoinedSite(const SVFInstruction* inst) const
|
|
251
215
|
{
|
|
252
|
-
|
|
216
|
+
assert(isTDJoin(inst) && "not a thread join function!");
|
|
217
|
+
CallSite cs = getSVFCallSite(inst);
|
|
218
|
+
return cs.getArgument(1);
|
|
253
219
|
}
|
|
254
220
|
//@}
|
|
255
221
|
|
|
256
222
|
|
|
257
223
|
/// Return true if this call exits/terminate a thread
|
|
258
224
|
//@{
|
|
259
|
-
inline bool isTDExit(const
|
|
225
|
+
inline bool isTDExit(const ICFGNode *inst) const
|
|
260
226
|
{
|
|
261
227
|
return getType(getCallee(inst)) == TD_EXIT;
|
|
262
228
|
}
|
|
263
229
|
|
|
264
|
-
inline bool isTDExit(
|
|
230
|
+
inline bool isTDExit(const SVFInstruction* inst) const
|
|
265
231
|
{
|
|
266
|
-
return getType(getCallee(
|
|
232
|
+
return getType(getCallee(inst)) == TD_EXIT;
|
|
267
233
|
}
|
|
268
234
|
//@}
|
|
269
235
|
|
|
270
236
|
/// Return true if this call acquire a lock
|
|
271
237
|
//@{
|
|
272
|
-
inline bool isTDAcquire(const
|
|
238
|
+
inline bool isTDAcquire(const ICFGNode* inst) const
|
|
273
239
|
{
|
|
274
240
|
return getType(getCallee(inst)) == TD_ACQUIRE;
|
|
275
241
|
}
|
|
276
242
|
|
|
277
|
-
inline bool isTDAcquire(
|
|
243
|
+
inline bool isTDAcquire(const SVFInstruction* inst) const
|
|
278
244
|
{
|
|
279
|
-
return getType(getCallee(
|
|
245
|
+
return getType(getCallee(inst)) == TD_ACQUIRE;
|
|
280
246
|
}
|
|
281
247
|
//@}
|
|
282
248
|
|
|
283
249
|
/// Return true if this call release a lock
|
|
284
250
|
//@{
|
|
285
|
-
inline bool isTDRelease(const
|
|
251
|
+
inline bool isTDRelease(const ICFGNode *inst) const
|
|
286
252
|
{
|
|
287
253
|
return getType(getCallee(inst)) == TD_RELEASE;
|
|
288
254
|
}
|
|
289
255
|
|
|
290
|
-
inline bool isTDRelease(
|
|
256
|
+
inline bool isTDRelease(const SVFInstruction* inst) const
|
|
291
257
|
{
|
|
292
|
-
return getType(getCallee(
|
|
258
|
+
return getType(getCallee(inst)) == TD_RELEASE;
|
|
293
259
|
}
|
|
294
260
|
//@}
|
|
295
261
|
|
|
296
262
|
/// Return lock value
|
|
297
263
|
//@{
|
|
298
264
|
/// First argument of pthread_mutex_lock/pthread_mutex_unlock
|
|
299
|
-
|
|
300
|
-
{
|
|
301
|
-
assert((isTDAcquire(inst) || isTDRelease(inst)) && "not a lock acquire or release function");
|
|
302
|
-
CallSite cs = getSVFCallSite(inst);
|
|
303
|
-
return cs.getArgument(0);
|
|
304
|
-
}
|
|
305
|
-
inline const SVFValue* getLockVal(CallSite cs) const
|
|
306
|
-
{
|
|
307
|
-
return getLockVal(cs.getInstruction());
|
|
308
|
-
}
|
|
265
|
+
const SVFValue* getLockVal(const ICFGNode *inst) const;
|
|
309
266
|
//@}
|
|
310
267
|
|
|
311
268
|
/// Return true if this call waits for a barrier
|
|
312
269
|
//@{
|
|
313
|
-
inline bool isTDBarWait(const
|
|
270
|
+
inline bool isTDBarWait(const ICFGNode *inst) const
|
|
314
271
|
{
|
|
315
272
|
return getType(getCallee(inst)) == TD_BAR_WAIT;
|
|
316
273
|
}
|
|
317
274
|
|
|
318
|
-
inline bool isTDBarWait(
|
|
275
|
+
inline bool isTDBarWait(const SVFInstruction* inst) const
|
|
319
276
|
{
|
|
320
|
-
return getType(getCallee(
|
|
277
|
+
return getType(getCallee(inst)) == TD_BAR_WAIT;
|
|
321
278
|
}
|
|
322
279
|
//@}
|
|
323
280
|
|
|
@@ -89,29 +89,6 @@ void ThreadCallGraph::updateCallGraph(PointerAnalysis* pta)
|
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
// parallel_for sites
|
|
94
|
-
for (CallSiteSet::const_iterator it = parForSitesBegin(), eit = parForSitesEnd(); it != eit; ++it)
|
|
95
|
-
{
|
|
96
|
-
const SVFValue* forkedval = tdAPI->getTaskFuncAtHareParForSite((*it)->getCallSite());
|
|
97
|
-
if(SVFUtil::dyn_cast<SVFFunction>(forkedval)==nullptr)
|
|
98
|
-
{
|
|
99
|
-
SVFIR* pag = pta->getPAG();
|
|
100
|
-
const NodeBS targets = pta->getPts(pag->getValueNode(forkedval)).toNodeBS();
|
|
101
|
-
for (NodeBS::iterator ii = targets.begin(), ie = targets.end(); ii != ie; ii++)
|
|
102
|
-
{
|
|
103
|
-
if(ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(pag->getGNode(*ii)))
|
|
104
|
-
{
|
|
105
|
-
const MemObj* obj = pag->getObject(objPN);
|
|
106
|
-
if(obj->isFunction())
|
|
107
|
-
{
|
|
108
|
-
const SVFFunction* svfCallee = SVFUtil::cast<SVFFunction>(obj->getValue());
|
|
109
|
-
this->addIndirectForkEdge(*it, svfCallee);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
92
|
}
|
|
116
93
|
|
|
117
94
|
|
|
@@ -123,7 +100,7 @@ void ThreadCallGraph::updateJoinEdge(PointerAnalysis* pta)
|
|
|
123
100
|
|
|
124
101
|
for (CallSiteSet::const_iterator it = joinsitesBegin(), eit = joinsitesEnd(); it != eit; ++it)
|
|
125
102
|
{
|
|
126
|
-
const SVFValue* jointhread = tdAPI->getJoinedThread(
|
|
103
|
+
const SVFValue* jointhread = tdAPI->getJoinedThread(*it);
|
|
127
104
|
// find its corresponding fork sites first
|
|
128
105
|
CallSiteSet forkset;
|
|
129
106
|
for (CallSiteSet::const_iterator it = forksitesBegin(), eit = forksitesEnd(); it != eit; ++it)
|
|
@@ -214,52 +191,3 @@ void ThreadCallGraph::addDirectJoinEdge(const CallICFGNode* cs,const CallSiteSet
|
|
|
214
191
|
}
|
|
215
192
|
}
|
|
216
193
|
}
|
|
217
|
-
|
|
218
|
-
/*!
|
|
219
|
-
* Add a direct ParFor edges
|
|
220
|
-
*/
|
|
221
|
-
void ThreadCallGraph::addDirectParForEdge(const CallICFGNode* cs)
|
|
222
|
-
{
|
|
223
|
-
|
|
224
|
-
CallGraphNode* caller = getCallGraphNode(cs->getCaller());
|
|
225
|
-
const SVFFunction* taskFunc = SVFUtil::dyn_cast<SVFFunction>(tdAPI->getTaskFuncAtHareParForSite(cs->getCallSite()));
|
|
226
|
-
assert(taskFunc && "callee does not exist");
|
|
227
|
-
|
|
228
|
-
CallGraphNode* callee = getCallGraphNode(taskFunc);
|
|
229
|
-
|
|
230
|
-
CallSiteID csId = addCallSite(cs, callee->getFunction());
|
|
231
|
-
|
|
232
|
-
if (!hasGraphEdge(caller, callee, CallGraphEdge::TDForkEdge, csId))
|
|
233
|
-
{
|
|
234
|
-
assert(cs->getCaller() == caller->getFunction() && "callee instruction not inside caller??");
|
|
235
|
-
|
|
236
|
-
HareParForEdge* edge = new HareParForEdge(caller, callee, csId);
|
|
237
|
-
edge->addDirectCallSite(cs);
|
|
238
|
-
|
|
239
|
-
addEdge(edge);
|
|
240
|
-
addHareParForEdgeSetMap(cs, edge);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/*!
|
|
245
|
-
* Add an indirect ParFor edge to update call graph
|
|
246
|
-
*/
|
|
247
|
-
void ThreadCallGraph::addIndirectParForEdge(const CallICFGNode* cs, const SVFFunction* calleefun)
|
|
248
|
-
{
|
|
249
|
-
|
|
250
|
-
CallGraphNode* caller = getCallGraphNode(cs->getCaller());
|
|
251
|
-
CallGraphNode* callee = getCallGraphNode(calleefun);
|
|
252
|
-
|
|
253
|
-
CallSiteID csId = addCallSite(cs, callee->getFunction());
|
|
254
|
-
|
|
255
|
-
if (!hasGraphEdge(caller, callee, CallGraphEdge::HareParForEdge,csId))
|
|
256
|
-
{
|
|
257
|
-
assert(cs->getCaller() == caller->getFunction() && "callee instruction not inside caller??");
|
|
258
|
-
|
|
259
|
-
HareParForEdge* edge = new HareParForEdge(caller, callee, csId);
|
|
260
|
-
edge->addInDirectCallSite(cs);
|
|
261
|
-
|
|
262
|
-
addEdge(edge);
|
|
263
|
-
addHareParForEdgeSetMap(cs, edge);
|
|
264
|
-
}
|
|
265
|
-
}
|