svf-tools 1.0.977 → 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.
Files changed (68) hide show
  1. package/package.json +1 -1
  2. package/svf/include/AE/Svfexe/AbstractInterpretation.h +1 -1
  3. package/svf/include/DDA/ContextDDA.h +2 -2
  4. package/svf/include/DDA/DDAVFSolver.h +5 -5
  5. package/svf/include/DDA/FlowDDA.h +1 -1
  6. package/svf/include/Graphs/{PTACallGraph.h → CallGraph.h} +41 -41
  7. package/svf/include/Graphs/ICFG.h +2 -2
  8. package/svf/include/Graphs/ThreadCallGraph.h +24 -30
  9. package/svf/include/Graphs/VFG.h +4 -4
  10. package/svf/include/MSSA/MemRegion.h +4 -4
  11. package/svf/include/MTA/LockAnalysis.h +42 -32
  12. package/svf/include/MTA/MHP.h +34 -54
  13. package/svf/include/MTA/MTAStat.h +1 -2
  14. package/svf/include/MTA/TCT.h +43 -25
  15. package/svf/include/MemoryModel/PointerAnalysis.h +13 -13
  16. package/svf/include/SABER/SaberSVFGBuilder.h +1 -1
  17. package/svf/include/SABER/SrcSnkDDA.h +7 -7
  18. package/svf/include/Util/CallGraphBuilder.h +5 -5
  19. package/svf/include/Util/CxtStmt.h +13 -12
  20. package/svf/include/Util/Options.h +1 -20
  21. package/svf/include/Util/SVFUtil.h +8 -43
  22. package/svf/include/Util/ThreadAPI.h +42 -85
  23. package/svf/lib/AE/Svfexe/AbstractInterpretation.cpp +1 -1
  24. package/svf/lib/CFL/CFLSVFGBuilder.cpp +1 -1
  25. package/svf/lib/DDA/ContextDDA.cpp +9 -9
  26. package/svf/lib/DDA/DDAClient.cpp +3 -3
  27. package/svf/lib/DDA/DDAPass.cpp +4 -4
  28. package/svf/lib/DDA/FlowDDA.cpp +2 -2
  29. package/svf/lib/Graphs/{PTACallGraph.cpp → CallGraph.cpp} +66 -66
  30. package/svf/lib/Graphs/ICFG.cpp +6 -6
  31. package/svf/lib/Graphs/SVFG.cpp +7 -7
  32. package/svf/lib/Graphs/SVFGReadWrite.cpp +6 -6
  33. package/svf/lib/Graphs/SVFGStat.cpp +1 -1
  34. package/svf/lib/Graphs/ThreadCallGraph.cpp +12 -84
  35. package/svf/lib/Graphs/VFG.cpp +1 -1
  36. package/svf/lib/MSSA/MemRegion.cpp +7 -7
  37. package/svf/lib/MTA/LockAnalysis.cpp +100 -92
  38. package/svf/lib/MTA/MHP.cpp +159 -138
  39. package/svf/lib/MTA/MTA.cpp +3 -41
  40. package/svf/lib/MTA/MTAStat.cpp +7 -33
  41. package/svf/lib/MTA/TCT.cpp +52 -52
  42. package/svf/lib/MemoryModel/PointerAnalysis.cpp +12 -12
  43. package/svf/lib/SABER/LeakChecker.cpp +4 -4
  44. package/svf/lib/SABER/SaberSVFGBuilder.cpp +4 -4
  45. package/svf/lib/SABER/SrcSnkDDA.cpp +1 -1
  46. package/svf/lib/Util/CallGraphBuilder.cpp +2 -17
  47. package/svf/lib/Util/Options.cpp +0 -62
  48. package/svf/lib/Util/PTAStat.cpp +7 -7
  49. package/svf/lib/Util/ThreadAPI.cpp +27 -6
  50. package/svf/lib/WPA/VersionedFlowSensitive.cpp +2 -2
  51. package/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +1 -1
  52. package/svf-llvm/lib/SVFIRBuilder.cpp +5 -5
  53. package/svf-llvm/lib/SVFIRExtAPI.cpp +0 -26
  54. package/svf-llvm/tools/AE/ae.cpp +1 -1
  55. package/svf-llvm/tools/Example/svf-ex.cpp +1 -1
  56. package/svf-llvm/tools/MTA/CMakeLists.txt +1 -1
  57. package/svf-llvm/tools/MTA/mta.cpp +0 -8
  58. package/svf/include/MTA/FSMPTA.h +0 -270
  59. package/svf/include/MTA/MTAResultValidator.h +0 -448
  60. package/svf/include/MTA/PCG.h +0 -229
  61. package/svf/lib/MTA/FSMPTA.cpp +0 -792
  62. package/svf/lib/MTA/PCG.cpp +0 -364
  63. package/svf-llvm/tools/MTA/LockResultValidator.cpp +0 -251
  64. package/svf-llvm/tools/MTA/LockResultValidator.h +0 -84
  65. package/svf-llvm/tools/MTA/MTAAnnotator.cpp +0 -293
  66. package/svf-llvm/tools/MTA/MTAAnnotator.h +0 -120
  67. package/svf-llvm/tools/MTA/MTAResultValidator.cpp +0 -716
  68. package/svf-llvm/tools/MTA/MTAResultValidator.h +0 -337
@@ -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",
@@ -28,7 +28,7 @@
28
28
  */
29
29
 
30
30
  #include <iomanip>
31
- #include "Graphs/PTACallGraph.h"
31
+ #include "Graphs/CallGraph.h"
32
32
  #include "Util/PTAStat.h"
33
33
  #include "MemoryModel/PointerAnalysisImpl.h"
34
34
  #include "SVFIR/SVFIR.h"
@@ -81,7 +81,7 @@ void PTAStat::performStat()
81
81
  void PTAStat::callgraphStat()
82
82
  {
83
83
 
84
- PTACallGraph* graph = pta->getPTACallGraph();
84
+ CallGraph* graph = pta->getCallGraph();
85
85
  PointerAnalysis::CallGraphSCC* callgraphSCC = new PointerAnalysis::CallGraphSCC(graph);
86
86
  callgraphSCC->find();
87
87
 
@@ -93,8 +93,8 @@ void PTAStat::callgraphStat()
93
93
  unsigned edgeInCycle = 0;
94
94
 
95
95
  NodeSet sccRepNodeSet;
96
- PTACallGraph::iterator it = graph->begin();
97
- PTACallGraph::iterator eit = graph->end();
96
+ CallGraph::iterator it = graph->begin();
97
+ CallGraph::iterator eit = graph->end();
98
98
  for (; it != eit; ++it)
99
99
  {
100
100
  totalNode++;
@@ -107,11 +107,11 @@ void PTAStat::callgraphStat()
107
107
  maxNodeInCycle = subNodes.count();
108
108
  }
109
109
 
110
- PTACallGraphNode::const_iterator edgeIt = it->second->InEdgeBegin();
111
- PTACallGraphNode::const_iterator edgeEit = it->second->InEdgeEnd();
110
+ CallGraphNode::const_iterator edgeIt = it->second->InEdgeBegin();
111
+ CallGraphNode::const_iterator edgeEit = it->second->InEdgeEnd();
112
112
  for (; edgeIt != edgeEit; ++edgeIt)
113
113
  {
114
- PTACallGraphEdge *edge = *edgeIt;
114
+ CallGraphEdge *edge = *edgeIt;
115
115
  totalEdge+= edge->getDirectCalls().size() + edge->getIndirectCalls().size();
116
116
  if(callgraphSCC->repNode(edge->getSrcID()) == callgraphSCC->repNode(edge->getDstID()))
117
117
  {
@@ -132,17 +132,37 @@ void ThreadAPI::init()
132
132
  /*!
133
133
  *
134
134
  */
135
- const SVFFunction* ThreadAPI::getCallee(const SVFInstruction *inst) const
135
+ const SVFFunction* ThreadAPI::getCallee(const ICFGNode *inst) const
136
136
  {
137
- return SVFUtil::getCallee(inst);
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 CallSite cs) 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
- return SVFUtil::getCallee(cs);
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 SVFInstruction *inst) 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
- const SVFFunction* fun = getCallee(svfInst);
254
+
255
+ const SVFFunction* fun = SVFUtil::getCallee(svfInst);
235
256
  TD_TYPE type = getType(fun);
236
257
  switch (type)
237
258
  {
@@ -483,9 +483,9 @@ void VersionedFlowSensitive::buildDeltaMaps(void)
483
483
  bool isDelta = false;
484
484
  if (const SVFFunction *fn = svfg->isFunEntrySVFGNode(s))
485
485
  {
486
- PTACallGraphEdge::CallInstSet callsites;
486
+ CallGraphEdge::CallInstSet callsites;
487
487
  /// use pre-analysis call graph to approximate all potential callsites
488
- ander->getPTACallGraph()->getIndCallSitesInvokingCallee(fn, callsites);
488
+ ander->getCallGraph()->getIndCallSitesInvokingCallee(fn, callsites);
489
489
  isDelta = !callsites.empty();
490
490
 
491
491
  if (isDelta)
@@ -201,7 +201,7 @@ public:
201
201
  //}@
202
202
 
203
203
  /// connect PAG edges based on callgraph
204
- void updateCallGraph(PTACallGraph* callgraph);
204
+ void updateCallGraph(CallGraph* callgraph);
205
205
 
206
206
  protected:
207
207
  /// Handle globals including (global variable and functions)
@@ -1146,17 +1146,17 @@ void SVFIRBuilder::handleIndCall(CallBase* cs)
1146
1146
  pag->addIndirectCallsites(cbn,pag->getValueNode(svfcalledval));
1147
1147
  }
1148
1148
 
1149
- void SVFIRBuilder::updateCallGraph(PTACallGraph* callgraph)
1149
+ void SVFIRBuilder::updateCallGraph(CallGraph* callgraph)
1150
1150
  {
1151
- PTACallGraph::CallEdgeMap::const_iterator iter = callgraph->getIndCallMap().begin();
1152
- PTACallGraph::CallEdgeMap::const_iterator eiter = callgraph->getIndCallMap().end();
1151
+ CallGraph::CallEdgeMap::const_iterator iter = callgraph->getIndCallMap().begin();
1152
+ CallGraph::CallEdgeMap::const_iterator eiter = callgraph->getIndCallMap().end();
1153
1153
  for (; iter != eiter; iter++)
1154
1154
  {
1155
1155
  const CallICFGNode* callBlock = iter->first;
1156
1156
  const CallBase* callbase = SVFUtil::cast<CallBase>(LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(callBlock->getCallSite()));
1157
1157
  assert(callBlock->isIndirectCall() && "this is not an indirect call?");
1158
- const PTACallGraph::FunctionSet& functions = iter->second;
1159
- for (PTACallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
1158
+ const CallGraph::FunctionSet& functions = iter->second;
1159
+ for (CallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
1160
1160
  {
1161
1161
  const Function* callee = SVFUtil::cast<Function>(LLVMModuleSet::getLLVMModuleSet()->getLLVMValue(*func_iter));
1162
1162
 
@@ -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
  }
@@ -880,7 +880,7 @@ int main(int argc, char** argv)
880
880
  SVFIRBuilder builder(svfModule);
881
881
  SVFIR* pag = builder.build();
882
882
  AndersenWaveDiff* ander = AndersenWaveDiff::createAndersenWaveDiff(pag);
883
- PTACallGraph* callgraph = ander->getPTACallGraph();
883
+ CallGraph* callgraph = ander->getCallGraph();
884
884
  builder.updateCallGraph(callgraph);
885
885
  pag->getICFG()->updateCallGraph(callgraph);
886
886
  if (Options::ICFGMergeAdjacentNodes())
@@ -168,7 +168,7 @@ int main(int argc, char ** argv)
168
168
 
169
169
 
170
170
  /// Call Graph
171
- PTACallGraph* callgraph = ander->getPTACallGraph();
171
+ CallGraph* callgraph = ander->getCallGraph();
172
172
 
173
173
  /// ICFG
174
174
  ICFG* icfg = pag->getICFG();
@@ -1,2 +1,2 @@
1
- add_llvm_executable(mta mta.cpp LockResultValidator.cpp MTAResultValidator.cpp MTAAnnotator.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
 
@@ -1,270 +0,0 @@
1
- //===- FSMPTA.h -- Flow-sensitive analysis of multithreaded programs-------------//
2
- //
3
- // SVF: Static Value-Flow Analysis
4
- //
5
- // Copyright (C) <2013-> <Yulei Sui>
6
- //
7
-
8
- // This program is free software: you can redistribute it and/or modify
9
- // it under the terms of the GNU Affero General Public License as published by
10
- // the Free Software Foundation, either version 3 of the License, or
11
- // (at your option) any later version.
12
-
13
- // This program is distributed in the hope that it will be useful,
14
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- // GNU Affero General Public License for more details.
17
-
18
- // You should have received a copy of the GNU Affero General Public License
19
- // along with this program. If not, see <http://www.gnu.org/licenses/>.
20
- //
21
- //===----------------------------------------------------------------------===//
22
-
23
- /*
24
- * FSMPTA.h
25
- *
26
- * Created on: Jul 29, 2015
27
- * Author: Yulei Sui, Peng Di
28
- *
29
- * The implementation is based on
30
- * Yulei Sui, Peng Di, and Jingling Xue. "Sparse Flow-Sensitive Pointer Analysis for Multithreaded Programs".
31
- * 2016 International Symposium on Code Generation and Optimization (CGO'16)
32
- */
33
-
34
- #ifndef FSPTANALYSIS_H_
35
- #define FSPTANALYSIS_H_
36
-
37
-
38
- #include "WPA/FlowSensitive.h"
39
- #include "MSSA/SVFGBuilder.h"
40
- #include "MTA/LockAnalysis.h"
41
- #include "MemoryModel/PointsTo.h"
42
- #include "MTA/MHP.h"
43
-
44
- namespace SVF
45
- {
46
-
47
- class MHP;
48
- class LockAnalysis;
49
-
50
-
51
- class SVFGNodeLockSpan
52
- {
53
- public:
54
- SVFGNodeLockSpan(const StmtSVFGNode* SVFGnode, LockAnalysis::LockSpan lockspan) :
55
- SVFGNode(SVFGnode), lockSpan(lockspan) {}
56
- virtual ~SVFGNodeLockSpan() {}
57
-
58
- inline bool operator< (const SVFGNodeLockSpan& rhs) const
59
- {
60
- if (SVFGNode != rhs.getSVFGNode())
61
- return SVFGNode < rhs.getSVFGNode();
62
- return lockSpan.size() < rhs.getLockSpan().size();
63
- }
64
- inline SVFGNodeLockSpan& operator= (const SVFGNodeLockSpan& rhs)
65
- {
66
- if(*this != rhs)
67
- {
68
- SVFGNode = rhs.getSVFGNode();
69
- lockSpan = rhs.getLockSpan();
70
- }
71
- return *this;
72
- }
73
- inline bool operator== (const SVFGNodeLockSpan& rhs) const
74
- {
75
- return (SVFGNode == rhs.getSVFGNode() && lockSpan == rhs.getLockSpan());
76
- }
77
- inline bool operator!= (const SVFGNodeLockSpan& rhs) const
78
- {
79
- return !(*this == rhs);
80
- }
81
- inline const StmtSVFGNode* getSVFGNode() const
82
- {
83
- return SVFGNode;
84
- }
85
- inline const LockAnalysis::LockSpan getLockSpan() const
86
- {
87
- return lockSpan;
88
- }
89
- private:
90
- const StmtSVFGNode* SVFGNode;
91
- LockAnalysis::LockSpan lockSpan;
92
- };
93
-
94
- /*!
95
- * SVFG builder for DDA
96
- */
97
- class MTASVFGBuilder : public SVFGBuilder
98
- {
99
-
100
- public:
101
- typedef PointerAnalysis::CallSiteSet CallSiteSet;
102
- typedef PointerAnalysis::CallEdgeMap CallEdgeMap;
103
- typedef PointerAnalysis::FunctionSet FunctionSet;
104
- typedef Set<const SVFGNode*> SVFGNodeSet;
105
- typedef std::vector<const SVFGNode*> SVFGNodeVec;
106
- typedef NodeBS SVFGNodeIDSet;
107
- typedef Set<const SVFInstruction*> InstSet;
108
- typedef std::pair<NodeID,NodeID> NodeIDPair;
109
- typedef Map<SVFGNodeLockSpan, bool> PairToBoolMap;
110
-
111
- /// Constructor
112
- MTASVFGBuilder(MHP* m, LockAnalysis* la) : SVFGBuilder(), mhp(m), lockana(la)
113
- {
114
- }
115
-
116
- /// Destructor
117
- virtual ~MTASVFGBuilder() {}
118
-
119
- /// Number of newly added SVFG edges
120
- static u32_t numOfNewSVFGEdges;
121
- static u32_t numOfRemovedSVFGEdges;
122
- static u32_t numOfRemovedPTS;
123
-
124
- protected:
125
- /// Re-write create SVFG method
126
- virtual void buildSVFG();
127
-
128
- private:
129
- /// Record edges
130
- bool recordEdge(NodeID id1, NodeID id2, PointsTo pts);
131
- bool recordAddingEdge(NodeID id1, NodeID id2, PointsTo pts);
132
- bool recordRemovingEdge(NodeID id1, NodeID id2, PointsTo pts);
133
- /// perform adding/removing MHP Edges in value flow graph
134
- void performAddingMHPEdges();
135
- void performRemovingMHPEdges();
136
- SVFGEdge* addTDEdges(NodeID srcId, NodeID dstId, PointsTo& pts);
137
- /// Connect MHP indirect value-flow edges for two nodes that may-happen-in-parallel
138
- void connectMHPEdges(PointerAnalysis* pta);
139
-
140
- void handleStoreLoadNonSparse(const StmtSVFGNode* n1,const StmtSVFGNode* n2, PointerAnalysis* pta);
141
- void handleStoreStoreNonSparse(const StmtSVFGNode* n1,const StmtSVFGNode* n2, PointerAnalysis* pta);
142
-
143
- void handleStoreLoad(const StmtSVFGNode* n1,const StmtSVFGNode* n2, PointerAnalysis* pta);
144
- void handleStoreStore(const StmtSVFGNode* n1,const StmtSVFGNode* n2, PointerAnalysis* pta);
145
-
146
- void handleStoreLoadWithLockPrecisely(const StmtSVFGNode* n1,const StmtSVFGNode* n2, PointerAnalysis* pta);
147
- void handleStoreStoreWithLockPrecisely(const StmtSVFGNode* n1,const StmtSVFGNode* n2, PointerAnalysis* pta);
148
-
149
- void mergeSpan(NodeBS comlocks, InstSet& res);
150
- void readPrecision();
151
-
152
- SVFGNodeIDSet getPrevNodes(const StmtSVFGNode* n);
153
- SVFGNodeIDSet getSuccNodes(const StmtSVFGNode* n);
154
- SVFGNodeIDSet getSuccNodes(const StmtSVFGNode* n, NodeID o);
155
-
156
- bool isHeadofSpan(const StmtSVFGNode* n, LockAnalysis::LockSpan lspan);
157
- bool isTailofSpan(const StmtSVFGNode* n, LockAnalysis::LockSpan lspan);
158
- bool isHeadofSpan(const StmtSVFGNode* n, InstSet mergespan);
159
- bool isTailofSpan(const StmtSVFGNode* n, InstSet mergespan);
160
- bool isHeadofSpan(const StmtSVFGNode* n);
161
- bool isTailofSpan(const StmtSVFGNode* n);
162
- /// Collect all loads/stores SVFGNodes
163
- void collectLoadStoreSVFGNodes();
164
-
165
- /// all stores/loads SVFGNodes
166
- SVFGNodeSet stnodeSet;
167
- SVFGNodeSet ldnodeSet;
168
-
169
- /// MHP class
170
- MHP* mhp;
171
- LockAnalysis* lockana;
172
-
173
- Set<NodeIDPair> recordedges;
174
- Map<NodeIDPair, PointsTo> edge2pts;
175
-
176
-
177
- Map<const StmtSVFGNode*, SVFGNodeIDSet> prevset;
178
- Map<const StmtSVFGNode*, SVFGNodeIDSet> succset;
179
-
180
- Map<const StmtSVFGNode*, bool> headmap;
181
- Map<const StmtSVFGNode*, bool> tailmap;
182
-
183
- PairToBoolMap pairheadmap;
184
- PairToBoolMap pairtailmap;
185
-
186
-
187
- static const u32_t ADDEDGE_NOEDGE= 0;
188
- static const u32_t ADDEDGE_NONSPARSE= 1;
189
- static const u32_t ADDEDGE_ALLOPT= 2;
190
- static const u32_t ADDEDGE_NOMHP= 3;
191
- static const u32_t ADDEDGE_NOALIAS= 4;
192
- static const u32_t ADDEDGE_NOLOCK= 5;
193
- static const u32_t ADDEDGE_NORP= 6;
194
- // static const u32_t ADDEDGE_PRECISELOCK= 5;
195
-
196
- };
197
-
198
-
199
- /*!
200
- * Flow-sensitive pointer analysis for multithreaded programs
201
- */
202
- class FSMPTA : public FlowSensitive
203
- {
204
-
205
-
206
- public:
207
-
208
- /// Constructor
209
- FSMPTA(MHP* m, LockAnalysis* la) : FlowSensitive(m->getTCT()->getPTA()->getPAG()), mhp(m), lockana(la)
210
- {
211
- }
212
-
213
- /// Destructor
214
- ~FSMPTA()
215
- {
216
- }
217
-
218
- /// Initialize analysis
219
- void initialize(SVFModule* module);
220
-
221
- inline SVFIR* getPAG()
222
- {
223
- return mhp->getTCT()->getPTA()->getPAG();
224
- }
225
-
226
- /// Create single instance of flow-sensitive pointer analysis
227
- static FSMPTA* createFSMPTA(SVFModule* module, MHP* m, LockAnalysis* la)
228
- {
229
- if (mfspta == nullptr)
230
- {
231
- mfspta = new FSMPTA(m,la);
232
- mfspta->analyze();
233
- }
234
- return mfspta;
235
- }
236
-
237
- /// Release flow-sensitive pointer analysis
238
- static void releaseFSMPTA()
239
- {
240
- if (mfspta)
241
- delete mfspta;
242
- mfspta = nullptr;
243
- }
244
-
245
- /// Get MHP
246
- inline MHP* getMHP() const
247
- {
248
- return mhp;
249
- }
250
-
251
- private:
252
- static FSMPTA* mfspta;
253
- MHP* mhp;
254
- LockAnalysis* lockana;
255
- using FlowSensitive::initialize;
256
- };
257
-
258
- } // End namespace SVF
259
-
260
- template <> struct std::hash<SVF::SVFGNodeLockSpan>
261
- {
262
- size_t operator()(const SVF::SVFGNodeLockSpan &cs) const
263
- {
264
- std::hash<SVF::StmtSVFGNode* >h;
265
- SVF::StmtSVFGNode* node = const_cast<SVF::StmtSVFGNode* > (cs.getSVFGNode());
266
- return h(node);
267
- }
268
- };
269
-
270
- #endif /* FSPTANALYSIS_H_ */