svf-lib 1.0.1277 → 1.0.1279
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/SVF-linux/Release-build/lib/libSvf.a +0 -0
- package/SVF-linux/include/DDA/DDAVFSolver.h +1 -2
- package/SVF-linux/include/Graphs/ICFG.h +16 -16
- package/SVF-linux/include/Graphs/ICFGEdge.h +6 -6
- package/SVF-linux/include/Graphs/ICFGNode.h +16 -16
- package/SVF-linux/include/Graphs/IRGraph.h +6 -6
- package/SVF-linux/include/Graphs/ThreadCallGraph.h +2 -2
- package/SVF-linux/include/Graphs/VFGNode.h +1 -1
- package/SVF-linux/include/MSSA/MSSAMuChi.h +11 -11
- package/SVF-linux/include/MSSA/MemRegion.h +2 -2
- package/SVF-linux/include/MSSA/MemSSA.h +13 -13
- package/SVF-linux/include/MTA/FSMPTA.h +1 -1
- package/SVF-linux/include/MTA/LockAnalysis.h +33 -33
- package/SVF-linux/include/MTA/LockResultValidator.h +7 -6
- package/SVF-linux/include/MTA/MHP.h +46 -46
- package/SVF-linux/include/MTA/MTA.h +4 -4
- package/SVF-linux/include/MTA/MTAAnnotator.h +6 -4
- package/SVF-linux/include/MTA/MTAResultValidator.h +51 -44
- package/SVF-linux/include/MTA/PCG.h +22 -27
- package/SVF-linux/include/MTA/TCT.h +28 -37
- package/SVF-linux/include/MemoryModel/SVFStatements.h +11 -6
- package/SVF-linux/include/MemoryModel/SVFVariables.h +4 -4
- package/SVF-linux/include/MemoryModel/SymbolTableInfo.h +13 -19
- package/SVF-linux/include/SABER/ProgSlice.h +5 -5
- package/SVF-linux/include/SABER/SaberCheckerAPI.h +4 -4
- package/SVF-linux/include/SABER/SaberCondAllocator.h +32 -35
- package/SVF-linux/include/SVF-FE/BasicTypes.h +10 -0
- package/SVF-linux/include/SVF-FE/CPPUtil.h +9 -8
- package/SVF-linux/include/SVF-FE/DCHG.h +4 -4
- package/SVF-linux/include/SVF-FE/DataFlowUtil.h +1 -1
- package/SVF-linux/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
- package/SVF-linux/include/SVF-FE/ICFGBuilder.h +9 -9
- package/SVF-linux/include/SVF-FE/IRAnnotator.h +9 -9
- package/SVF-linux/include/SVF-FE/LLVMModule.h +119 -22
- package/SVF-linux/include/SVF-FE/LLVMUtil.h +31 -52
- package/SVF-linux/include/SVF-FE/SVFIRBuilder.h +14 -20
- package/SVF-linux/include/SVF-FE/SymbolTableBuilder.h +8 -8
- package/SVF-linux/include/Util/Annotator.h +22 -22
- package/SVF-linux/include/Util/BasicTypes.h +476 -72
- package/SVF-linux/include/Util/Casting.h +1 -1
- package/SVF-linux/include/Util/CxtStmt.h +13 -12
- package/SVF-linux/include/Util/SVFBasicTypes.h +0 -78
- package/SVF-linux/include/Util/SVFInstruction.h +40 -0
- package/SVF-linux/include/Util/SVFModule.h +58 -124
- package/SVF-linux/include/Util/SVFUtil.h +48 -39
- package/SVF-linux/include/Util/ThreadAPI.h +17 -28
- package/SVF-linux/include/WPA/WPAPass.h +4 -4
- package/SVF-osx/Release-build/lib/libSvf.a +0 -0
- package/SVF-osx/include/DDA/DDAVFSolver.h +1 -2
- package/SVF-osx/include/Graphs/ICFG.h +16 -16
- package/SVF-osx/include/Graphs/ICFGEdge.h +6 -6
- package/SVF-osx/include/Graphs/ICFGNode.h +16 -16
- package/SVF-osx/include/Graphs/IRGraph.h +6 -6
- package/SVF-osx/include/Graphs/ThreadCallGraph.h +2 -2
- package/SVF-osx/include/Graphs/VFGNode.h +1 -1
- package/SVF-osx/include/MSSA/MSSAMuChi.h +11 -11
- package/SVF-osx/include/MSSA/MemRegion.h +2 -2
- package/SVF-osx/include/MSSA/MemSSA.h +13 -13
- package/SVF-osx/include/MTA/FSMPTA.h +1 -1
- package/SVF-osx/include/MTA/LockAnalysis.h +33 -33
- package/SVF-osx/include/MTA/LockResultValidator.h +7 -6
- package/SVF-osx/include/MTA/MHP.h +46 -46
- package/SVF-osx/include/MTA/MTA.h +4 -4
- package/SVF-osx/include/MTA/MTAAnnotator.h +6 -4
- package/SVF-osx/include/MTA/MTAResultValidator.h +51 -44
- package/SVF-osx/include/MTA/PCG.h +22 -27
- package/SVF-osx/include/MTA/TCT.h +28 -37
- package/SVF-osx/include/MemoryModel/SVFStatements.h +11 -6
- package/SVF-osx/include/MemoryModel/SVFVariables.h +4 -4
- package/SVF-osx/include/MemoryModel/SymbolTableInfo.h +13 -19
- package/SVF-osx/include/SABER/ProgSlice.h +5 -5
- package/SVF-osx/include/SABER/SaberCheckerAPI.h +4 -4
- package/SVF-osx/include/SABER/SaberCondAllocator.h +32 -35
- package/SVF-osx/include/SVF-FE/BasicTypes.h +10 -0
- package/SVF-osx/include/SVF-FE/CPPUtil.h +9 -8
- package/SVF-osx/include/SVF-FE/DCHG.h +4 -4
- package/SVF-osx/include/SVF-FE/DataFlowUtil.h +1 -1
- package/SVF-osx/include/SVF-FE/GEPTypeBridgeIterator.h +1 -1
- package/SVF-osx/include/SVF-FE/ICFGBuilder.h +9 -9
- package/SVF-osx/include/SVF-FE/IRAnnotator.h +9 -9
- package/SVF-osx/include/SVF-FE/LLVMModule.h +119 -22
- package/SVF-osx/include/SVF-FE/LLVMUtil.h +31 -52
- package/SVF-osx/include/SVF-FE/SVFIRBuilder.h +14 -20
- package/SVF-osx/include/SVF-FE/SymbolTableBuilder.h +8 -8
- package/SVF-osx/include/Util/Annotator.h +22 -22
- package/SVF-osx/include/Util/BasicTypes.h +476 -72
- package/SVF-osx/include/Util/Casting.h +1 -1
- package/SVF-osx/include/Util/CxtStmt.h +13 -12
- package/SVF-osx/include/Util/SVFBasicTypes.h +0 -78
- package/SVF-osx/include/Util/SVFInstruction.h +40 -0
- package/SVF-osx/include/Util/SVFModule.h +58 -124
- package/SVF-osx/include/Util/SVFUtil.h +48 -39
- package/SVF-osx/include/Util/ThreadAPI.h +17 -28
- package/SVF-osx/include/WPA/WPAPass.h +4 -4
- package/package.json +1 -1
|
@@ -59,11 +59,11 @@ public:
|
|
|
59
59
|
|
|
60
60
|
typedef NodeBS LockSet;
|
|
61
61
|
typedef TCT::InstVec InstVec;
|
|
62
|
-
typedef Set<const
|
|
62
|
+
typedef Set<const SVFInstruction*> InstSet;
|
|
63
63
|
typedef InstSet CISpan;
|
|
64
|
-
typedef Map<const
|
|
65
|
-
typedef Set<const
|
|
66
|
-
typedef Map<const
|
|
64
|
+
typedef Map<const SVFInstruction*, CISpan>CILockToSpan;
|
|
65
|
+
typedef Set<const SVFFunction*> FunSet;
|
|
66
|
+
typedef Map<const SVFInstruction*, InstSet> InstToInstSetMap;
|
|
67
67
|
typedef Map<CxtStmt, ValDomain> CxtStmtToLockFlagMap;
|
|
68
68
|
typedef FIFOWorkList<CxtStmt> CxtStmtWorkList;
|
|
69
69
|
typedef Set<CxtStmt> LockSpan;
|
|
@@ -72,13 +72,13 @@ public:
|
|
|
72
72
|
|
|
73
73
|
typedef Map<CxtLock, LockSpan> CxtLockToSpan;
|
|
74
74
|
typedef Map<CxtLock, NodeBS> CxtLockToLockSet;
|
|
75
|
-
typedef Map<const
|
|
76
|
-
typedef Map<const
|
|
75
|
+
typedef Map<const SVFInstruction*, NodeBS> LockSiteToLockSet;
|
|
76
|
+
typedef Map<const SVFInstruction*, LockSpan> InstToCxtStmtSet;
|
|
77
77
|
typedef Map<CxtStmt, CxtLockSet> CxtStmtToCxtLockSet;
|
|
78
78
|
typedef FIFOWorkList<CxtLockProc> CxtLockProcVec;
|
|
79
79
|
typedef Set<CxtLockProc> CxtLockProcSet;
|
|
80
80
|
|
|
81
|
-
typedef Map<const
|
|
81
|
+
typedef Map<const SVFInstruction*, CxtStmtSet> InstToCxtStmt;
|
|
82
82
|
|
|
83
83
|
LockAnalysis(TCT* t) : tct(t), lockTime(0),numOfTotalQueries(0), numOfLockedQueries(0), lockQueriesTime(0)
|
|
84
84
|
{
|
|
@@ -89,7 +89,7 @@ public:
|
|
|
89
89
|
/// (2) maps a context-sensitive lock site to its corresponding lock span.
|
|
90
90
|
void analyze();
|
|
91
91
|
void analyzeIntraProcedualLock();
|
|
92
|
-
bool intraForwardTraverse(const
|
|
92
|
+
bool intraForwardTraverse(const SVFInstruction* lock, InstSet& unlockset, InstSet& forwardInsts);
|
|
93
93
|
bool intraBackwardTraverse(const InstSet& unlockset, InstSet& backwardInsts);
|
|
94
94
|
|
|
95
95
|
void collectCxtLock();
|
|
@@ -101,14 +101,14 @@ public:
|
|
|
101
101
|
/// Intraprocedural locks
|
|
102
102
|
//@{
|
|
103
103
|
/// Return true if the lock is an intra-procedural lock
|
|
104
|
-
inline bool isIntraLock(const
|
|
104
|
+
inline bool isIntraLock(const SVFInstruction* lock) const
|
|
105
105
|
{
|
|
106
106
|
assert(locksites.find(lock)!=locksites.end() && "not a lock site?");
|
|
107
107
|
return ciLocktoSpan.find(lock)!=ciLocktoSpan.end();
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/// Add intra-procedural lock
|
|
111
|
-
inline void addIntraLock(const
|
|
111
|
+
inline void addIntraLock(const SVFInstruction* lockSite, const InstSet& stmts)
|
|
112
112
|
{
|
|
113
113
|
for(InstSet::const_iterator it = stmts.begin(), eit = stmts.end(); it!=eit; ++it)
|
|
114
114
|
{
|
|
@@ -118,7 +118,7 @@ public:
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/// Add intra-procedural lock
|
|
121
|
-
inline void addCondIntraLock(const
|
|
121
|
+
inline void addCondIntraLock(const SVFInstruction* lockSite, const InstSet& stmts)
|
|
122
122
|
{
|
|
123
123
|
for(InstSet::const_iterator it = stmts.begin(), eit = stmts.end(); it!=eit; ++it)
|
|
124
124
|
{
|
|
@@ -127,18 +127,18 @@ public:
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
/// Return true if a statement is inside an intra-procedural lock
|
|
130
|
-
inline bool isInsideIntraLock(const
|
|
130
|
+
inline bool isInsideIntraLock(const SVFInstruction* stmt) const
|
|
131
131
|
{
|
|
132
132
|
return instCILocksMap.find(stmt)!=instCILocksMap.end() || isInsideCondIntraLock(stmt);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/// Return true if a statement is inside a partial lock/unlock pair (conditional lock with unconditional unlock)
|
|
136
|
-
inline bool isInsideCondIntraLock(const
|
|
136
|
+
inline bool isInsideCondIntraLock(const SVFInstruction* stmt) const
|
|
137
137
|
{
|
|
138
138
|
return instTocondCILocksMap.find(stmt)!=instTocondCILocksMap.end();
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
inline const InstSet& getIntraLockSet(const
|
|
141
|
+
inline const InstSet& getIntraLockSet(const SVFInstruction* stmt) const
|
|
142
142
|
{
|
|
143
143
|
InstToInstSetMap::const_iterator it = instCILocksMap.find(stmt);
|
|
144
144
|
assert(it!=instCILocksMap.end() && "intralock not found!");
|
|
@@ -149,7 +149,7 @@ public:
|
|
|
149
149
|
/// Context-sensitive locks
|
|
150
150
|
//@{
|
|
151
151
|
/// Add inter-procedural context-sensitive lock
|
|
152
|
-
inline void addCxtLock(const CallStrCxt& cxt,const
|
|
152
|
+
inline void addCxtLock(const CallStrCxt& cxt,const SVFInstruction* inst)
|
|
153
153
|
{
|
|
154
154
|
CxtLock cxtlock(cxt,inst);
|
|
155
155
|
cxtLockset.insert(cxtlock);
|
|
@@ -193,7 +193,7 @@ public:
|
|
|
193
193
|
//@}
|
|
194
194
|
|
|
195
195
|
/// Return true if it is a candidate function
|
|
196
|
-
inline bool isLockCandidateFun(const
|
|
196
|
+
inline bool isLockCandidateFun(const SVFFunction* fun) const
|
|
197
197
|
{
|
|
198
198
|
return lockcandidateFuncSet.find(fun)!=lockcandidateFuncSet.end();
|
|
199
199
|
}
|
|
@@ -201,12 +201,12 @@ public:
|
|
|
201
201
|
/// Context-sensitive statement and lock spans
|
|
202
202
|
//@{
|
|
203
203
|
/// Get LockSet and LockSpan
|
|
204
|
-
inline bool hasCxtStmtfromInst(const
|
|
204
|
+
inline bool hasCxtStmtfromInst(const SVFInstruction* inst) const
|
|
205
205
|
{
|
|
206
206
|
InstToCxtStmtSet::const_iterator it = instToCxtStmtSet.find(inst);
|
|
207
207
|
return (it != instToCxtStmtSet.end());
|
|
208
208
|
}
|
|
209
|
-
inline const CxtStmtSet& getCxtStmtfromInst(const
|
|
209
|
+
inline const CxtStmtSet& getCxtStmtfromInst(const SVFInstruction* inst) const
|
|
210
210
|
{
|
|
211
211
|
InstToCxtStmtSet::const_iterator it = instToCxtStmtSet.find(inst);
|
|
212
212
|
assert(it != instToCxtStmtSet.end());
|
|
@@ -270,7 +270,7 @@ public:
|
|
|
270
270
|
|
|
271
271
|
|
|
272
272
|
/// Check if one instruction's context stmt is in a lock span
|
|
273
|
-
inline bool hasOneCxtInLockSpan(const
|
|
273
|
+
inline bool hasOneCxtInLockSpan(const SVFInstruction *I, LockSpan lspan) const
|
|
274
274
|
{
|
|
275
275
|
if(!hasCxtStmtfromInst(I))
|
|
276
276
|
return false;
|
|
@@ -285,7 +285,7 @@ public:
|
|
|
285
285
|
return false;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
inline bool hasAllCxtInLockSpan(const
|
|
288
|
+
inline bool hasAllCxtInLockSpan(const SVFInstruction *I, LockSpan lspan) const
|
|
289
289
|
{
|
|
290
290
|
if(!hasCxtStmtfromInst(I))
|
|
291
291
|
return false;
|
|
@@ -304,15 +304,15 @@ public:
|
|
|
304
304
|
/// Check if two Instructions are protected by common locks
|
|
305
305
|
/// echo inst may have multiple cxt stmt
|
|
306
306
|
/// we check whether every cxt stmt of instructions is protected by a common lock.
|
|
307
|
-
bool isProtectedByCommonLock(const
|
|
308
|
-
bool isProtectedByCommonCxtLock(const
|
|
307
|
+
bool isProtectedByCommonLock(const SVFInstruction *i1, const SVFInstruction *i2);
|
|
308
|
+
bool isProtectedByCommonCxtLock(const SVFInstruction *i1, const SVFInstruction *i2);
|
|
309
309
|
bool isProtectedByCommonCxtLock(const CxtStmt& cxtStmt1, const CxtStmt& cxtStmt2);
|
|
310
|
-
bool isProtectedByCommonCILock(const
|
|
310
|
+
bool isProtectedByCommonCILock(const SVFInstruction *i1, const SVFInstruction *i2);
|
|
311
311
|
|
|
312
|
-
bool isInSameSpan(const
|
|
313
|
-
bool isInSameCSSpan(const
|
|
312
|
+
bool isInSameSpan(const SVFInstruction *I1, const SVFInstruction *I2);
|
|
313
|
+
bool isInSameCSSpan(const SVFInstruction *i1, const SVFInstruction *i2) const;
|
|
314
314
|
bool isInSameCSSpan(const CxtStmt& cxtStmt1, const CxtStmt& cxtStmt2) const;
|
|
315
|
-
bool isInSameCISpan(const
|
|
315
|
+
bool isInSameCISpan(const SVFInstruction *i1, const SVFInstruction *i2) const;
|
|
316
316
|
|
|
317
317
|
inline u32_t getNumOfCxtLocks()
|
|
318
318
|
{
|
|
@@ -347,7 +347,7 @@ private:
|
|
|
347
347
|
{
|
|
348
348
|
return isAliasedLocks(cl1.getStmt(), cl2.getStmt());
|
|
349
349
|
}
|
|
350
|
-
bool isAliasedLocks(const
|
|
350
|
+
bool isAliasedLocks(const SVFInstruction* i1, const SVFInstruction* i2)
|
|
351
351
|
{
|
|
352
352
|
/// todo: must alias
|
|
353
353
|
return tct->getPTA()->alias(getLockVal(i1), getLockVal(i2));
|
|
@@ -433,29 +433,29 @@ private:
|
|
|
433
433
|
//@}
|
|
434
434
|
|
|
435
435
|
/// Push calling context
|
|
436
|
-
void pushCxt(CallStrCxt& cxt, const
|
|
436
|
+
void pushCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee);
|
|
437
437
|
/// Match context
|
|
438
|
-
bool matchCxt(CallStrCxt& cxt, const
|
|
438
|
+
bool matchCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee);
|
|
439
439
|
|
|
440
440
|
void validateResults();
|
|
441
441
|
|
|
442
442
|
/// Whether it is a lock site
|
|
443
|
-
inline bool isTDFork(const
|
|
443
|
+
inline bool isTDFork(const SVFInstruction* call)
|
|
444
444
|
{
|
|
445
445
|
return getTCG()->getThreadAPI()->isTDFork(call);
|
|
446
446
|
}
|
|
447
447
|
/// Whether it is a lock site
|
|
448
|
-
inline bool isTDAcquire(const
|
|
448
|
+
inline bool isTDAcquire(const SVFInstruction* call)
|
|
449
449
|
{
|
|
450
450
|
return getTCG()->getThreadAPI()->isTDAcquire(call);
|
|
451
451
|
}
|
|
452
452
|
/// Whether it is a unlock site
|
|
453
|
-
inline bool isTDRelease(const
|
|
453
|
+
inline bool isTDRelease(const SVFInstruction* call)
|
|
454
454
|
{
|
|
455
455
|
return getTCG()->getThreadAPI()->isTDRelease(call);
|
|
456
456
|
}
|
|
457
457
|
/// Get lock value
|
|
458
|
-
inline const Value* getLockVal(const
|
|
458
|
+
inline const Value* getLockVal(const SVFInstruction* call)
|
|
459
459
|
{
|
|
460
460
|
return getTCG()->getThreadAPI()->getLockVal(call);
|
|
461
461
|
}
|
|
@@ -19,7 +19,7 @@ class LockResultValidator
|
|
|
19
19
|
{
|
|
20
20
|
public:
|
|
21
21
|
typedef Set<std::string> CxtLockSetStr;
|
|
22
|
-
typedef Map<const
|
|
22
|
+
typedef Map<const SVFInstruction*, CxtLockSetStr> CxtStmtToCxtLockS;
|
|
23
23
|
|
|
24
24
|
typedef unsigned LOCK_FLAG;
|
|
25
25
|
|
|
@@ -38,11 +38,11 @@ public:
|
|
|
38
38
|
}
|
|
39
39
|
private:
|
|
40
40
|
// Get CallICFGNode
|
|
41
|
-
inline CallICFGNode* getCBN(const
|
|
41
|
+
inline CallICFGNode* getCBN(const SVFInstruction* inst)
|
|
42
42
|
{
|
|
43
43
|
return _la->getTCT()->getCallICFGNode(inst);
|
|
44
44
|
}
|
|
45
|
-
const Instruction
|
|
45
|
+
const Instruction* getPreviousMemoryAccessInst( const Instruction* I)
|
|
46
46
|
{
|
|
47
47
|
I = I->getPrevNode();
|
|
48
48
|
while (I)
|
|
@@ -51,10 +51,11 @@ private:
|
|
|
51
51
|
return I;
|
|
52
52
|
SVFFunction* callee = nullptr;
|
|
53
53
|
|
|
54
|
-
if(SVFUtil::
|
|
54
|
+
if(SVFUtil::isCallSite(I))
|
|
55
55
|
{
|
|
56
56
|
PTACallGraph::FunctionSet callees;
|
|
57
|
-
|
|
57
|
+
const SVFInstruction* svfInst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(I);
|
|
58
|
+
_la->getTCT()->getThreadCallGraph()->getCallees(getCBN(svfInst), callees);
|
|
58
59
|
|
|
59
60
|
for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(),
|
|
60
61
|
ecit = callees.end(); cit!=ecit; cit++)
|
|
@@ -93,7 +94,7 @@ private:
|
|
|
93
94
|
|
|
94
95
|
std::string getOutput(const char* scenario, LOCK_FLAG analysisRes);
|
|
95
96
|
|
|
96
|
-
Set<std::string> getStringArg(const
|
|
97
|
+
Set<std::string> getStringArg(const SVFInstruction* inst, unsigned int arg_num);
|
|
97
98
|
|
|
98
99
|
bool collectLockTargets();
|
|
99
100
|
LOCK_FLAG validateStmtInLock();
|
|
@@ -47,17 +47,17 @@ class MHP
|
|
|
47
47
|
{
|
|
48
48
|
|
|
49
49
|
public:
|
|
50
|
-
typedef Set<const
|
|
51
|
-
typedef Set<const
|
|
50
|
+
typedef Set<const SVFFunction*> FunSet;
|
|
51
|
+
typedef Set<const SVFInstruction*> InstSet;
|
|
52
52
|
typedef TCT::InstVec InstVec;
|
|
53
53
|
typedef FIFOWorkList<CxtThreadStmt> CxtThreadStmtWorkList;
|
|
54
54
|
typedef Set<CxtThreadStmt> CxtThreadStmtSet;
|
|
55
55
|
typedef Map<CxtThreadStmt,NodeBS> ThreadStmtToThreadInterleav;
|
|
56
|
-
typedef Map<const
|
|
56
|
+
typedef Map<const SVFInstruction*,CxtThreadStmtSet> InstToThreadStmtSetMap;
|
|
57
57
|
|
|
58
58
|
typedef Set<CxtStmt> LockSpan;
|
|
59
59
|
|
|
60
|
-
typedef std::pair<const
|
|
60
|
+
typedef std::pair<const SVFFunction*,const SVFFunction*> FuncPair;
|
|
61
61
|
typedef Map<FuncPair, bool> FuncPairToBool;
|
|
62
62
|
|
|
63
63
|
/// Constructor
|
|
@@ -85,29 +85,29 @@ public:
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// Get CallICFGNode
|
|
88
|
-
inline CallICFGNode* getCBN(const
|
|
88
|
+
inline CallICFGNode* getCBN(const SVFInstruction* inst)
|
|
89
89
|
{
|
|
90
90
|
return tct->getCallICFGNode(inst);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/// Whether the function is connected from main function in thread call graph
|
|
94
|
-
bool isConnectedfromMain(const
|
|
94
|
+
bool isConnectedfromMain(const SVFFunction* fun);
|
|
95
95
|
|
|
96
96
|
// /// Interface to query whether two instructions are protected by common locks
|
|
97
|
-
// virtual bool isProtectedByACommonLock(const
|
|
98
|
-
// virtual bool isAllCxtInSameLockSpan(const
|
|
99
|
-
// virtual bool isOneCxtInSameLockSpan(const
|
|
97
|
+
// virtual bool isProtectedByACommonLock(const SVFInstruction* i1, const SVFInstruction* i2);
|
|
98
|
+
// virtual bool isAllCxtInSameLockSpan(const SVFInstruction *I1, const SVFInstruction *I2);
|
|
99
|
+
// virtual bool isOneCxtInSameLockSpan(const SVFInstruction *I1, const SVFInstruction *I2);
|
|
100
100
|
//
|
|
101
|
-
// bool hasOneCxtInLockSpan(const
|
|
102
|
-
// bool hasAllCxtInLockSpan(const
|
|
101
|
+
// bool hasOneCxtInLockSpan(const SVFInstruction *I, LockSpan lspan);
|
|
102
|
+
// bool hasAllCxtInLockSpan(const SVFInstruction *I, LockSpan lspan);
|
|
103
103
|
//
|
|
104
104
|
//
|
|
105
105
|
// LockSpan getSpanfromCxtLock(NodeID l);
|
|
106
106
|
/// Interface to query whether two instructions may happen-in-parallel
|
|
107
|
-
virtual bool mayHappenInParallel(const
|
|
108
|
-
virtual bool mayHappenInParallelCache(const
|
|
109
|
-
virtual bool mayHappenInParallelInst(const
|
|
110
|
-
virtual bool executedByTheSameThread(const
|
|
107
|
+
virtual bool mayHappenInParallel(const SVFInstruction* i1, const SVFInstruction* i2);
|
|
108
|
+
virtual bool mayHappenInParallelCache(const SVFInstruction* i1, const SVFInstruction* i2);
|
|
109
|
+
virtual bool mayHappenInParallelInst(const SVFInstruction* i1, const SVFInstruction* i2);
|
|
110
|
+
virtual bool executedByTheSameThread(const SVFInstruction* i1, const SVFInstruction* i2);
|
|
111
111
|
|
|
112
112
|
/// Get interleaving thread for statement inst
|
|
113
113
|
//@{
|
|
@@ -123,13 +123,13 @@ public:
|
|
|
123
123
|
|
|
124
124
|
/// Get/has ThreadStmt
|
|
125
125
|
//@{
|
|
126
|
-
inline const CxtThreadStmtSet& getThreadStmtSet(const
|
|
126
|
+
inline const CxtThreadStmtSet& getThreadStmtSet(const SVFInstruction* inst) const
|
|
127
127
|
{
|
|
128
128
|
InstToThreadStmtSetMap::const_iterator it = instToTSMap.find(inst);
|
|
129
129
|
assert(it!=instToTSMap.end() && "no thread access the instruction?");
|
|
130
130
|
return it->second;
|
|
131
131
|
}
|
|
132
|
-
inline bool hasThreadStmtSet(const
|
|
132
|
+
inline bool hasThreadStmtSet(const SVFInstruction* inst) const
|
|
133
133
|
{
|
|
134
134
|
return instToTSMap.find(inst)!=instToTSMap.end();
|
|
135
135
|
}
|
|
@@ -140,7 +140,7 @@ public:
|
|
|
140
140
|
|
|
141
141
|
private:
|
|
142
142
|
|
|
143
|
-
inline const PTACallGraph::FunctionSet& getCallee(const
|
|
143
|
+
inline const PTACallGraph::FunctionSet& getCallee(const SVFInstruction* inst, PTACallGraph::FunctionSet& callees)
|
|
144
144
|
{
|
|
145
145
|
tcg->getCallees(getCBN(inst), callees);
|
|
146
146
|
return callees;
|
|
@@ -189,7 +189,7 @@ private:
|
|
|
189
189
|
pushToCTSWorkList(tgr);
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
inline void rmInterleavingThread(const CxtThreadStmt& tgr, const NodeBS& tids, const
|
|
192
|
+
inline void rmInterleavingThread(const CxtThreadStmt& tgr, const NodeBS& tids, const SVFInstruction* joinsite)
|
|
193
193
|
{
|
|
194
194
|
NodeBS joinedTids;
|
|
195
195
|
for(NodeBS::iterator it = tids.begin(), eit = tids.end(); it!=eit; ++it)
|
|
@@ -214,7 +214,7 @@ private:
|
|
|
214
214
|
bool isRecurFullJoin(NodeID parentTid, NodeID curTid);
|
|
215
215
|
|
|
216
216
|
/// Whether a join site must join a thread t
|
|
217
|
-
bool isMustJoin(const NodeID curTid, const
|
|
217
|
+
bool isMustJoin(const NodeID curTid, const SVFInstruction* joinsite);
|
|
218
218
|
|
|
219
219
|
/// A thread is a multiForked thread if it is in a loop or recursion
|
|
220
220
|
inline bool isMultiForkedThread(NodeID curTid)
|
|
@@ -223,17 +223,17 @@ private:
|
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/// Get the next instructions following control flow
|
|
226
|
-
inline void getNextInsts(const
|
|
226
|
+
inline void getNextInsts(const SVFInstruction* inst, InstVec& instVec)
|
|
227
227
|
{
|
|
228
228
|
tct->getNextInsts(inst,instVec);
|
|
229
229
|
}
|
|
230
230
|
/// Push calling context
|
|
231
|
-
inline void pushCxt(CallStrCxt& cxt, const
|
|
231
|
+
inline void pushCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee)
|
|
232
232
|
{
|
|
233
233
|
tct->pushCxt(cxt,call,callee);
|
|
234
234
|
}
|
|
235
235
|
/// Match context
|
|
236
|
-
inline bool matchCxt(CallStrCxt& cxt, const
|
|
236
|
+
inline bool matchCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee)
|
|
237
237
|
{
|
|
238
238
|
return tct->matchCxt(cxt,call,callee);
|
|
239
239
|
}
|
|
@@ -251,21 +251,21 @@ private:
|
|
|
251
251
|
}
|
|
252
252
|
|
|
253
253
|
/// Whether it is a fork site
|
|
254
|
-
inline bool isTDFork(const
|
|
254
|
+
inline bool isTDFork(const SVFInstruction* call)
|
|
255
255
|
{
|
|
256
256
|
return tcg->getThreadAPI()->isTDFork(call);
|
|
257
257
|
}
|
|
258
258
|
/// Whether it is a join site
|
|
259
|
-
inline bool isTDJoin(const
|
|
259
|
+
inline bool isTDJoin(const SVFInstruction* call)
|
|
260
260
|
{
|
|
261
261
|
return tcg->getThreadAPI()->isTDJoin(call);
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
/// Return thread id(s) which are directly or indirectly joined at this join site
|
|
265
|
-
NodeBS getDirAndIndJoinedTid(const CallStrCxt& cxt, const
|
|
265
|
+
NodeBS getDirAndIndJoinedTid(const CallStrCxt& cxt, const SVFInstruction* call);
|
|
266
266
|
|
|
267
267
|
/// Whether a context-sensitive join satisfies symmetric loop pattern
|
|
268
|
-
const Loop* isJoinInSymmetricLoop(const CallStrCxt& cxt, const
|
|
268
|
+
const Loop* isJoinInSymmetricLoop(const CallStrCxt& cxt, const SVFInstruction* call) const;
|
|
269
269
|
|
|
270
270
|
/// Whether thread t1 happens before t2 based on ForkJoin Analysis
|
|
271
271
|
bool isHBPair(NodeID tid1, NodeID tid2);
|
|
@@ -309,7 +309,7 @@ public:
|
|
|
309
309
|
typedef Set<NodePair> ThreadPairSet;
|
|
310
310
|
typedef Map<CxtStmt, const Loop*> CxtStmtToLoopMap;
|
|
311
311
|
typedef FIFOWorkList<CxtStmt> CxtStmtWorkList;
|
|
312
|
-
typedef Map<const
|
|
312
|
+
typedef Map<const SVFInstruction*, PTASCEV> forkjoinToPTASCEVMap;
|
|
313
313
|
ForkJoinAnalysis(TCT* t) : tct(t)
|
|
314
314
|
{
|
|
315
315
|
collectSCEVInfo();
|
|
@@ -358,22 +358,22 @@ public:
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
/// Get exit instruction of the start routine function of tid's parent thread
|
|
361
|
-
inline const
|
|
361
|
+
inline const SVFInstruction* getExitInstOfParentRoutineFun(NodeID tid) const
|
|
362
362
|
{
|
|
363
363
|
NodeID parentTid = tct->getParentThread(tid);
|
|
364
364
|
const CxtThread& parentct = tct->getTCTNode(parentTid)->getCxtThread();
|
|
365
|
-
const
|
|
366
|
-
const
|
|
367
|
-
return
|
|
365
|
+
const SVFFunction* parentRoutine = tct->getStartRoutineOfCxtThread(parentct);
|
|
366
|
+
const SVFInstruction* inst = parentRoutine->getExitBB()->back();
|
|
367
|
+
return inst;
|
|
368
368
|
}
|
|
369
369
|
|
|
370
370
|
/// Get loop for join site
|
|
371
|
-
inline const Loop* getJoinLoop(const
|
|
371
|
+
inline const Loop* getJoinLoop(const SVFInstruction* inst)
|
|
372
372
|
{
|
|
373
373
|
return tct->getJoinLoop(inst);
|
|
374
374
|
}
|
|
375
375
|
/// Get SE for function
|
|
376
|
-
inline ScalarEvolution* getSE(const
|
|
376
|
+
inline ScalarEvolution* getSE(const SVFInstruction* inst)
|
|
377
377
|
{
|
|
378
378
|
return tct->getSE(inst);
|
|
379
379
|
}
|
|
@@ -395,18 +395,18 @@ private:
|
|
|
395
395
|
void handleIntra(const CxtStmt& cts);
|
|
396
396
|
|
|
397
397
|
/// Return true if the fork and join have the same SCEV
|
|
398
|
-
bool isSameSCEV(const
|
|
398
|
+
bool isSameSCEV(const SVFInstruction* forkSite, const SVFInstruction* joinSite);
|
|
399
399
|
|
|
400
400
|
/// Same loop trip count
|
|
401
|
-
bool sameLoopTripCount(const
|
|
401
|
+
bool sameLoopTripCount(const SVFInstruction* forkSite, const SVFInstruction* joinSite);
|
|
402
402
|
|
|
403
403
|
/// Whether it is a matched fork join pair
|
|
404
|
-
bool isAliasedForkJoin(const
|
|
404
|
+
bool isAliasedForkJoin(const SVFInstruction* forkSite, const SVFInstruction* joinSite)
|
|
405
405
|
{
|
|
406
406
|
return tct->getPTA()->alias(getForkedThread(forkSite), getJoinedThread(joinSite)) && isSameSCEV(forkSite,joinSite);
|
|
407
407
|
}
|
|
408
408
|
// Get CallICFGNode
|
|
409
|
-
inline CallICFGNode* getCBN(const
|
|
409
|
+
inline CallICFGNode* getCBN(const SVFInstruction* inst)
|
|
410
410
|
{
|
|
411
411
|
return tct->getCallICFGNode(inst);
|
|
412
412
|
}
|
|
@@ -477,42 +477,42 @@ private:
|
|
|
477
477
|
//@}
|
|
478
478
|
|
|
479
479
|
/// Get the next instructions following control flow
|
|
480
|
-
inline void getNextInsts(const
|
|
480
|
+
inline void getNextInsts(const SVFInstruction* inst, InstVec& instSet)
|
|
481
481
|
{
|
|
482
482
|
tct->getNextInsts(inst,instSet);
|
|
483
483
|
}
|
|
484
484
|
/// Push calling context
|
|
485
|
-
inline void pushCxt(CallStrCxt& cxt, const
|
|
485
|
+
inline void pushCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee)
|
|
486
486
|
{
|
|
487
487
|
tct->pushCxt(cxt,call,callee);
|
|
488
488
|
}
|
|
489
489
|
/// Match context
|
|
490
|
-
inline bool matchCxt(CallStrCxt& cxt, const
|
|
490
|
+
inline bool matchCxt(CallStrCxt& cxt, const SVFInstruction* call, const SVFFunction* callee)
|
|
491
491
|
{
|
|
492
492
|
return tct->matchCxt(cxt,call,callee);
|
|
493
493
|
}
|
|
494
494
|
|
|
495
495
|
/// Whether it is a fork site
|
|
496
|
-
inline bool isTDFork(const
|
|
496
|
+
inline bool isTDFork(const SVFInstruction* call)
|
|
497
497
|
{
|
|
498
498
|
return getTCG()->getThreadAPI()->isTDFork(call);
|
|
499
499
|
}
|
|
500
500
|
/// Whether it is a join site
|
|
501
|
-
inline bool isTDJoin(const
|
|
501
|
+
inline bool isTDJoin(const SVFInstruction* call)
|
|
502
502
|
{
|
|
503
503
|
return getTCG()->getThreadAPI()->isTDJoin(call);
|
|
504
504
|
}
|
|
505
505
|
/// Get forked thread
|
|
506
|
-
inline const Value* getForkedThread(const
|
|
506
|
+
inline const Value* getForkedThread(const SVFInstruction* call)
|
|
507
507
|
{
|
|
508
508
|
return getTCG()->getThreadAPI()->getForkedThread(call);
|
|
509
509
|
}
|
|
510
510
|
/// Get joined thread
|
|
511
|
-
inline const Value* getJoinedThread(const
|
|
511
|
+
inline const Value* getJoinedThread(const SVFInstruction* call)
|
|
512
512
|
{
|
|
513
513
|
return getTCG()->getThreadAPI()->getJoinedThread(call);
|
|
514
514
|
}
|
|
515
|
-
inline const PTACallGraph::FunctionSet& getCallee(const
|
|
515
|
+
inline const PTACallGraph::FunctionSet& getCallee(const SVFInstruction* inst, PTACallGraph::FunctionSet& callees)
|
|
516
516
|
{
|
|
517
517
|
getTCG()->getCallees(getCBN(inst), callees);
|
|
518
518
|
return callees;
|
|
@@ -60,8 +60,8 @@ class MTA: public ModulePass
|
|
|
60
60
|
public:
|
|
61
61
|
typedef Set<const LoadInst*> LoadSet;
|
|
62
62
|
typedef Set<const StoreInst*> StoreSet;
|
|
63
|
-
typedef Map<const
|
|
64
|
-
typedef Map<const
|
|
63
|
+
typedef Map<const SVFFunction*, ScalarEvolution*> FunToSEMap;
|
|
64
|
+
typedef Map<const SVFFunction*, LoopInfo*> FunToLoopInfoMap;
|
|
65
65
|
|
|
66
66
|
/// Pass ID
|
|
67
67
|
static char ID;
|
|
@@ -96,12 +96,12 @@ public:
|
|
|
96
96
|
void dump(Module &module, MHP *mhp, LockAnalysis *lsa);
|
|
97
97
|
|
|
98
98
|
// Get ScalarEvolution for Function F.
|
|
99
|
-
static inline ScalarEvolution* getSE(const
|
|
99
|
+
static inline ScalarEvolution* getSE(const SVFFunction* F)
|
|
100
100
|
{
|
|
101
101
|
FunToSEMap::iterator it = func2ScevMap.find(F);
|
|
102
102
|
if (it != func2ScevMap.end())
|
|
103
103
|
return it->second;
|
|
104
|
-
ScalarEvolutionWrapperPass *scev = &modulePass->getAnalysis<ScalarEvolutionWrapperPass>(*const_cast<Function*>(F));
|
|
104
|
+
ScalarEvolutionWrapperPass *scev = &modulePass->getAnalysis<ScalarEvolutionWrapperPass>(*const_cast<Function*>(F->getLLVMFun()));
|
|
105
105
|
func2ScevMap[F] = &scev->getSE();
|
|
106
106
|
return &scev->getSE();
|
|
107
107
|
}
|
|
@@ -68,16 +68,18 @@ public:
|
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
/// Check if Function "F" is memset
|
|
71
|
-
inline bool isMemset(const Instruction
|
|
71
|
+
inline bool isMemset(const Instruction* I)
|
|
72
72
|
{
|
|
73
|
-
const
|
|
73
|
+
const SVFInstruction* svfInst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(I);
|
|
74
|
+
const Function* F =SVFUtil::getCallee(svfInst)->getLLVMFun();
|
|
74
75
|
return F && F->getName().find("llvm.memset") != std::string::npos;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
/// Check if Function "F" is memcpy
|
|
78
|
-
inline bool isMemcpy(const Instruction
|
|
79
|
+
inline bool isMemcpy(const Instruction* I)
|
|
79
80
|
{
|
|
80
|
-
const
|
|
81
|
+
const SVFInstruction* svfInst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(I);
|
|
82
|
+
const SVFFunction* F = SVFUtil::getCallee(svfInst);
|
|
81
83
|
return F && F->getName().find("llvm.memcpy") != std::string::npos;
|
|
82
84
|
}
|
|
83
85
|
|