9 #ifndef IR_SEG_SEGSIMPLESITE_H
10 #define IR_SEG_SEGSIMPLESITE_H
12 #include <llvm/IR/Instructions.h>
14 #include "Analysis/Bitcode/BitcodeUtils.h"
15 #include "IR/SEG/SymbolicExprGraph.h"
16 #include "Persistence/PersistenceBasis.h"
20 class PersistedSEGSimpleSite;
22 class PersistedSEGDereferenceSite;
24 class PersistedSEGSEGDivSite;
26 class PersistedSEGCmpSite;
28 class PersistedSEGGEPSite;
30 class PersistedSEGAllocSite;
49 return N->getKind() >= SEGOBJK_SimpleSiteBegin &&
50 N->getKind() <= SEGOBJK_SimpleSiteEnd;
74 friend class IntraFalcon;
75 friend class MantaIntraFalcon;
77 void setPtrOperand(
SEGNodeBase *Node) { PtrOp = Node; }
79 void setValOperand(
SEGNodeBase *Node) { ValOp = Node; }
82 virtual PersistedSEGObject *createPersistedObject()
const {
83 PersistedSEGObject *PersistedObj =
new PersistedSEGDereferenceSite;
88 if (Value *Val = Node->getLLVMValue()) {
89 kvec<Value *> DerefPtrs;
90 getDerefPtrFromInst(*getInstruction(), DerefPtrs);
91 if (DerefPtrs.find(Val) != DerefPtrs.end()) {
98 bool isLoad() {
return isa<LoadInst>(getInstruction()); }
100 bool isStore() {
return isa<StoreInst>(getInstruction()); }
106 static bool classof(
const SEGObject *N) {
107 return N->getKind() == SEGOBJK_DereferenceSite;
131 virtual PersistedSEGObject *createPersistedObject()
const {
132 PersistedSEGObject *PersistedObj =
new PersistedSEGCmpSite;
137 static bool classof(
const SEGObject *N) {
138 return N->getKind() == SEGOBJK_CmpSite;
160 virtual PersistedSEGObject *createPersistedObject()
const {
161 PersistedSEGObject *PersistedObj =
new PersistedSEGDivSite;
166 static bool classof(
const SEGObject *N) {
167 return N->getKind() == SEGOBJK_DivSite;
184 std::vector<SEGNodeBase *> OffsetOps;
194 void addOffsetOperand(
SEGNodeBase *N) { OffsetOps.emplace_back(N); }
197 static bool classof(
const SEGObject *N) {
198 return N->getKind() == SEGOBJK_GEPSite;
201 Instruction *GEPUsedInstruction()
const {
202 auto *SiteNode = getParentGraph()->findNode(getInstruction());
203 for (
auto It = SiteNode->use_site_begin(); It != SiteNode->use_site_end();
205 auto I = (*It)->getInstruction();
206 auto OpCode = I->getOpcode();
207 if (OpCode == Instruction::Load || OpCode == Instruction::Store) {
214 virtual PersistedSEGObject *createPersistedObject()
const {
215 PersistedSEGObject *PersistedObj =
new PersistedSEGGEPSite;
220 std::vector<SEGNodeBase *> &getOffsetOperands() {
return OffsetOps; }
241 virtual PersistedSEGObject *createPersistedObject()
const {
242 PersistedSEGObject *PersistedObj =
new PersistedSEGAllocSite;
247 static bool classof(
const SEGObject *N) {
248 return N->getKind() == SEGOBJK_AllocSite;