svf-tools 1.0.362 → 1.0.366

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 (199) hide show
  1. package/SVF-doxygen/html/html/AndersenStat_8cpp_source.html +1 -1
  2. package/SVF-doxygen/html/html/Andersen_8h_source.html +1 -1
  3. package/SVF-doxygen/html/html/ConsGNode_8h_source.html +5 -5
  4. package/SVF-doxygen/html/html/ConsG_8cpp_source.html +34 -32
  5. package/SVF-doxygen/html/html/ConsG_8h_source.html +20 -20
  6. package/SVF-doxygen/html/html/ContextDDA_8h_source.html +1 -1
  7. package/SVF-doxygen/html/html/DDAClient_8cpp_source.html +2 -2
  8. package/SVF-doxygen/html/html/DDAClient_8h_source.html +1 -1
  9. package/SVF-doxygen/html/html/DDAPass_8cpp_source.html +1 -1
  10. package/SVF-doxygen/html/html/DDAStat_8cpp_source.html +1 -1
  11. package/SVF-doxygen/html/html/DDAVFSolver_8h_source.html +1 -1
  12. package/SVF-doxygen/html/html/FlowDDA_8h_source.html +1 -1
  13. package/SVF-doxygen/html/html/ICFG_8cpp_source.html +9 -9
  14. package/SVF-doxygen/html/html/IRAnnotator_8h_source.html +1 -1
  15. package/SVF-doxygen/html/html/MTAAnnotator_8cpp_source.html +1 -1
  16. package/SVF-doxygen/html/html/MemRegion_8cpp_source.html +1 -1
  17. package/SVF-doxygen/html/html/PAGBuilderFromFile_8cpp_source.html +1 -1
  18. package/SVF-doxygen/html/html/PointerAnalysisImpl_8cpp_source.html +5 -5
  19. package/SVF-doxygen/html/html/PointerAnalysisImpl_8h_source.html +1 -1
  20. package/SVF-doxygen/html/html/PointerAnalysis_8cpp_source.html +13 -15
  21. package/SVF-doxygen/html/html/PointerAnalysis_8h_source.html +14 -14
  22. package/SVF-doxygen/html/html/SVFGOPT_8h_source.html +2 -2
  23. package/SVF-doxygen/html/html/SVFG_8cpp_source.html +4 -4
  24. package/SVF-doxygen/html/html/SVFG_8h_source.html +1 -1
  25. package/SVF-doxygen/html/html/SVFIRBuilder_8cpp_source.html +12 -6
  26. package/SVF-doxygen/html/html/SVFIRBuilder_8h_source.html +90 -84
  27. package/SVF-doxygen/html/html/SVFIR_8cpp_source.html +43 -39
  28. package/SVF-doxygen/html/html/SVFIR_8h_source.html +41 -39
  29. package/SVF-doxygen/html/html/SVFStatements_8cpp_source.html +21 -20
  30. package/SVF-doxygen/html/html/SVFStatements_8h.html +2 -0
  31. package/SVF-doxygen/html/html/SVFStatements_8h_source.html +78 -62
  32. package/SVF-doxygen/html/html/SaberSVFGBuilder_8cpp_source.html +1 -1
  33. package/SVF-doxygen/html/html/SymbolTableBuilder_8cpp_source.html +13 -13
  34. package/SVF-doxygen/html/html/SymbolTableBuilder_8h_source.html +12 -12
  35. package/SVF-doxygen/html/html/TypeBasedHeapCloning_8cpp_source.html +1 -1
  36. package/SVF-doxygen/html/html/VFGNode_8h_source.html +5 -5
  37. package/SVF-doxygen/html/html/VFG_8cpp_source.html +42 -40
  38. package/SVF-doxygen/html/html/VFG_8h_source.html +26 -26
  39. package/SVF-doxygen/html/html/annotated.html +58 -57
  40. package/SVF-doxygen/html/html/classSVF_1_1AddrCGEdge.html +2 -2
  41. package/SVF-doxygen/html/html/classSVF_1_1AddrStmt-members.html +14 -13
  42. package/SVF-doxygen/html/html/classSVF_1_1AddrStmt.html +4 -3
  43. package/SVF-doxygen/html/html/classSVF_1_1Andersen.html +1 -1
  44. package/SVF-doxygen/html/html/classSVF_1_1AndersenBase.html +3 -3
  45. package/SVF-doxygen/html/html/classSVF_1_1AndersenStat.html +1 -1
  46. package/SVF-doxygen/html/html/classSVF_1_1ArgumentVFGNode.html +2 -2
  47. package/SVF-doxygen/html/html/classSVF_1_1AssignStmt-members.html +14 -13
  48. package/SVF-doxygen/html/html/classSVF_1_1AssignStmt.html +4 -3
  49. package/SVF-doxygen/html/html/classSVF_1_1BVDataPTAImpl.html +6 -6
  50. package/SVF-doxygen/html/html/classSVF_1_1BinaryOPStmt-members.html +30 -28
  51. package/SVF-doxygen/html/html/classSVF_1_1BinaryOPStmt.html +26 -22
  52. package/SVF-doxygen/html/html/classSVF_1_1BinaryOPVFGNode.html +2 -2
  53. package/SVF-doxygen/html/html/classSVF_1_1BranchStmt-members.html +16 -15
  54. package/SVF-doxygen/html/html/classSVF_1_1BranchStmt.html +41 -40
  55. package/SVF-doxygen/html/html/classSVF_1_1BranchVFGNode.html +4 -4
  56. package/SVF-doxygen/html/html/classSVF_1_1CallPE-members.html +14 -13
  57. package/SVF-doxygen/html/html/classSVF_1_1CallPE.html +6 -5
  58. package/SVF-doxygen/html/html/classSVF_1_1CmpStmt-members.html +30 -28
  59. package/SVF-doxygen/html/html/classSVF_1_1CmpStmt.html +27 -23
  60. package/SVF-doxygen/html/html/classSVF_1_1CmpVFGNode.html +2 -2
  61. package/SVF-doxygen/html/html/classSVF_1_1CondPTAImpl.html +1 -1
  62. package/SVF-doxygen/html/html/classSVF_1_1ConstraintGraph.html +79 -77
  63. package/SVF-doxygen/html/html/classSVF_1_1ConstraintNode-members.html +26 -26
  64. package/SVF-doxygen/html/html/classSVF_1_1ConstraintNode.html +43 -43
  65. package/SVF-doxygen/html/html/classSVF_1_1ContextDDA.html +1 -1
  66. package/SVF-doxygen/html/html/classSVF_1_1CopyStmt-members.html +14 -13
  67. package/SVF-doxygen/html/html/classSVF_1_1CopyStmt.html +4 -3
  68. package/SVF-doxygen/html/html/classSVF_1_1DDAClient.html +2 -2
  69. package/SVF-doxygen/html/html/classSVF_1_1DDAPass.html +3 -3
  70. package/SVF-doxygen/html/html/classSVF_1_1DDAStat.html +1 -1
  71. package/SVF-doxygen/html/html/classSVF_1_1DDAVFSolver.html +3 -3
  72. package/SVF-doxygen/html/html/classSVF_1_1FlowDDA.html +1 -1
  73. package/SVF-doxygen/html/html/classSVF_1_1FlowSensitiveStat.html +1 -1
  74. package/SVF-doxygen/html/html/classSVF_1_1FunptrDDAClient.html +1 -1
  75. package/SVF-doxygen/html/html/classSVF_1_1GenericNode.html +20 -21
  76. package/SVF-doxygen/html/html/classSVF_1_1GenericNode.png +0 -0
  77. package/SVF-doxygen/html/html/classSVF_1_1GepStmt-members.html +15 -14
  78. package/SVF-doxygen/html/html/classSVF_1_1GepStmt.html +6 -5
  79. package/SVF-doxygen/html/html/classSVF_1_1ICFG.html +4 -5
  80. package/SVF-doxygen/html/html/classSVF_1_1LoadStmt-members.html +14 -13
  81. package/SVF-doxygen/html/html/classSVF_1_1LoadStmt.html +6 -5
  82. package/SVF-doxygen/html/html/classSVF_1_1MRGenerator.html +1 -1
  83. package/SVF-doxygen/html/html/classSVF_1_1MTAAnnotator.html +1 -1
  84. package/SVF-doxygen/html/html/classSVF_1_1MTASVFGBuilder.html +1 -1
  85. package/SVF-doxygen/html/html/classSVF_1_1MultiOpndStmt-members.html +33 -31
  86. package/SVF-doxygen/html/html/classSVF_1_1MultiOpndStmt.html +66 -24
  87. package/SVF-doxygen/html/html/classSVF_1_1MultiOpndStmt.png +0 -0
  88. package/SVF-doxygen/html/html/classSVF_1_1OfflineConsG.html +4 -4
  89. package/SVF-doxygen/html/html/classSVF_1_1PAGBuilderFromFile.html +9 -10
  90. package/SVF-doxygen/html/html/classSVF_1_1PHIVFGNode.html +2 -2
  91. package/SVF-doxygen/html/html/classSVF_1_1PhiStmt-members.html +21 -16
  92. package/SVF-doxygen/html/html/classSVF_1_1PhiStmt.html +186 -73
  93. package/SVF-doxygen/html/html/classSVF_1_1PointerAnalysis.html +38 -40
  94. package/SVF-doxygen/html/html/classSVF_1_1RetPE-members.html +14 -13
  95. package/SVF-doxygen/html/html/classSVF_1_1RetPE.html +6 -5
  96. package/SVF-doxygen/html/html/classSVF_1_1SVFG-members.html +1 -1
  97. package/SVF-doxygen/html/html/classSVF_1_1SVFG.html +10 -10
  98. package/SVF-doxygen/html/html/classSVF_1_1SVFGBuilder.html +1 -1
  99. package/SVF-doxygen/html/html/classSVF_1_1SVFGOPT-members.html +1 -1
  100. package/SVF-doxygen/html/html/classSVF_1_1SVFGOPT.html +8 -8
  101. package/SVF-doxygen/html/html/classSVF_1_1SVFIR-members.html +177 -176
  102. package/SVF-doxygen/html/html/classSVF_1_1SVFIR.html +160 -90
  103. package/SVF-doxygen/html/html/classSVF_1_1SVFIRBuilder-members.html +36 -34
  104. package/SVF-doxygen/html/html/classSVF_1_1SVFIRBuilder.html +340 -223
  105. package/SVF-doxygen/html/html/classSVF_1_1SVFStmt-members.html +17 -16
  106. package/SVF-doxygen/html/html/classSVF_1_1SVFStmt.html +9 -5
  107. package/SVF-doxygen/html/html/classSVF_1_1SVFStmt.png +0 -0
  108. package/SVF-doxygen/html/html/classSVF_1_1SaberSVFGBuilder.html +3 -3
  109. package/SVF-doxygen/html/html/classSVF_1_1SelectStmt-members.html +154 -0
  110. package/SVF-doxygen/html/html/classSVF_1_1SelectStmt.html +704 -0
  111. package/SVF-doxygen/html/html/classSVF_1_1SelectStmt.png +0 -0
  112. package/SVF-doxygen/html/html/classSVF_1_1StmtVFGNode.html +2 -2
  113. package/SVF-doxygen/html/html/classSVF_1_1StoreStmt-members.html +17 -16
  114. package/SVF-doxygen/html/html/classSVF_1_1StoreStmt.html +6 -5
  115. package/SVF-doxygen/html/html/classSVF_1_1SymbolTableBuilder.html +39 -39
  116. package/SVF-doxygen/html/html/classSVF_1_1TDForkPE-members.html +17 -16
  117. package/SVF-doxygen/html/html/classSVF_1_1TDForkPE.html +15 -14
  118. package/SVF-doxygen/html/html/classSVF_1_1TDJoinPE-members.html +17 -16
  119. package/SVF-doxygen/html/html/classSVF_1_1TDJoinPE.html +15 -14
  120. package/SVF-doxygen/html/html/classSVF_1_1TypeAnalysis.html +2 -2
  121. package/SVF-doxygen/html/html/classSVF_1_1TypeBasedHeapCloning.html +1 -1
  122. package/SVF-doxygen/html/html/classSVF_1_1UnaryOPStmt-members.html +17 -16
  123. package/SVF-doxygen/html/html/classSVF_1_1UnaryOPStmt.html +29 -28
  124. package/SVF-doxygen/html/html/classSVF_1_1VFG-members.html +1 -1
  125. package/SVF-doxygen/html/html/classSVF_1_1VFG.html +61 -59
  126. package/SVF-doxygen/html/html/classSVF_1_1VersionedFlowSensitiveStat.html +1 -1
  127. package/SVF-doxygen/html/html/classes.html +70 -70
  128. package/SVF-doxygen/html/html/functions_a.html +12 -8
  129. package/SVF-doxygen/html/html/functions_b.html +4 -2
  130. package/SVF-doxygen/html/html/functions_c.html +31 -29
  131. package/SVF-doxygen/html/html/functions_eval_s.html +3 -0
  132. package/SVF-doxygen/html/html/functions_func.html +12 -8
  133. package/SVF-doxygen/html/html/functions_func_c.html +18 -17
  134. package/SVF-doxygen/html/html/functions_func_g.html +19 -6
  135. package/SVF-doxygen/html/html/functions_func_o.html +2 -1
  136. package/SVF-doxygen/html/html/functions_func_s.html +8 -5
  137. package/SVF-doxygen/html/html/functions_func_t.html +1 -0
  138. package/SVF-doxygen/html/html/functions_func_u.html +1 -0
  139. package/SVF-doxygen/html/html/functions_g.html +22 -9
  140. package/SVF-doxygen/html/html/functions_i.html +3 -3
  141. package/SVF-doxygen/html/html/functions_l.html +3 -3
  142. package/SVF-doxygen/html/html/functions_m.html +1 -1
  143. package/SVF-doxygen/html/html/functions_o.html +20 -13
  144. package/SVF-doxygen/html/html/functions_p.html +6 -6
  145. package/SVF-doxygen/html/html/functions_s.html +23 -17
  146. package/SVF-doxygen/html/html/functions_t.html +5 -4
  147. package/SVF-doxygen/html/html/functions_type_o.html +3 -0
  148. package/SVF-doxygen/html/html/functions_u.html +1 -0
  149. package/SVF-doxygen/html/html/functions_vars_c.html +3 -0
  150. package/SVF-doxygen/html/html/functions_vars_o.html +3 -0
  151. package/SVF-doxygen/html/html/hierarchy.html +55 -54
  152. package/SVF-doxygen/html/html/namespaceSVF.html +3 -1
  153. package/SVF-doxygen/html/html/search/all_1.js +4 -3
  154. package/SVF-doxygen/html/html/search/all_10.js +7 -7
  155. package/SVF-doxygen/html/html/search/all_12.js +1 -1
  156. package/SVF-doxygen/html/html/search/all_13.js +8 -6
  157. package/SVF-doxygen/html/html/search/all_14.js +4 -4
  158. package/SVF-doxygen/html/html/search/all_15.js +1 -1
  159. package/SVF-doxygen/html/html/search/all_16.js +1 -1
  160. package/SVF-doxygen/html/html/search/all_2.js +1 -1
  161. package/SVF-doxygen/html/html/search/all_3.js +3 -3
  162. package/SVF-doxygen/html/html/search/all_7.js +5 -1
  163. package/SVF-doxygen/html/html/search/all_9.js +1 -1
  164. package/SVF-doxygen/html/html/search/all_c.js +2 -2
  165. package/SVF-doxygen/html/html/search/all_d.js +1 -1
  166. package/SVF-doxygen/html/html/search/all_e.js +1 -1
  167. package/SVF-doxygen/html/html/search/all_f.js +3 -1
  168. package/SVF-doxygen/html/html/search/classes_f.js +1 -0
  169. package/SVF-doxygen/html/html/search/enumvalues_f.js +1 -0
  170. package/SVF-doxygen/html/html/search/functions_0.js +4 -3
  171. package/SVF-doxygen/html/html/search/functions_10.js +1 -0
  172. package/SVF-doxygen/html/html/search/functions_11.js +1 -1
  173. package/SVF-doxygen/html/html/search/functions_12.js +1 -1
  174. package/SVF-doxygen/html/html/search/functions_2.js +1 -1
  175. package/SVF-doxygen/html/html/search/functions_6.js +5 -1
  176. package/SVF-doxygen/html/html/search/functions_d.js +1 -1
  177. package/SVF-doxygen/html/html/search/functions_e.js +1 -1
  178. package/SVF-doxygen/html/html/search/typedefs_e.js +1 -0
  179. package/SVF-doxygen/html/html/search/variables_14.js +1 -1
  180. package/SVF-doxygen/html/html/search/variables_3.js +1 -0
  181. package/SVF-doxygen/html/html/search/variables_e.js +1 -1
  182. package/SVF-doxygen/html/html/search/variables_f.js +1 -0
  183. package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01ConstraintGraph_01_5_01_4.html +16 -16
  184. package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01ICFG_01_5_01_4.html +16 -16
  185. package/SVF-doxygen/html/html/structllvm_1_1DOTGraphTraits_3_01VFG_01_5_01_4.html +18 -18
  186. package/include/Graphs/VFG.h +1 -1
  187. package/include/MemoryModel/SVFIR.h +3 -1
  188. package/include/MemoryModel/SVFStatements.h +76 -4
  189. package/include/SVF-FE/SVFIRBuilder.h +12 -2
  190. package/lib/Graphs/ConsG.cpp +9 -0
  191. package/lib/Graphs/ICFG.cpp +12 -17
  192. package/lib/Graphs/VFG.cpp +9 -0
  193. package/lib/MemoryModel/PAGBuilderFromFile.cpp +3 -1
  194. package/lib/MemoryModel/PointerAnalysis.cpp +0 -3
  195. package/lib/MemoryModel/SVFIR.cpp +24 -3
  196. package/lib/MemoryModel/SVFStatements.cpp +14 -0
  197. package/lib/SVF-FE/SVFIRBuilder.cpp +55 -13
  198. package/lib/SVF-FE/SymbolTableBuilder.cpp +1 -0
  199. package/package.json +1 -1
@@ -74,6 +74,15 @@ void ConstraintGraph::buildCG()
74
74
  addCopyCGEdge(opVar->getId(),edge->getResID());
75
75
  }
76
76
 
77
+ SVFStmt::SVFStmtSetTy& selects = getPAGEdgeSet(SVFStmt::Select);
78
+ for (SVFStmt::SVFStmtSetTy::iterator iter = selects.begin(), eiter =
79
+ selects.end(); iter != eiter; ++iter)
80
+ {
81
+ const SelectStmt* edge = SVFUtil::cast<SelectStmt>(*iter);
82
+ for(const auto opVar : edge->getOpndVars())
83
+ addCopyCGEdge(opVar->getId(),edge->getResID());
84
+ }
85
+
77
86
  SVFStmt::SVFStmtSetTy& calls = getPAGEdgeSet(SVFStmt::Call);
78
87
  for (SVFStmt::SVFStmtSetTy::iterator iter = calls.begin(), eiter =
79
88
  calls.end(); iter != eiter; ++iter)
@@ -436,25 +436,20 @@ void ICFG::updateCallGraph(PTACallGraph* callgraph)
436
436
  for (PTACallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
437
437
  {
438
438
  const SVFFunction* callee = *func_iter;
439
- CallICFGNode* callICFGNode = getCallICFGNode(cs);
439
+ CallICFGNode* callBlockNode = getCallICFGNode(cs);
440
440
  RetICFGNode* retBlockNode = getRetICFGNode(cs);
441
- /// if this is an external function (no function body or specified in ExAPI.cpp)
441
+ FunEntryICFGNode* calleeEntryNode = getFunEntryBlock(callee);
442
+ FunExitICFGNode* calleeExitNode = getFunExitBlock(callee);
443
+ addCallEdge(callBlockNode, calleeEntryNode, cs);
444
+ addRetEdge(calleeExitNode, retBlockNode, cs);
445
+
446
+ /// if this is an external function (no function body), connect calleeEntryNode to calleeExitNode
442
447
  if (isExtCall(callee))
443
- {
444
- addIntraEdge(callICFGNode, retBlockNode);
445
- }
446
- /// otherwise connect interprocedural edges
447
- else
448
- {
449
- FunEntryICFGNode* calleeEntryNode = getFunEntryICFGNode(callee);
450
- FunExitICFGNode* calleeExitNode = getFunExitICFGNode(callee);
451
- addCallEdge(callICFGNode, calleeEntryNode, cs);
452
- addRetEdge(calleeExitNode, retBlockNode, cs);
453
-
454
- /// Remove callBlockNode to retBlockNode intraICFGEdge since we found at least one inter procedural edge
455
- if(ICFGEdge* edge = hasIntraICFGEdge(callICFGNode,retBlockNode, ICFGEdge::IntraCF))
456
- removeICFGEdge(edge);
457
- }
448
+ addIntraEdge(calleeEntryNode, calleeExitNode);
449
+
450
+ /// Remove callBlockNode to retBlockNode intraICFGEdge since we found at least one inter procedural edge
451
+ if(ICFGEdge* edge = hasIntraICFGEdge(callBlockNode,retBlockNode, ICFGEdge::IntraCF))
452
+ removeICFGEdge(edge);
458
453
  }
459
454
  }
460
455
  // dump ICFG
@@ -489,6 +489,15 @@ void VFG::addVFGNodes()
489
489
  if(isInterestedPAGNode(edge->getRes()))
490
490
  addIntraPHIVFGNode(edge);
491
491
  }
492
+ // initialize select statement
493
+ SVFStmt::SVFStmtSetTy& selects = getPAGEdgeSet(SVFStmt::Select);
494
+ for (SVFStmt::SVFStmtSetTy::iterator iter = selects.begin(), eiter =
495
+ selects.end(); iter != eiter; ++iter)
496
+ {
497
+ const MultiOpndStmt* edge = SVFUtil::cast<MultiOpndStmt>(*iter);
498
+ if(isInterestedPAGNode(edge->getRes()))
499
+ addIntraPHIVFGNode(edge);
500
+ }
492
501
  // initialize llvm binary nodes (binary operators)
493
502
  SVFStmt::SVFStmtSetTy& binaryops = getPAGEdgeSet(SVFStmt::BinaryOp);
494
503
  for (SVFStmt::SVFStmtSetTy::iterator iter = binaryops.begin(), eiter =
@@ -183,7 +183,9 @@ void PAGBuilderFromFile::addEdge(NodeID srcID, NodeID dstID,
183
183
  else if (edge == "unary-op")
184
184
  pag->addUnaryOPStmt(srcID, dstID, dstID);
185
185
  else if (edge == "phi")
186
- pag->addPhiStmt(srcID, dstID);
186
+ assert(false && "fix phi here!");
187
+ else if (edge == "select")
188
+ assert(false && "fix select here!");
187
189
  else if (edge == "branch"){
188
190
  assert(false && "fix successors here!");
189
191
  //pag->addBranchStmt(srcID, dstID, nullptr);
@@ -204,9 +204,6 @@ void PointerAnalysis::finalize()
204
204
  dumpStat();
205
205
 
206
206
  SVFIR* pag = SVFIR::getPAG();
207
- // dump SVFIR
208
- if (Options::PAGDotGraph)
209
- pag->dump("pag_final");
210
207
 
211
208
  /// Dump results
212
209
  if (Options::PTSPrint)
@@ -84,24 +84,45 @@ CopyStmt* SVFIR::addCopyStmt(NodeID src, NodeID dst)
84
84
  /*!
85
85
  * Add Phi statement
86
86
  */
87
- PhiStmt* SVFIR::addPhiStmt(NodeID res, NodeID opnd)
87
+ PhiStmt* SVFIR::addPhiStmt(NodeID res, NodeID opnd, const ICFGNode* pred)
88
88
  {
89
89
  SVFVar* opNode = getGNode(opnd);
90
90
  SVFVar* resNode = getGNode(res);
91
91
  PHINodeMap::iterator it = phiNodeMap.find(resNode);
92
92
  if(it == phiNodeMap.end()){
93
- PhiStmt* phi = new PhiStmt(resNode, {opNode});
93
+ PhiStmt* phi = new PhiStmt(resNode, {opNode}, {pred});
94
94
  addToStmt2TypeMap(phi);
95
95
  addEdge(opNode, resNode, phi);
96
96
  phiNodeMap[resNode] = phi;
97
97
  return phi;
98
98
  }
99
99
  else{
100
- it->second->addOpVar(opNode);
100
+ it->second->addOpVar(opNode,pred);
101
101
  return it->second;
102
102
  }
103
103
  }
104
104
 
105
+ /*!
106
+ * Add Phi statement
107
+ */
108
+ SelectStmt* SVFIR::addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
109
+ {
110
+ SVFVar* op1Node = getGNode(op1);
111
+ SVFVar* op2Node = getGNode(op2);
112
+ SVFVar* dstNode = getGNode(res);
113
+ SVFVar* condNode = getGNode(cond);
114
+ if(SVFStmt* edge = hasLabeledEdge(op1Node, dstNode, SVFStmt::Select, op2Node))
115
+ return SVFUtil::cast<SelectStmt>(edge);
116
+ else
117
+ {
118
+ std::vector<SVFVar*> opnds = {op1Node, op2Node};
119
+ SelectStmt* select = new SelectStmt(dstNode, opnds, condNode);
120
+ addToStmt2TypeMap(select);
121
+ addEdge(op1Node, dstNode, select);
122
+ return select;
123
+ }
124
+ }
125
+
105
126
  /*!
106
127
  * Add Compare edge
107
128
  */
@@ -101,6 +101,20 @@ const std::string PhiStmt::toString() const{
101
101
  return rawstr.str();
102
102
  }
103
103
 
104
+ const std::string SelectStmt::toString() const{
105
+ std::string str;
106
+ raw_string_ostream rawstr(str);
107
+ rawstr << "SelectStmt: (Condition Var" << getCondition()->getId() << ") [Var" << getResID() << " <-- (Var";
108
+ for(const SVFVar* op : getOpndVars())
109
+ rawstr << op->getId() << ",";
110
+ rawstr << ")]\t";
111
+ if (Options::ShowSVFIRValue) {
112
+ rawstr << "\n";
113
+ rawstr << value2String(getValue());
114
+ }
115
+ return rawstr.str();
116
+ }
117
+
104
118
  const std::string CmpStmt::toString() const{
105
119
  std::string str;
106
120
  raw_string_ostream rawstr(str);
@@ -369,11 +369,11 @@ void SVFIRBuilder::processCE(const Value *val)
369
369
  const Value* cval = getCurrentValue();
370
370
  const BasicBlock* cbb = getCurrentBB();
371
371
  setCurrentLocation(selectce, nullptr);
372
+ NodeID cond = pag->getValueNode(selectce->getOperand(0));
372
373
  NodeID nsrc1 = pag->getValueNode(src1);
373
374
  NodeID nsrc2 = pag->getValueNode(src2);
374
375
  NodeID nres = pag->getValueNode(selectce);
375
- addPhiStmt(nres,nsrc1);
376
- addPhiStmt(nres,nsrc2);
376
+ addSelectStmt(nres,nsrc1, nsrc2, cond);
377
377
  setCurrentLocation(cval, cbb);
378
378
  }
379
379
  // if we meet a int2ptr, then it points-to black hole
@@ -629,9 +629,10 @@ void SVFIRBuilder::visitPHINode(PHINode &inst)
629
629
  const Value* val = inst.getIncomingValue(i);
630
630
  const Instruction* incomingInst = SVFUtil::dyn_cast<Instruction>(val);
631
631
  assert((incomingInst==nullptr) || (incomingInst->getFunction() == inst.getFunction()));
632
-
632
+ const Instruction* predInst = &inst.getIncomingBlock(i)->front();
633
+ const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(predInst);
633
634
  NodeID src = getValueNode(val);
634
- addPhiStmt(dst,src);
635
+ addPhiStmt(dst,src,icfgNode);
635
636
  }
636
637
  }
637
638
 
@@ -772,10 +773,9 @@ void SVFIRBuilder::visitSelectInst(SelectInst &inst)
772
773
  NodeID dst = getValueNode(&inst);
773
774
  NodeID src1 = getValueNode(inst.getTrueValue());
774
775
  NodeID src2 = getValueNode(inst.getFalseValue());
775
-
776
+ NodeID cond = getValueNode(inst.getCondition());
776
777
  /// Two operands have same incoming basic block, both are the current BB
777
- addPhiStmt(dst,src1);
778
- addPhiStmt(dst,src2);
778
+ addSelectStmt(dst,src1,src2, cond);
779
779
  }
780
780
 
781
781
  /*
@@ -841,8 +841,9 @@ void SVFIRBuilder::visitReturnInst(ReturnInst &inst)
841
841
 
842
842
  NodeID rnF = getReturnNode(F);
843
843
  NodeID vnS = getValueNode(src);
844
+ const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(&inst);
844
845
  //vnS may be null if src is a null ptr
845
- addPhiStmt(rnF,vnS);
846
+ addPhiStmt(rnF,vnS,icfgNode);
846
847
  }
847
848
  }
848
849
 
@@ -892,7 +893,7 @@ void SVFIRBuilder::visitBranchInst(BranchInst &inst){
892
893
  BranchStmt::SuccAndCondPairVec successors;
893
894
  for (u32_t i = 0; i < inst.getNumSuccessors(); ++i)
894
895
  {
895
- const Instruction* succInst = &inst.getSuccessor(i)->front();
896
+ const Instruction* succInst = &inst.getSuccessor(i)->back();
896
897
  const ICFGNode* icfgNode = pag->getICFG()->getICFGNode(succInst);
897
898
  successors.push_back(std::make_pair(icfgNode, 1-i));
898
899
  }
@@ -1635,12 +1636,16 @@ void SVFIRBuilder::setCurrentBBAndValueForPAGEdge(PAGEdge* edge)
1635
1636
  assert(curBB && "instruction does not have a basic block??");
1636
1637
 
1637
1638
  /// We will have one unique function exit ICFGNode for all returns
1638
- if(const ReturnInst* retInst = SVFUtil::dyn_cast<ReturnInst>(curVal)){
1639
+ if(const ReturnInst* retInst = SVFUtil::dyn_cast<ReturnInst>(curInst)){
1639
1640
  const SVFFunction *fun = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(retInst->getParent()->getParent());
1640
1641
  icfgNode = pag->getICFG()->getFunExitICFGNode(fun);
1641
1642
  }
1642
- else
1643
- icfgNode = pag->getICFG()->getICFGNode(curInst);
1643
+ else{
1644
+ if(SVFUtil::isa<RetPE>(edge))
1645
+ icfgNode = pag->getICFG()->getRetICFGNode(curInst);
1646
+ else
1647
+ icfgNode = pag->getICFG()->getICFGNode(curInst);
1648
+ }
1644
1649
  }
1645
1650
  else if (const Argument* arg = SVFUtil::dyn_cast<Argument>(curVal))
1646
1651
  {
@@ -1656,12 +1661,20 @@ void SVFIRBuilder::setCurrentBBAndValueForPAGEdge(PAGEdge* edge)
1656
1661
  icfgNode = pag->getICFG()->getICFGNode(&curBB->front());
1657
1662
  }
1658
1663
  else if (SVFUtil::isa<GlobalVariable>(curVal) ||
1659
- SVFUtil::isa<Function>(curVal) ||
1660
1664
  SVFUtil::isa<Constant>(curVal) ||
1661
1665
  SVFUtil::isa<MetadataAsValue>(curVal))
1662
1666
  {
1663
1667
  pag->addGlobalPAGEdge(edge);
1664
1668
  }
1669
+ else if(const Function* fun = SVFUtil::dyn_cast<Function>(curVal)){
1670
+ const SVFFunction* f = LLVMModuleSet::getLLVMModuleSet()->getSVFFunction(fun);
1671
+ if((&fun->getEntryBlock() == curBB) && isExtCall(f)){
1672
+ /// all external function connected to a indirect call, we will put SVFStmts in the FunctionEntryICFGNode
1673
+ icfgNode = pag->getICFG()->getFunEntryICFGNode(f);
1674
+ }
1675
+ else
1676
+ pag->addGlobalPAGEdge(edge);
1677
+ }
1665
1678
  else
1666
1679
  {
1667
1680
  assert(false && "what else value can we have?");
@@ -1693,3 +1706,32 @@ u32_t SVFIRBuilder::getFields(std::vector<LocationSet>& fields, const Type* T, u
1693
1706
 
1694
1707
  return sz;
1695
1708
  }
1709
+
1710
+
1711
+ void SVFIRBuilder::updateCallGraph(PTACallGraph* callgraph){
1712
+ PTACallGraph::CallEdgeMap::const_iterator iter = callgraph->getIndCallMap().begin();
1713
+ PTACallGraph::CallEdgeMap::const_iterator eiter = callgraph->getIndCallMap().end();
1714
+ for (; iter != eiter; iter++)
1715
+ {
1716
+ const CallICFGNode* callBlock = iter->first;
1717
+ CallSite cs = getLLVMCallSite(callBlock->getCallSite());
1718
+ assert(callBlock->isIndirectCall() && "this is not an indirect call?");
1719
+ const PTACallGraph::FunctionSet & functions = iter->second;
1720
+ for (PTACallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++)
1721
+ {
1722
+ const SVFFunction* callee = *func_iter;
1723
+ if (isExtCall(callee)){
1724
+ setCurrentLocation(callee->getLLVMFun(), &callee->getLLVMFun()->getEntryBlock());
1725
+ handleExtCall(cs, callee);
1726
+ }
1727
+ else{
1728
+ setCurrentLocation(callBlock->getCallSite(), callBlock->getCallSite()->getParent());
1729
+ handleDirectCall(cs, callee);
1730
+ }
1731
+ }
1732
+ }
1733
+
1734
+ // dump SVFIR
1735
+ if (Options::PAGDotGraph)
1736
+ pag->dump("svfir_final");
1737
+ }
@@ -130,6 +130,7 @@ void SymbolTableBuilder::buildMemModel(SVFModule* svfModule)
130
130
  {
131
131
  collectSym(sel->getTrueValue());
132
132
  collectSym(sel->getFalseValue());
133
+ collectSym(sel->getCondition());
133
134
  }
134
135
  else if (const BinaryOperator *binary = SVFUtil::dyn_cast<BinaryOperator>(inst))
135
136
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-tools",
3
- "version": "1.0.362",
3
+ "version": "1.0.366",
4
4
  "description": "* <b>[TypeClone](https://github.com/SVF-tools/SVF/wiki/TypeClone) published in our [ECOOP paper](https://yuleisui.github.io/publications/ecoop20.pdf) is now available in SVF </b> * <b>SVF now uses a single script for its build. Just type [`source ./build.sh`](https://github.com/SVF-tools/SVF/blob/master/build.sh) in your terminal, that's it!</b> * <b>SVF now supports LLVM-10.0.0! </b> * <b>We thank [bsauce](https://github.com/bsauce) for writing a user manual of SVF ([link1](https://www.jianshu.com/p/068a08ec749c) and [link2](https://www.jianshu.com/p/777c30d4240e)) in Chinese </b> * <b>SVF now supports LLVM-9.0.0 (Thank [Byoungyoung Lee](https://github.com/SVF-tools/SVF/issues/142) for his help!). </b> * <b>SVF now supports a set of [field-sensitive pointer analyses](https://yuleisui.github.io/publications/sas2019a.pdf). </b> * <b>[Use SVF as an external lib](https://github.com/SVF-tools/SVF/wiki/Using-SVF-as-a-lib-in-your-own-tool) for your own project (Contributed by [Hongxu Chen](https://github.com/HongxuChen)). </b> * <b>SVF now supports LLVM-7.0.0. </b> * <b>SVF now supports Docker. [Try SVF in Docker](https://github.com/SVF-tools/SVF/wiki/Try-SVF-in-Docker)! </b> * <b>SVF now supports [LLVM-6.0.0](https://github.com/svf-tools/SVF/pull/38) (Contributed by [Jack Anthony](https://github.com/jackanth)). </b> * <b>SVF now supports [LLVM-4.0.0](https://github.com/svf-tools/SVF/pull/23) (Contributed by Jared Carlson. Thank [Jared](https://github.com/jcarlson23) and [Will](https://github.com/dtzWill) for their in-depth [discussions](https://github.com/svf-tools/SVF/pull/18) about updating SVF!) </b> * <b>SVF now supports analysis for C++ programs.</b> <br />",
5
5
  "main": "index.js",
6
6
  "scripts": {