ClearBlue
SymbolicExprGraph.h
1 /*
2  * Developed by Qingkai Shi, Fan Gang
3  * Copy Right by Prism Research Group, HKUST and State Key Lab for Novel
4  * Software Tech., Nanjing University.
5  */
6 
7 #ifndef SYMBOLIC_EXPR_GRAPH_H
8 #define SYMBOLIC_EXPR_GRAPH_H
9 
10 #include <llvm/IR/BasicBlock.h>
11 #include <llvm/IR/CallSite.h>
12 #include <llvm/IR/Constants.h>
13 #include <llvm/IR/Function.h>
14 #include <llvm/IR/InstIterator.h>
15 #include <llvm/IR/Instructions.h>
16 #include <llvm/IR/Value.h>
17 
18 #include <llvm/Support/Casting.h>
19 #include <llvm/Support/FileSystem.h>
20 #include <llvm/Support/Format.h>
21 #include <llvm/Support/raw_ostream.h>
22 
23 #include <map>
24 #include <set>
25 #include <unordered_map>
26 #include <unordered_set>
27 #include <vector>
28 
29 #include "Analysis/Alias/PathSensitiveAADriver/ProgramVal.h"
30 #include "IR/SEG/SEGValue.h"
31 #include "Transform/ValueComparator.h"
32 #include "Utils/ADT/MapIterators.h"
33 #include "Utils/ADT/kvec.h"
34 
35 using namespace llvm;
36 
37 class SEGCallSite;
43 
44 class SEGOpcodeNode;
45 class SEGOperandNode;
46 class SEGRegionNode;
47 class SEGPhiNode;
48 class SEGLoadMemNode;
49 class SEGStoreMemNode;
50 
51 class SEGReturnNode;
54 
55 class SEGArgumentNode;
58 class SEGVarArgumentNode;
59 
60 class SEGCastNode;
63 
64 class SEGSiteBase;
65 
66 class SymbolicExprGraph;
68 class OCValueFlowBuilder;
69 
70 class SEGOptions {
71 public:
72  static bool EnableValueToString;
73  static bool EnableArithmeticFlow;
74 };
75 
76 class SEGObject {
77  friend class SEGSerializer;
78  friend class SEGHash;
79 
80 public:
81  enum SEGObjectKind {
82  // nodes
83  SEGOBJK_NodeBegin,
84  // operand nodes
85  SEGOBJK_OperandBegin,
86 
87  SEGOBJK_ArgumentBegin,
88  SEGOBJK_CommonArgument,
89  SEGOBJK_VarArgument,
90  SEGOBJK_PseudoArgument,
91  SEGOBJK_ArgumentEnd,
92 
93  SEGOBJK_CallSiteOutputBegin,
94  SEGOBJK_CallSiteCommonOutput,
95  SEGOBJK_CallSitePseudoOutput,
96  SEGOBJK_CallSiteOutputEnd,
97 
98  SEGOBJK_ReturnBegin,
99  SEGOBJK_CommonReturn,
100  SEGOBJK_PseudoReturn,
101  SEGOBJK_ReturnEnd,
102 
103  SEGOBJK_LoadMem,
104  SEGOBJK_StoreMem,
105  SEGOBJK_Phi,
106  SEGOBJK_Region,
107  SEGOBJK_SimpleOperand,
108  SEGOBJK_Undef,
109  SEGOBJK_CallSitePseudoInput,
110  SEGOBJK_CallSiteSummaryArgument,
111  SEGOBJK_CallSiteSummaryReturn,
112 
113  SEGOBJK_OperandEnd,
114 
115  // opcode nodes
116  SEGOBJK_OpcodeBegin,
117  SEGOBJK_BinaryWithIntConst,
118  SEGOBJK_Cast,
119  SEGOBJK_SimpleOpcode,
120  SEGOBJK_OpcodeEnd,
121 
122  SEGOBJK_NodeEnd,
123 
124  // use sites
125  SEGOBJK_SiteBegin,
126 
127  SEGOBJK_CallSite,
128  SEGOBJK_ReturnSite,
129 
130  SEGOBJK_SimpleSiteBegin,
131  SEGOBJK_GEPSite,
132  SEGOBJK_DereferenceSite,
133  SEGOBJK_DivSite,
134  SEGOBJK_CmpSite,
135  SEGOBJK_AllocSite,
136  SEGOBJK_SimpleSiteEnd,
137 
138  SEGOBJK_SiteEnd,
139  };
140 
141 private:
142  const SEGObjectKind ObjKind;
143 
145  SymbolicExprGraph *ParentGraph;
146 
148  BasicBlock *ParentBasicBlock = nullptr;
149 
150  // Index of this SEGObject
151  int64_t ObjIndex = -1;
152 
153  // Index of this SEG
154  int64_t SEGIndex = -1;
155 
156 protected:
157 public:
158  SEGObject(SEGObjectKind OK, SymbolicExprGraph *SEG, BasicBlock *BB,
159  bool fromDisk);
160 
161  virtual ~SEGObject() = 0;
162 
163  // getLLVMDbgValue and getLLVMDbgInstruction are used for printing human
164  // readable info for SEGObjects This design is to eliminate the enumerating of
165  // SEG object types to print the required corresponding info for SEGObjects We
166  // try best to collect such info, For example, for callsite output nodes, if
167  // we want to distinguish the output values, we can use getLLVMDbgValue to get
168  // the value if we want to get the line number in the source code, we can use
169  // getLLVMDbgInstruction This function returns the callsite instruction
170  // containing the output node, which can be used to get the line number to
171  // find the callsite
172  //
173  // getLLVMDbgValue and getLLVMDbgInstruction are virtual functions in
174  // SEGObject. Thus, we can use them on each node in SEG, to print human
175  // readable debug info and still eliminate enumerating SEG Object types
176 
177  // Try best to collect the llvm value corresponding to the SEGObject
178  // For printing human readable Debug info relative to values
179  // SEGOperandNode : the value of the node
180  // SEGSite : the instruction
181  // Default : null
182  virtual Value *getLLVMDbgValue() const { return nullptr; }
183 
184  // Try best to collect the llvm instruction corresponding to the SEGObject
185  // For printing human readable Debug info requiring instructions
186  // In detail,
187  // For callsite pseudo-output nodes, we return the callsite
188  // For store mem node, we return the store site
189  // Otherwise, we return the instruction for the value if value exists or
190  // otherwise return null
191  virtual Instruction *getLLVMDbgInstruction() const {
192  Value *val = getLLVMDbgValue();
193  if (val != nullptr) {
194  return dyn_cast<Instruction>(val);
195  }
196 
197  return nullptr;
198  }
199 
200  SEGObjectKind getKind() const { return ObjKind; }
201 
202  int64_t getSEGIndex() const {
203  assert(SEGIndex != -1 && "Index should not be -1");
204  return SEGIndex;
205  }
206 
207  void setObjIndex(int64_t index) { ObjIndex = index; }
208 
209  int64_t getObjIndex() const {
210  assert(ObjIndex != -1 && "Index should not be -1");
211  return ObjIndex;
212  }
213 
214  const char *getKindName() const;
215 
216  BasicBlock *getParentBasicBlock() const { return ParentBasicBlock; }
217 
218  Function *getParentFunction() const { return ParentBasicBlock->getParent(); }
219 
220  const SymbolicExprGraph *getParentGraph() const { return ParentGraph; }
221  SymbolicExprGraph *getParentGraph() { return ParentGraph; }
222 
223  friend raw_ostream &operator<<(llvm::raw_ostream &Out, const SEGObject &N);
224 };
225 
226 struct seg_cmp {
227  LLVMValueIndexer *instance;
228  seg_cmp() : instance(LLVMValueIndexer::get()) {}
229 
230  bool operator()(const SEGObject *A, const SEGObject *B) const {
231  int64_t indexSEGA = A ? A->getSEGIndex() : -1;
232  int64_t indexSEGB = B ? B->getSEGIndex() : -1;
233  if (indexSEGA != indexSEGB || (indexSEGA == -1 && indexSEGB == -1)) {
234  return indexSEGA < indexSEGB;
235  } else {
236  int64_t indexA = A ? A->getObjIndex() : -1;
237  int64_t indexB = B ? B->getObjIndex() : -1;
238  return indexA < indexB;
239  }
240  }
241 };
242 
244 class SEGNodeBase : public SEGObject {
245  friend class SEGSerializer;
246  friend class SEGHash;
247 
248 protected:
252  SEGNodeBase(SEGObjectKind K, Type *Ty, SymbolicExprGraph *SEG, BasicBlock *BB,
253  bool fromDisk);
254 
255  void setDescription(std::string &Desc) { Description = Desc; }
256 
257  friend class SymbolicExprGraph;
258 
259 private:
260  // This is useful for debugging
261  std::string Description;
262 
265  std::vector<SEGNodeBase *> Children;
266 
268  std::map<const SEGNodeBase *, float, seg_cmp> Parents;
269 
271  std::vector<SEGSiteBase *> UseSites;
272  std::set<SEGSiteBase *> UseSiteSet;
273 
275  Type *LLVMType = nullptr;
276 
278  SEGRegionNode *Region = nullptr;
279 
280 public:
281  virtual ~SEGNodeBase() {}
282 
284  Type *getLLVMType() const { return LLVMType; }
285 
286  SEGNodeBase *getChild(unsigned I) const {
287  assert(Children.size() > I &&
288  "Invalid child index when querying SEG edges");
289  return Children[I];
290  }
291 
292  float getConfidence(const SEGNodeBase *ParentNode) const {
293  auto It = Parents.find(ParentNode);
294  assert(It != Parents.end() &&
295  "Invalid parent node when querying SEG edges");
296  return It->second;
297  }
298 
299  unsigned getNumChildren() const { return Children.size(); }
300 
301  unsigned getNumParents() const { return Parents.size(); }
302 
303  void addChild(SEGNodeBase *N, float Confidence = 1.0f) {
304  Children.push_back(N);
305  N->Parents.insert(std::make_pair(this, Confidence));
306  }
307 
308  void eraseAllChildren() {
309  for (auto *Child : Children) {
310  Child->Parents.erase(this);
311  }
312  Children.clear();
313  }
314 
315  void addUseSite(SEGSiteBase *U) {
316  if (!UseSiteSet.count(U)) {
317  UseSiteSet.insert(U);
318  UseSites.push_back(U);
319  }
320  }
321 
322  virtual bool isTerminalNode() const { return Children.empty(); }
323 
324  SEGRegionNode *getRegion() const;
325 
326  bool containsParentNode(const SEGNodeBase *N) const {
327  return Parents.count(N);
328  }
329 
330  const std::string &getDescription() const { return Description; }
331 
333  virtual void dot(raw_fd_ostream &O) const = 0;
334 
335  friend raw_ostream &operator<<(llvm::raw_ostream &Out, const SEGNodeBase &N);
336 
337  /*==-------Iterators------==*/
339  private:
340  const SEGNodeBase *Node;
341  key_iterator<std::map<const SEGNodeBase *, float>::const_iterator> It;
342 
343  public:
344  ValueFlowIterator(const SEGNodeBase *N, bool End) : Node(N) {
345  if (End) {
346  It = N->parent_end();
347  } else {
348  It = N->parent_begin();
349  increment();
350  }
351  }
352 
354  : Node(VFIt.Node), It(VFIt.It) {}
355 
356  ValueFlowIterator &operator=(const ValueFlowIterator &VFIt) {
357  if (this != &VFIt) {
358  this->Node = VFIt.Node;
359  this->It = VFIt.It;
360  }
361  return *this;
362  }
363 
364  ValueFlowIterator operator++(int) {
365  ValueFlowIterator Old(*this);
366  ++(*this);
367  return Old;
368  }
369 
370  ValueFlowIterator &operator++() {
371  It++;
372  increment();
373  return *this;
374  }
375 
376  const SEGNodeBase *operator*() { return *It; }
377 
378  bool operator==(const ValueFlowIterator &VFIt) { return It == VFIt.It; }
379 
380  bool operator!=(const ValueFlowIterator &VFIt) { return It != VFIt.It; }
381 
382  private:
383  void increment();
384  };
385 
386  ValueFlowIterator vflow_begin() const { return {this, false}; }
387 
388  ValueFlowIterator vflow_end() const { return {this, true}; }
389 
390  key_iterator<std::map<const SEGNodeBase *, float>::const_iterator>
391  parent_begin() const {
392  return {Parents.begin()};
393  }
394 
395  key_iterator<std::map<const SEGNodeBase *, float>::const_iterator>
396  parent_end() const {
397  return {Parents.end()};
398  }
399 
400  iterator_range<std::map<const SEGNodeBase *, float>::const_iterator>
401  parents() const {
402  return {Parents.begin(), Parents.end()};
403  }
404 
405  std::vector<SEGNodeBase *>::const_iterator child_begin() const {
406  return Children.begin();
407  }
408 
409  std::vector<SEGNodeBase *>::const_iterator child_end() const {
410  return Children.end();
411  }
412 
413  iterator_range<std::vector<SEGNodeBase *>::const_iterator> children() const {
414  return {Children.begin(), Children.end()};
415  }
416 
417  std::map<const SEGNodeBase *, float>::const_iterator
418  parent_confidence_begin() const {
419  return key_iterator<std::map<const SEGNodeBase *, float>::const_iterator>(
420  Parents.begin());
421  }
422 
423  std::map<const SEGNodeBase *, float>::const_iterator
424  parent_confidence_end() const {
425  return key_iterator<std::map<const SEGNodeBase *, float>::const_iterator>(
426  Parents.end());
427  }
428 
429  size_t child_size() const { return Children.size(); }
430 
431  size_t parent_size() const { return Parents.size(); }
432 
433  std::vector<SEGSiteBase *>::const_iterator use_site_begin() const {
434  return UseSites.begin();
435  }
436 
437  std::vector<SEGSiteBase *>::const_iterator use_site_end() const {
438  return UseSites.end();
439  }
440 
441  iterator_range<std::vector<SEGSiteBase *>::const_iterator> use_sites() {
442  return {UseSites.begin(), UseSites.end()};
443  };
444 
445  size_t use_site_size() const { return UseSites.size(); }
446 
447 public:
448  static bool classof(const SEGObject *N) {
449  return N->getKind() >= SEGOBJK_NodeBegin && N->getKind() <= SEGOBJK_NodeEnd;
450  }
451 };
452 
456 class SEGOperandNode : public SEGNodeBase {
457 protected:
460  Value *LLVMValue = nullptr;
461 
462  SEGValue *segValue = nullptr;
463 
465  SEGOperandNode(SEGObjectKind K, Type *Ty, SymbolicExprGraph *SEG,
466  BasicBlock *BB, bool fromDisk);
467 
479  SEGOperandNode(SEGObjectKind K, Value *Val, Type *Ty, SymbolicExprGraph *SEG,
480  BasicBlock *BB, bool fromDisk);
481 
483  friend class SymbolicExprGraph;
484  friend class SEGHash;
485 
486 public:
487  virtual ~SEGOperandNode() = 0;
488 
489  Value *getLLVMValue() const { return LLVMValue; }
490 
491  SEGValue *getSEGValue() const { return segValue; }
492 
493  void dot(raw_fd_ostream &O) const override;
494 
495  friend raw_ostream &operator<<(llvm::raw_ostream &Out,
496  const SEGOperandNode &N) {
497  if (Value *Val = N.getLLVMValue()) {
498  Out << *Val;
499  } else {
500  Out << N.getDescription();
501  }
502  return Out;
503  }
504 
505  virtual Value *getLLVMDbgValue() const override { return getLLVMValue(); }
506 
507 public:
508  static bool classof(const SEGObject *N) {
509  return N->getKind() >= SEGOBJK_OperandBegin &&
510  N->getKind() <= SEGOBJK_OperandEnd;
511  }
512 
513 private:
514  void initialize(Value *Val);
515 };
516 
519 class SEGOpcodeNode : public SEGNodeBase {
520 
521 public:
522  enum CodeKind {
523  CK_BinaryBegin,
524  CK_URem = CK_BinaryBegin,
525  CK_FRem,
526  CK_SRem,
527  CK_UDiv,
528  CK_FDiv,
529  CK_SDiv,
530  CK_And,
531  CK_Or,
532  CK_Xor,
533  CK_Add,
534  CK_FAdd,
535  CK_Sub,
536  CK_FSub,
537  CK_Mul,
538  CK_FMul,
539  CK_Shl,
540  CK_LShr,
541  CK_AShr,
542  CK_BinaryEnd = CK_AShr,
543 
544  CK_CastBegin,
545  CK_AddressCast = CK_CastBegin,
546  CK_Int2Ptr,
547  CK_Ptr2Int,
548  CK_Bitcast,
549  CK_Trunc,
550  CK_FPTrunc,
551  CK_SExt,
552  CK_ZExt,
553  CK_FPExt,
554  CK_SI2FP,
555  CK_FP2SI,
556  CK_UI2FP,
557  CK_FP2UI,
558  CK_CastEnd = CK_FP2UI,
559 
560  CK_ExtractElmt,
561  CK_InsertElmt,
562 
563  CK_Select,
564 
565  CK_GetElmtPtr,
566 
567  CK_Concat,
568 
569  CK_CmpBegin,
570  // Predicates for comparing floating numbers
571  // U L G E Intuitive operation
572  CK_FFalse = CK_CmpBegin,
588 
589  // Predicates for comparing integers
600  CK_CmpEnd = CK_ISLE,
601 
602  CK_InvalidCode,
603  };
604 
605 protected:
606  CodeKind Opcode;
607 
609  SEGOpcodeNode(SEGObjectKind K, CodeKind Opcode, Type *Ty,
610  SymbolicExprGraph *SEG, BasicBlock *BB, bool fromDisk);
611 
613  friend class SymbolicExprGraph;
614 
615 public:
616  virtual ~SEGOpcodeNode() = 0;
617 
618  CodeKind getOpcode() const { return Opcode; }
619 
620  virtual void dot(raw_fd_ostream &O) const;
621 
622  bool isCmpNode() const {
623  return Opcode <= CK_CmpEnd && Opcode >= CK_CmpBegin;
624  }
625 
626  bool isSignedCmp() const { return Opcode <= CK_ISLE && Opcode >= CK_ISGT; }
627 
628  bool isUnSignedCmp() const { return Opcode <= CK_IULE && Opcode >= CK_IUGT; }
629 
630  bool isFloatCmp() const { return Opcode <= CK_FTrue && Opcode >= CK_FFalse; }
631 
632  bool isAddNode() const { return Opcode == CK_Add; }
633 
634  bool isSubNode() const { return Opcode == CK_Sub; }
635 
636  bool isGEPNode() const { return Opcode == CK_GetElmtPtr; }
637 
638  bool isSelectNode() const { return Opcode == CK_Select; }
639 
640  bool isCastNode() const {
641  return Opcode <= CK_CastEnd && Opcode >= CK_CastBegin;
642  }
643 
644  bool isBinaryNode() const {
645  return Opcode <= CK_BinaryEnd && Opcode >= CK_BinaryBegin;
646  }
647 
648  bool isExtractElmtNode() const { return Opcode == CK_ExtractElmt; }
649 
650  bool isInsertElmtNode() const { return Opcode == CK_InsertElmt; }
651 
652  bool isConcatNode() const { return Opcode == CK_Concat; }
653 
654 public:
655  static bool classof(const SEGObject *N) {
656  return N->getKind() >= SEGOBJK_OpcodeBegin &&
657  N->getKind() <= SEGOBJK_OpcodeEnd;
658  }
659 
660  static const char *getOpcodeName(CodeKind CK);
661 };
662 
663 class SEGSiteBase : public SEGObject {
664 
665 private:
666  Instruction *User = nullptr;
667 
668  SEGValue *segValue = nullptr;
669 
670 protected:
671  SEGSiteBase(SEGObjectKind K, Instruction *User, SymbolicExprGraph *G,
672  bool fromDisk);
673  friend class SymbolicExprGraph;
674 
675 public:
676  virtual ~SEGSiteBase() = 0;
677 
678  CallSite getLLVMCallSite() const { return CallSite(User); }
679 
680  Instruction *getInstruction() const { return User; }
681 
682  SEGValue *getSEGValue() const { return segValue; }
683 
684  virtual Value *getLLVMDbgValue() const override { return getInstruction(); }
685 
686  friend raw_ostream &operator<<(llvm::raw_ostream &Out,
687  const SEGSiteBase &US) {
688  Out << *US.User;
689  return Out;
690  }
691 
692 public:
693  static bool classof(const SEGObject *O) {
694  return O->getKind() >= SEGOBJK_SiteBegin && O->getKind() <= SEGOBJK_SiteEnd;
695  }
696 };
697 
698 namespace FalconPlus {
699 class AbstractCond;
700 class RegionCond;
701 class IntraFalcon;
702 class AbstractCondPtr;
703 class FalconAA;
704 class MemValueSet;
705 } // namespace FalconPlus
706 
708 
709  friend class SEGRegionNode;
710  friend class SymbolicExprGraphBuilder;
711  friend class IntraFalcon;
712  friend class MantaIntraFalcon;
713  friend class PTGraph;
714  friend class SEGObject;
715  friend class OCValueFlowBuilder;
716  friend class SEGSerializer;
717 
718  friend class FalconPlus::AbstractCond;
719  friend class FalconPlus::RegionCond;
720  friend class FalconPlus::IntraFalcon;
721  friend class FalconPlus::AbstractCondPtr;
722  friend class FalconPlus::FalconAA;
723  friend class FalconPlus::MemValueSet;
724 
725 public:
726  struct CDGCond {
727  SEGNodeBase *CondNode;
728  BasicBlock *BB;
729  bool Cond;
730 
731  public:
732  CDGCond(SEGNodeBase *CN, BasicBlock *B, bool C)
733  : CondNode(CN), BB(B), Cond(C) {}
734 
735  bool operator<(const CDGCond &RHS) const {
736  return (CondNode < RHS.CondNode) ||
737  (CondNode == RHS.CondNode && BB < RHS.BB) ||
738  (CondNode == RHS.CondNode && BB == RHS.BB && Cond < RHS.Cond);
739  }
740 
741  bool operator==(const CDGCond &RHS) const {
742  return CondNode == RHS.CondNode && BB == RHS.BB && Cond == RHS.Cond;
743  }
744 
745  BasicBlock *getBB() const { return BB; }
746  };
747 
748 private:
749  // The base function for this SEG
750  Function *BaseFunc = nullptr;
751 
752  // All the nodes in seg
753  std::vector<SEGObject *> NodesList;
754 
756  std::unordered_map<Value *, SEGOperandNode *> ValueNodesMap;
757 
761  std::vector<std::pair<Value *, SEGOperandNode *>> ValueNodePairs;
762 
765  std::set<SEGNodeBase *> NonValueNodes;
766 
768  std::map<std::pair<Instruction *, Value *>, SEGStoreMemNode *>
769  StoreMemNodesMap;
770 
772  std::map<Instruction *, SEGSiteBase *> InstSiteMap;
773  std::vector<SEGCallSite *> CallSites;
774 
782  std::map<BasicBlock *, std::set<CDGCond> *> BlockCondMap;
783 
784  int64_t SEGIndex = -1;
785 
786 public:
787  // For Swap
788  int64_t getSEGIndex() const { return SEGIndex; }
789 
790  template <class T> T *getSEGObject(int64_t index) {
791  assert(index == -1 || (index >= 0 && index < NodesList.size()));
792  if (index == -1)
793  return nullptr;
794  auto *Obj = NodesList[index];
795  assert(isa<T>(Obj));
796  return (T *)Obj;
797  }
798 
799 private:
800  /*==--------------------Structures for Inter-procedural
801  * Analysis--------------------==*/
802  SEGCommonReturnNode *CommonReturn = nullptr;
803  kvec<SEGPseudoReturnNode *> PseudoReturns;
804 
805  kvec<SEGCommonArgumentNode *> CommonArgumentNodes;
806  kvec<SEGPseudoArgumentNode *> PseudoArgumentNodes;
807  kvec<SEGVarArgumentNode *> VarArgumentNodes;
808 
809  // Summary Nodes
810  // SEGNodeBase : the node
811  // int : the corresponding ap-depth (0 means ap-depth larger than considered)
812  //
813  // For each ap-depth, there is only one return summary node with a load mem
814  // node as child,
815  // which collects all values with conditions and confidence score, that
816  // may escape to caller with the corresponding ap-depth
817  // For each ap-depth, there can be multiple arg-summary node,
818  // each has a parent to the argument node that is not inlined
819  // Each summary node has type PTGraph::DEFAULT_NON_POINTER_TYPE
820  // which is currently int64 type
821  std::unordered_map<SEGNodeBase *, int> SummaryArgNodes;
822  std::unordered_map<int, std::unordered_set<SEGNodeBase *>>
823  SummaryArgNodesCache;
824  std::unordered_map<SEGNodeBase *, int> SummaryReturnNodes;
825  std::unordered_map<int, std::unordered_set<SEGNodeBase *>>
826  SummaryReturnNodesCache;
827 
829  std::map<std::string, SEGOperandNode *> NameToPseudoArgNode;
830  std::unordered_map<std::string, SEGOperandNode *> NameToNonArgPseudoNode;
831  std::unordered_map<std::string, std::unique_ptr<PseudoVal>> PseudoValStorage;
832 
833  void addCommonArgumentNodes(SEGCommonArgumentNode *Node);
834 
835  void addPseudoArgumentNodes(SEGPseudoArgumentNode *Node);
836 
837  void addVarArgumentNodes(SEGVarArgumentNode *Node);
838 
839  void setCommonReturnNode(SEGCommonReturnNode *Node);
840 
841  void addPseudoReturnNode(SEGPseudoReturnNode *Node);
842 
843  void addSummaryArgNode(SEGNodeBase *Node, int APDepth);
844 
845  void addSummaryReturnNode(SEGNodeBase *Node, int APDepth);
846 
847 public:
848  size_t getNumCommonArgument() const { return CommonArgumentNodes.size(); }
849 
850  size_t getNumPseudoArgument() const { return PseudoArgumentNodes.size(); }
851 
852  size_t getNumVarArgument() const { return VarArgumentNodes.size(); }
853 
854  size_t getNumPseudoReturn() const { return PseudoReturns.size(); }
855 
856  bool hasCommonReturnNode() const {
857  if (CommonReturn)
858  return true;
859  else
860  return false;
861  }
862 
863  const SEGCommonReturnNode *getCommonReturn() const { return CommonReturn; }
864 
865  const SEGPseudoReturnNode *getPseudoReturn(size_t Index) const {
866  return PseudoReturns[Index];
867  }
868 
869  const SEGCommonArgumentNode *getCommonArgument(size_t Index) const {
870  return CommonArgumentNodes[Index];
871  }
872 
873  const SEGPseudoArgumentNode *getPseudoArgument(size_t Index) const {
874  return PseudoArgumentNodes[Index];
875  }
876 
877  const SEGVarArgumentNode *getVarArgument(size_t Index) const {
878  return VarArgumentNodes[Index];
879  }
880 
881  bool isSummaryArgument(const SEGNodeBase *Node) const;
882 
883  // Return the ap-depth of an SEGNodeBase as summary argument.
884  // If the node is not a summary argument, return -1.
885  int getSummaryArgumentAPDepth(const SEGNodeBase *Node) const;
886 
887  // Get the set of summary argument nodes given APDepth
888  // Return null if not exist
889  std::unordered_set<SEGNodeBase *> *getSummaryArgument(int APDepth) const;
890 
891  bool isSummaryReturn(const SEGNodeBase *Node) const;
892 
893  // Return the ap-depth of an SEGNodeBase as summary return node.
894  // If the node is not a summary return node, return -1.
895  int getSummaryReturnAPDepth(const SEGNodeBase *Node) const;
896 
897  // Get the set of summary return nodes given APDepth
898  // Return null if not exist
899  std::unordered_set<SEGNodeBase *> *getSummaryReturn(int APDepth) const;
900 
901  // Return if the value represented by the Node is directly passed to/from
902  // caller A node is directly passed to/from caller if either it is a common or
903  // pseudo return/argument node or a summary return/argument node. A node is
904  // indirectly passed to/from caller if one of it's ancestor/descendant is
905  // directly passed to/from caller
906  bool isDirectlyPassedToCaller(const SEGNodeBase *Node) const;
907  bool isDirectlyPassedFromCaller(const SEGNodeBase *Node) const;
908 
909 private:
910  // Cache of region nodes to avoid multiple creation of same regions
911  // Positive regions: Value of SEGNodeBase is true
912  // Negative regions: Value of SEGNodeBase is false
913  // compond_regions_cache_and: SEGRegionNode(3) is SEGRegionNode(1) and
914  // SEGRegionNode(2) compond_regions_cache_or: SEGRegionNode(3) is
915  // SEGRegionNode(1) or SEGRegionNode(2) Note, for compound regions, we assume
916  // (pointer) value SEGRegionNode*(1) < SEGRegionNode*(2)
917  std::unordered_map<SEGNodeBase *, SEGRegionNode *> positive_regions_cache;
918  std::unordered_map<SEGNodeBase *, SEGRegionNode *> negative_regions_cache;
919  std::unordered_map<SEGRegionNode *,
920  std::unordered_map<SEGRegionNode *, SEGRegionNode *>>
921  compound_regions_cache_and;
922  std::unordered_map<SEGRegionNode *,
923  std::unordered_map<SEGRegionNode *, SEGRegionNode *>>
924  compound_regions_cache_or;
925 
926  // cache the corresponding region nodes for basic blocks
927  std::unordered_map<BasicBlock *, SEGRegionNode *> bb_region_cache;
928 
929 public:
930  void clearRegionNodeCache();
931 
932 private:
933  // All the functions that may change the SEG (i.e. have side-effects on the
934  // SEG) are private) Meaning that the SEG cannot be changed once created. Only
935  // friend class of SEG can modify the SEG, which is used to protect the SEG
936  // from modified by checkers
937 
948  SEGOperandNode *findOrCreateNode(Value *Val, Type *Ty, BasicBlock *BB);
949 
952  template <class OperandNodeTy>
953  OperandNodeTy *findOrCreateOperandNode(Value *Val, Type *Ty, BasicBlock *BB,
954  bool fromDisk = false) {
955  assert(Ty && BB);
956  assert(Val && !Val->getType()->isVoidTy());
957  assert((!(dyn_cast<Instruction>(Val)) ||
958  BB == ((Instruction *)Val)->getParent()) &&
959  "Incorrect BasicBlock detected");
960 
961  auto It = ValueNodesMap.find(Val);
962  if (It != ValueNodesMap.end()) {
963  assert(isa<OperandNodeTy>(It->second));
964  return (OperandNodeTy *)It->second;
965  } else {
966  auto *N = new OperandNodeTy(Val, Ty, this, BB, fromDisk);
967  ValueNodePairs.push_back({Val, N});
968  ValueNodesMap[Val] = N;
969  return N;
970  }
971  }
972 
974 
975  template <class OperandNodeTy>
976  OperandNodeTy *
977  clonePseudoVal(const PseudoVal *Arg,
978  std::function<OperandNodeTy *(const PseudoVal *)> Proc) {
979  const std::string &ArgName = Arg->getName();
980  auto ClonedArg = std::unique_ptr<PseudoVal>(Arg->clone());
981  auto *ArgNode = Proc(ClonedArg.get());
982 
983  if (std::is_same<OperandNodeTy, SEGPseudoArgumentNode>::value) {
984  NameToPseudoArgNode.insert(std::make_pair(ArgName, ArgNode));
985  } else {
986  NameToNonArgPseudoNode.insert(std::make_pair(ArgName, ArgNode));
987  }
988 
989  assert(!PseudoValStorage.count(ArgName));
990  PseudoValStorage.insert({ArgName, std::move(ClonedArg)});
991  return ArgNode;
992  }
993 
994  template <class OperandNodeTy>
995  OperandNodeTy *
996  findOrClonePseudoVal(const PseudoVal *Arg,
997  std::function<OperandNodeTy *(const PseudoVal *)> Proc) {
998  const std::string &ArgName = Arg->getName();
999  if (std::is_same<OperandNodeTy, SEGPseudoArgumentNode>::value) {
1000  if (NameToPseudoArgNode.count(ArgName)) {
1001  return cast<OperandNodeTy>(NameToPseudoArgNode.at(ArgName));
1002  }
1003  } else {
1004  if (NameToNonArgPseudoNode.count(ArgName)) {
1005  static_assert(
1006  std::is_base_of<SEGOperandNode, OperandNodeTy>::value,
1007  "OperandNodeTy must be a derived class of SEGOperandNode.");
1008  return cast<OperandNodeTy>(NameToNonArgPseudoNode.at(ArgName));
1009  }
1010  }
1011 
1012  return clonePseudoVal<OperandNodeTy>(Arg, Proc);
1013  }
1014 
1015  SEGPseudoArgumentNode *findOrCreatePseudoArgumentNode(const PseudoVal *Arg,
1016  BasicBlock *BB);
1017  // Call this after all pseudo args have been created.
1018  void finalizePseudoArgumentNodes();
1019  SEGOperandNode *findOrCreateSimpleOperandFromPseudoVal(const PseudoVal *Arg,
1020  BasicBlock *BB);
1021  SEGPseudoReturnNode *createPseudoReturnNode(const PseudoVal *Arg,
1022  BasicBlock *BB);
1023  SEGCallSitePseudoInputNode *createPseudoInputNode(const PseudoVal *Arg,
1024  BasicBlock *BB, CallSite CS,
1025  Function *Callee);
1026  SEGCallSitePseudoOutputNode *createPseudoOutputNode(const PseudoVal *Arg,
1027  BasicBlock *BB,
1028  CallInst *Call,
1029  Function *Callee);
1030 
1031  template <class OperandNodeTy>
1032  OperandNodeTy *CreateUniqueOperandNode(Value *Val, Type *Ty, BasicBlock *BB,
1033  bool fromDisk = false) {
1034  assert(Ty && BB);
1035  assert(Val && !Val->getType()->isVoidTy());
1036  assert((!(dyn_cast<Instruction>(Val)) ||
1037  BB == ((Instruction *)Val)->getParent()) &&
1038  "Incorrect BasicBlock detected");
1039 
1040  auto *N = new OperandNodeTy(Val, Ty, this, BB, fromDisk);
1041  ValueNodesMap[Val] = N;
1042  ValueNodePairs.push_back({Val, N});
1043  return N;
1044  }
1045 
1046  template <class OperandNodeTy>
1047  OperandNodeTy *createOperandNode(Type *Ty, BasicBlock *BB,
1048  bool fromDisk = false) {
1049  assert(Ty);
1050  assert(BB);
1051  auto *Ret = new OperandNodeTy(Ty, this, BB, fromDisk);
1052  NonValueNodes.insert(Ret);
1053  return Ret;
1054  }
1055 
1058  template <class SiteTy>
1059  SiteTy *findOrCreateSite(Instruction *I, bool fromDisk = false) {
1060  assert(I);
1061 
1062  auto It = InstSiteMap.find(I);
1063  if (It != InstSiteMap.end()) {
1064  assert(isa<SiteTy>(It->second));
1065  return (SiteTy *)It->second;
1066  } else {
1067  SiteTy *N = new SiteTy(I, this, fromDisk);
1068  InstSiteMap[I] = N;
1069 
1070  if (SEGCallSite *CS = dyn_cast<SEGCallSite>(N)) {
1071  CallSites.push_back(CS);
1072  }
1073 
1074  return N;
1075  }
1076  }
1077 
1078  // Create callSite argument summary node as operandNode(Type* Ty,
1079  // SymbolicExprGraph* SEG, BasicBlock* BB) for call site Callsite with
1080  // ap-depth APDepth
1082  createCallSiteArgumentSummaryNode(Type *Ty, BasicBlock *BB,
1083  Instruction *Callsite, int APDepth,
1084  bool fromDisk = false);
1085 
1086  // Create callSite return summary node as operandNode(Type* Ty,
1087  // SymbolicExprGraph* SEG, BasicBlock* BB) for call site Callsite, with value
1088  // confidence Confidence
1090  createCallSiteReturnSummaryNode(Type *Ty, BasicBlock *BB,
1091  Instruction *Callsite, float Confidence,
1092  bool fromDisk = false);
1093 
1094  // find or create a call site output node
1096  findOrCreateCallSiteOutputNode(Value *Val, Type *Ty, BasicBlock *BB,
1097  CallSite CS, Function *Callee, bool IsCommon);
1098 
1099  SEGCallSiteOutputNode *createCallSiteOutputNode(Value *Val, Type *Ty,
1100  BasicBlock *BB, CallSite CS,
1101  Function *Callee,
1102  bool IsCommon,
1103  bool fromDisk = false);
1104 
1105  // find or create a call site pseudo input node
1107  findOrCreateCallSitePseudoInputNode(Value *Val, Type *Ty, BasicBlock *BB,
1108  CallSite CS, Function *Callee,
1109  bool fromDisk = false);
1110 
1112  SEGStoreMemNode *findOrCreateStoreMemNode(Type *Ty, Instruction *StoreSite,
1113  Value *StoreVal, BasicBlock *BB,
1114  bool fromDisk = false);
1115 
1116  // Create a region node
1117  SEGRegionNode *createRegionNode(SEGNodeBase *cond_node = nullptr,
1118  bool cond = false, bool fromDisk = false);
1119 
1120  // Find or create a Region node from a region unit (with boolean value
1121  // cond_node == cond)
1122  SEGRegionNode *findOrCreateUnitRegion(SEGNodeBase *cond_node, bool cond);
1123 
1124  // Find or create a Region node "region1 and region2"
1125  SEGRegionNode *findOrCreateAndRegion(SEGRegionNode *region1,
1126  SEGRegionNode *region2);
1127 
1128  // Find or create a Region node "region1 or region2"
1129  SEGRegionNode *findOrCreateOrRegion(SEGRegionNode *region1,
1130  SEGRegionNode *region2);
1131 
1132  // Find or create a Region node "not region1"
1133  SEGRegionNode *findOrCreateNotRegion(SEGRegionNode *region1);
1134 
1135  // Find or create a node representing a constant bool value : Constant True or
1136  // Constant False
1137  SEGOperandNode *findOrCreateConstantBoolNode(bool bool_val);
1138 
1142  SEGSimpleOpcodeNode *createExpr(SEGOpcodeNode::CodeKind Opcode, Type *Ty,
1143  BasicBlock *BB, SEGNodeBase *FirstOperand,
1144  ...);
1145 
1149  SEGSimpleOpcodeNode *createExpr(SEGOpcodeNode::CodeKind Opcode, Type *Ty,
1150  BasicBlock *BB, const kvec<SEGNodeBase *> &,
1151  bool fromDisk = false);
1152 
1154  SEGCastNode *createCastExpr(SEGOpcodeNode::CodeKind Opcode, Type *Ty,
1155  BasicBlock *BB, SEGNodeBase *Op, uint64_t OSz,
1156  uint64_t TSz, bool fromDisk = false);
1157 
1160  createBinaryWithIntConstExpr(SEGOpcodeNode::CodeKind Opcode, Type *Ty,
1161  BasicBlock *BB, SEGNodeBase *Op, uint64_t TSz,
1162  bool fromDisk = false);
1163 
1165  void addBlockCond(BasicBlock *CurrBB, SEGNodeBase *BrNode, BasicBlock *DepBB,
1166  bool Label);
1167 
1168 public:
1169  SymbolicExprGraph(Function *);
1170  ~SymbolicExprGraph();
1171 
1172  Function *getBaseFunc() const { return BaseFunc; }
1173 
1176  template <class SiteTy> SiteTy *findSite(Instruction *I) const {
1177  assert(I);
1178 
1179  auto It = InstSiteMap.find(I);
1180  if (It != InstSiteMap.end()) {
1181  // assert(isa<SiteTy>(It->second));
1182  return dyn_cast<SiteTy>(It->second);
1183  } else {
1184  return nullptr;
1185  }
1186  }
1187 
1194  template <class SiteTy> SiteTy *findSite(SEGValue *sValue) const {
1195  Instruction *I = dyn_cast<Instruction>(sValue->getValue());
1196  assert(I);
1197 
1198  auto It = InstSiteMap.find(I);
1199  if (It != InstSiteMap.end()) {
1200  // assert(isa<SiteTy>(It->second));
1201  return dyn_cast<SiteTy>(It->second);
1202  } else {
1203  return nullptr;
1204  }
1205  }
1206 
1209  SEGOperandNode *findNode(Value *) const;
1210 
1211  SEGOperandNode *findNode(SEGValue *) const;
1212 
1213  // Find the Region node from a region unit (with boolean value cond_node ==
1214  // cond)
1216  SEGRegionNode *findUnitRegion(SEGNodeBase *cond_node, bool cond) const;
1217 
1218  // Find the Region node "region1 and region2"
1220  SEGRegionNode *findAndRegion(SEGRegionNode *region1,
1221  SEGRegionNode *region2) const;
1222 
1223  // Find the Region node "region1 or region2"
1225  SEGRegionNode *findOrRegion(SEGRegionNode *region1,
1226  SEGRegionNode *region2) const;
1227 
1228  // Find the Region node "not region1"
1230  SEGRegionNode *findNotRegion(SEGRegionNode *region1) const;
1231 
1235  const std::set<CDGCond> *getBlockCond(BasicBlock *BB) const {
1236  auto It = BlockCondMap.find(BB);
1237  if (It != BlockCondMap.end()) {
1238  return It->second;
1239  }
1240  return nullptr;
1241  }
1242 
1244  void dot(const char *FileName) const;
1245 
1247  void dot(std::vector<const SEGNodeBase *> Srcs, const char *FileName) const;
1248 
1250  void validate();
1251 
1252  // Return the region node for the corresponding basicblock, if not computed,
1253  // we compute and generate a new region
1254  SEGRegionNode *findOrCreateRegionForBB(BasicBlock *BB);
1255 
1256  // Find the region for BB. If the region is not computed, we return null
1257  SEGRegionNode *findRegionForBB(BasicBlock *BB) const;
1258 
1259  /*==------------------------Iterators--------------------==*/
1260 
1261  std::unordered_map<Value *, SEGOperandNode *>::const_iterator
1262  value_node_begin() const {
1263  return ValueNodesMap.begin();
1264  }
1265 
1266  std::unordered_map<Value *, SEGOperandNode *>::const_iterator
1267  value_node_end() const {
1268  return ValueNodesMap.end();
1269  }
1270 
1271  std::vector<std::pair<Value *, SEGOperandNode *>>::const_iterator
1272  value_node_pair_begin() const {
1273  return ValueNodePairs.begin();
1274  }
1275 
1276  std::vector<std::pair<Value *, SEGOperandNode *>>::const_iterator
1277  value_node_pair_end() const {
1278  return ValueNodePairs.end();
1279  }
1280 
1281  std::set<SEGNodeBase *>::const_iterator non_value_node_begin() const {
1282  return NonValueNodes.begin();
1283  }
1284 
1285  std::set<SEGNodeBase *>::const_iterator non_value_node_end() const {
1286  return NonValueNodes.end();
1287  }
1288 
1289  std::map<Instruction *, SEGSiteBase *>::const_iterator
1290  inst_site_begin() const {
1291  return InstSiteMap.begin();
1292  }
1293 
1294  std::map<Instruction *, SEGSiteBase *>::const_iterator inst_site_end() const {
1295  return InstSiteMap.end();
1296  }
1297 
1298  std::map<std::pair<Instruction *, Value *>, SEGStoreMemNode *>::const_iterator
1299  store_mem_node_begin() const {
1300  return StoreMemNodesMap.begin();
1301  }
1302 
1303  std::map<std::pair<Instruction *, Value *>, SEGStoreMemNode *>::const_iterator
1304  store_mem_node_end() const {
1305  return StoreMemNodesMap.end();
1306  }
1307 
1308  std::map<Instruction *, SEGSiteBase *>::const_iterator site_begin() const {
1309  return InstSiteMap.begin();
1310  }
1311 
1312  std::map<Instruction *, SEGSiteBase *>::const_iterator site_end() const {
1313  return InstSiteMap.end();
1314  }
1315 
1316  std::vector<SEGObject *>::const_iterator node_begin() const {
1317  return NodesList.begin();
1318  }
1319 
1320  std::vector<SEGObject *>::const_iterator node_end() const {
1321  return NodesList.end();
1322  }
1323 
1325  private:
1326  size_t I;
1327  SEGCommonReturnNode *CommonRet;
1328  const kvec<SEGPseudoReturnNode *> &PseudoRets;
1329 
1330  public:
1331  ReturnIterator(size_t Id, SEGCommonReturnNode *CR,
1332  const kvec<SEGPseudoReturnNode *> &PRs)
1333  : I(Id), CommonRet(CR), PseudoRets(PRs) {}
1334 
1335  ReturnIterator(const ReturnIterator &It)
1336  : I(It.I), CommonRet(It.CommonRet), PseudoRets(It.PseudoRets) {}
1337 
1338  ReturnIterator &operator++() {
1339  I++;
1340  return *this;
1341  }
1342 
1343  ReturnIterator operator++(int) {
1344  ReturnIterator Old(*this);
1345  ++(*this);
1346  return Old;
1347  }
1348 
1349  const SEGReturnNode *operator*() {
1350  if (CommonRet) {
1351  if (I == 0) {
1352  return (const SEGReturnNode *)CommonRet;
1353  } else {
1354  return (const SEGReturnNode *)PseudoRets[I - 1];
1355  }
1356  } else {
1357  return (const SEGReturnNode *)PseudoRets[I];
1358  }
1359  }
1360 
1361  bool operator==(const ReturnIterator &It) { return I == It.I; }
1362 
1363  bool operator!=(const ReturnIterator &It) { return I != It.I; }
1364  };
1365 
1366  ReturnIterator return_begin() const {
1367  return ReturnIterator(0, CommonReturn, PseudoReturns);
1368  }
1369 
1370  ReturnIterator return_end() const {
1371  return ReturnIterator(getNumPseudoReturn() + (getCommonReturn() ? 1 : 0),
1372  CommonReturn, PseudoReturns);
1373  }
1374 
1375  ReturnIterator pseudo_return_begin() const {
1376  size_t StartIndex = getCommonReturn() ? 1 : 0;
1377  return ReturnIterator(StartIndex, CommonReturn, PseudoReturns);
1378  }
1379 
1380  ReturnIterator pseudo_return_end() const { return return_end(); }
1381 
1383  private:
1384  size_t I;
1385  const kvec<SEGCommonArgumentNode *> &CommonArgs;
1386  const kvec<SEGPseudoArgumentNode *> &PseudoArgs;
1387  const kvec<SEGVarArgumentNode *> &VarArgs;
1388 
1389  public:
1390  ArgumentIterator(size_t Id, const kvec<SEGCommonArgumentNode *> &CA,
1391  const kvec<SEGPseudoArgumentNode *> &PA,
1392  const kvec<SEGVarArgumentNode *> &VA)
1393  : I(Id), CommonArgs(CA), PseudoArgs(PA), VarArgs(VA) {}
1394 
1396  : I(It.I), CommonArgs(It.CommonArgs), PseudoArgs(It.PseudoArgs),
1397  VarArgs(It.VarArgs) {}
1398 
1399  ArgumentIterator &operator++() {
1400  I++;
1401  return *this;
1402  }
1403 
1404  ArgumentIterator operator++(int) {
1405  ArgumentIterator Old(*this);
1406  ++(*this);
1407  return Old;
1408  }
1409 
1410  const SEGArgumentNode *operator*() {
1411  if (I < (size_t)CommonArgs.size()) {
1412  return (const SEGArgumentNode *)CommonArgs[I];
1413  }
1414 
1415  if (I < (size_t)(CommonArgs.size() + PseudoArgs.size())) {
1416  return (const SEGArgumentNode *)PseudoArgs[I - CommonArgs.size()];
1417  }
1418 
1419  assert(I <
1420  (size_t)(CommonArgs.size() + PseudoArgs.size() + VarArgs.size()));
1421  return (const SEGArgumentNode *)
1422  VarArgs[I - (CommonArgs.size() + PseudoArgs.size())];
1423  }
1424 
1425  bool operator==(const ArgumentIterator &It) { return I == It.I; }
1426 
1427  bool operator!=(const ArgumentIterator &It) { return I != It.I; }
1428  };
1429 
1430  ArgumentIterator arg_begin() const {
1431  return ArgumentIterator(0, CommonArgumentNodes, PseudoArgumentNodes,
1432  VarArgumentNodes);
1433  }
1434 
1435  ArgumentIterator arg_end() const {
1436  size_t NumArgs =
1437  getNumCommonArgument() + getNumPseudoArgument() + getNumVarArgument();
1438  return ArgumentIterator(NumArgs, CommonArgumentNodes, PseudoArgumentNodes,
1439  VarArgumentNodes);
1440  }
1441 
1442  ArgumentIterator common_arg_begin() const { return arg_begin(); }
1443 
1444  ArgumentIterator common_arg_end() const {
1445  size_t NumArgs = getNumCommonArgument();
1446  return ArgumentIterator(NumArgs, CommonArgumentNodes, PseudoArgumentNodes,
1447  VarArgumentNodes);
1448  }
1449 
1450  ArgumentIterator pseudo_arg_begin() const { return common_arg_end(); }
1451 
1452  ArgumentIterator pseudo_arg_end() const {
1453  size_t EndId = getNumCommonArgument() + getNumPseudoArgument();
1454  return ArgumentIterator(EndId, CommonArgumentNodes, PseudoArgumentNodes,
1455  VarArgumentNodes);
1456  }
1457 
1458  ArgumentIterator var_arg_begin() const { return pseudo_arg_end(); }
1459 
1460  ArgumentIterator var_arg_end() const { return arg_end(); }
1461 
1462  typedef std::vector<SEGCallSite *>::const_iterator SEGCallSiteIterator;
1463  SEGCallSiteIterator seg_callsite_begin() const { return CallSites.begin(); }
1464 
1465  SEGCallSiteIterator seg_callsite_end() const { return CallSites.end(); }
1466 };
1467 
1468 #endif
SEGStoreMemNode
Definition: SEGStoreMemNode.h:23
SymbolicExprGraph::dot
void dot(const char *FileName) const
Dot this graph to a file with filename.
Definition: SymbolicExprGraph.cpp:891
SEGVarArgumentNode
Definition: SEGArgumentNode.h:89
SymbolicExprGraph::getBlockCond
const std::set< CDGCond > * getBlockCond(BasicBlock *BB) const
Definition: SymbolicExprGraph.h:1235
SymbolicExprGraph::ReturnIterator
Definition: SymbolicExprGraph.h:1324
SEGOpcodeNode::CK_FUGE
@ CK_FUGE
1 0 1 1 True if unordered, greater than, or equal
Definition: SymbolicExprGraph.h:583
SEGOperandNode
Definition: SymbolicExprGraph.h:456
SEGPseudoArgumentNode
Definition: SEGArgumentNode.h:121
SEGOpcodeNode::CK_FOGE
@ CK_FOGE
0 0 1 1 True if ordered and greater than or equal
Definition: SymbolicExprGraph.h:575
SEGOpcodeNode::CK_ISGT
@ CK_ISGT
signed greater than
Definition: SymbolicExprGraph.h:596
SEGOpcodeNode::CK_FOEq
@ CK_FOEq
0 0 0 1 True if ordered and equal
Definition: SymbolicExprGraph.h:573
SEGCallSiteOutputNode
Definition: SEGCallSiteOutputNode.h:19
SEGSimpleOpcodeNode
Definition: SEGSimpleOpcodeNode.h:18
SEGCallSite
Definition: SEGCallSite.h:52
SEGOpcodeNode::CK_FOrd
@ CK_FOrd
0 1 1 1 True if ordered (no nans)
Definition: SymbolicExprGraph.h:579
SEGOpcodeNode::CK_FONE
@ CK_FONE
0 1 1 0 True if ordered and operands are unequal
Definition: SymbolicExprGraph.h:578
SEGOpcodeNode::CodeKind
CodeKind
Definition: SymbolicExprGraph.h:522
SEGOpcodeNode::CK_FOLE
@ CK_FOLE
0 1 0 1 True if ordered and less than or equal
Definition: SymbolicExprGraph.h:577
SEGCallSiteArgumentSummaryNode
Definition: SEGCallSiteArgumentSummaryNode.h:17
SEGCastNode
Definition: SEGCastNode.h:18
SEGCommonArgumentNode
Definition: SEGArgumentNode.h:42
SEGOpcodeNode::CK_FULT
@ CK_FULT
1 1 0 0 True if unordered or less than
Definition: SymbolicExprGraph.h:584
SymbolicExprGraph
Definition: SymbolicExprGraph.h:707
SEGNodeBase::ValueFlowIterator
Definition: SymbolicExprGraph.h:338
SEGOpcodeNode::CK_ISLE
@ CK_ISLE
signed less or equal
Definition: SymbolicExprGraph.h:599
SEGOpcodeNode::CK_IULT
@ CK_IULT
unsigned less than
Definition: SymbolicExprGraph.h:594
SEGOpcodeNode::CK_IULE
@ CK_IULE
unsigned less or equal
Definition: SymbolicExprGraph.h:595
SEGOpcodeNode::CK_IEq
@ CK_IEq
equal
Definition: SymbolicExprGraph.h:590
SymbolicExprGraph::ArgumentIterator
Definition: SymbolicExprGraph.h:1382
SEGArgumentNode
Definition: SEGArgumentNode.h:18
SEGCallSiteReturnSummaryNode
Definition: SEGCallSiteReturnSummaryNode.h:20
SymbolicExprGraph::CDGCond
Definition: SymbolicExprGraph.h:726
SEGOpcodeNode::CK_IUGT
@ CK_IUGT
unsigned greater than
Definition: SymbolicExprGraph.h:592
SEGValue::getValue
Value * getValue()
Get Value.
Definition: SEGValue.h:66
SEGCommonReturnNode
Definition: SEGReturnNode.h:56
SEGOpcodeNode::CK_FUno
@ CK_FUno
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Definition: SymbolicExprGraph.h:580
SEGOptions
Definition: SymbolicExprGraph.h:70
SymbolicExprGraphBuilder
Definition: SymbolicExprGraphBuilder.h:37
SEGOpcodeNode::CK_ISGE
@ CK_ISGE
signed greater or equal
Definition: SymbolicExprGraph.h:597
SEGObject
Definition: SymbolicExprGraph.h:76
SEGOpcodeNode::CK_IUGE
@ CK_IUGE
unsigned greater or equal
Definition: SymbolicExprGraph.h:593
SEGCallSitePseudoInputNode
Definition: SEGCallSitePseudoInputNode.h:29
OCValueFlowBuilder
Definition: OCValueFlowBuilder.h:25
SEGValue
Definition: SEGValue.h:38
SEGPhiNode
Definition: SEGPhiNode.h:28
SEGOpcodeNode::CK_FOGT
@ CK_FOGT
0 0 1 0 True if ordered and greater than
Definition: SymbolicExprGraph.h:574
SEGOpcodeNode::CK_FUEq
@ CK_FUEq
1 0 0 1 True if unordered or equal
Definition: SymbolicExprGraph.h:581
SEGRegionNode
Definition: SEGRegionNode.h:34
SEGNodeBase::getLLVMType
Type * getLLVMType() const
get the type size of the node
Definition: SymbolicExprGraph.h:284
SEGOpcodeNode::CK_ISLT
@ CK_ISLT
signed less than
Definition: SymbolicExprGraph.h:598
SEGOpcodeNode::CK_FULE
@ CK_FULE
1 1 0 1 True if unordered, less than, or equal
Definition: SymbolicExprGraph.h:585
SEGOpcodeNode::CK_FUGT
@ CK_FUGT
1 0 1 0 True if unordered or greater than
Definition: SymbolicExprGraph.h:582
SEGCallSitePseudoOutputNode
Definition: SEGCallSiteOutputNode.h:76
SEGOpcodeNode::CK_FTrue
@ CK_FTrue
1 1 1 1 Always true (always folded)
Definition: SymbolicExprGraph.h:587
SEGOpcodeNode::CK_FUNE
@ CK_FUNE
1 1 1 0 True if unordered or not equal
Definition: SymbolicExprGraph.h:586
SEGPseudoReturnNode
Definition: SEGReturnNode.h:76
SEGOpcodeNode
Definition: SymbolicExprGraph.h:519
SymbolicExprGraph::findSite
SiteTy * findSite(SEGValue *sValue) const
Get site node based on Value and specific comparison method.
Definition: SymbolicExprGraph.h:1194
SymbolicExprGraph::findSite
SiteTy * findSite(Instruction *I) const
Definition: SymbolicExprGraph.h:1176
SEGSiteBase
Definition: SymbolicExprGraph.h:663
SEGReturnNode
The return node.
Definition: SEGReturnNode.h:25
seg_cmp
Definition: SymbolicExprGraph.h:226
SEGOpcodeNode::CK_INE
@ CK_INE
not equal
Definition: SymbolicExprGraph.h:591
SEGLoadMemNode
Definition: SEGLoadMemNode.h:21
SEGNodeBase
The node base of symbolic expression graph.
Definition: SymbolicExprGraph.h:244
SEGBinaryWithIntConstNode
Definition: SEGBinaryWithIntConstNode.h:19
SEGOpcodeNode::CK_FOLT
@ CK_FOLT
0 1 0 0 True if ordered and less than
Definition: SymbolicExprGraph.h:576