Static Value-Flow Analysis
Loading...
Searching...
No Matches
SVFIR.h
Go to the documentation of this file.
1//===- SVFIR.h -- IR of SVF ---------------------------------------------//
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 * SVFIR.h
25 *
26 * Created on: 31, 12, 2021
27 * Author: Yulei Sui
28 */
29
30#ifndef INCLUDE_SVFIR_H_
31#define INCLUDE_SVFIR_H_
32
33#include "Graphs/IRGraph.h"
34
35namespace SVF
36{
37class CommonCHGraph;
38class CallGraph;
44class SVFIR : public IRGraph
45{
46 friend class SVFIRBuilder;
47 friend class ExternalPAG;
48 friend class PAGBuilderFromFile;
50 friend class SVFIRWriter;
51 friend class SVFIRReader;
52 friend class BVDataPTAImpl;
53
54public:
59 typedef std::vector<const SVFStmt*> SVFStmtList;
60 typedef std::vector<const SVFVar*> SVFVarList;
69 typedef std::pair<NodeID, APOffset> NodeOffset;
70 typedef std::pair<NodeID, AccessPath> NodeAccessPath;
74 typedef std::pair<const SVFType*, std::vector<AccessPath>> SVFTypeLocSetsPair;
77
78private:
99 ICFG* icfg; // ICFG
100 CommonCHGraph* chgraph; // class hierarchy graph
103
104 static std::unique_ptr<SVFIR> pag;
105
107 SVFIR(bool buildFromFile);
108
110 void destroy();
111
112public:
113
115
116 static inline SVFIR* getPAG(bool buildFromFile = false)
117 {
118 if (pag == nullptr)
119 {
120 pag = std::unique_ptr<SVFIR>(new SVFIR(buildFromFile));
121 }
122 return pag.get();
123 }
124 static void releaseSVFIR()
125 {
126 pag = nullptr;
127 }
129
131 {
132 return memToFieldsMap;
133 }
136 {
137 return GepObjVarMap;
138 }
141 {
142 return candidatePointers;
143 }
146
148 virtual ~SVFIR()
149 {
150 destroy();
151 }
153
154
155 static void handleBlackHole(bool b);
157
158 inline void setModule(SVFModule* mod)
159 {
160 svfModule = mod;
161 }
163 {
164 assert(svfModule && "empty SVFModule! Build SVF IR first!");
165 return svfModule;
166 }
168 inline void setICFG(ICFG* i)
169 {
170 icfg = i;
171 }
172 inline ICFG* getICFG() const
173 {
174 assert(icfg->totalICFGNode>0 && "empty ICFG! Build SVF IR first!");
175 return icfg;
176 }
178 inline void setCHG(CommonCHGraph* c)
179 {
180 chgraph = c;
181 }
183 {
184 assert(chgraph && "empty ICFG! Build SVF IR first!");
185 return chgraph;
186 }
187
190 {
191 callGraph = c;
192 }
194 {
195 assert(callGraph && "empty CallGraph! Build SVF IR first!");
196 return callGraph;
197 }
198
200
201
203 {
204 return KindToSVFStmtSetMap[kind];
205 }
212 inline bool hasSVFStmtList(const ICFGNode* inst) const
213 {
214 return icfgNode2SVFStmtsMap.find(inst) != icfgNode2SVFStmtsMap.end();
215 }
216 inline bool hasPTASVFStmtList(const ICFGNode* inst) const
217 {
218 return icfgNode2PTASVFStmtsMap.find(inst) !=
220 }
223 {
224 return icfgNode2SVFStmtsMap[inst];
225 }
228 {
229 return icfgNode2PTASVFStmtsMap[inst];
230 }
233 {
234 edge->setICFGNode(inst);
235 icfgNode2SVFStmtsMap[inst].push_back(edge);
236 if (edge->isPTAEdge())
237 icfgNode2PTASVFStmtsMap[inst].push_back(edge);
238 }
251 {
252 return globSVFStmtSet;
253 }
255 inline const CallSiteSet& getCallSiteSet() const
256 {
257 return callSiteSet;
258 }
260 inline bool isPhiNode(const SVFVar* node) const
261 {
262 return phiNodeMap.find(node) != phiNodeMap.end();
263 }
264
266 inline bool hasFunArgsList(const SVFFunction* func) const
267 {
268 return (funArgsListMap.find(func) != funArgsListMap.end());
269 }
272 {
273 return funArgsListMap;
274 }
276 inline const SVFVarList& getFunArgsList(const SVFFunction* func) const
277 {
278 FunToArgsListMap::const_iterator it = funArgsListMap.find(func);
279 assert(it != funArgsListMap.end() && "this function doesn't have arguments");
280 return it->second;
281 }
283 inline bool hasCallSiteArgsMap(const CallICFGNode* cs) const
284 {
285 return (callSiteArgsListMap.find(cs) != callSiteArgsListMap.end());
286 }
289 {
290 return callSiteArgsListMap;
291 }
293 inline const SVFVarList& getCallSiteArgsList(const CallICFGNode* cs) const
294 {
295 CSToArgsListMap::const_iterator it = callSiteArgsListMap.find(cs);
296 assert(it != callSiteArgsListMap.end() && "this call site doesn't have arguments");
297 return it->second;
298 }
301 {
302 return callSiteRetMap;
303 }
305 inline const SVFVar* getCallSiteRet(const RetICFGNode* cs) const
306 {
307 CSToRetMap::const_iterator it = callSiteRetMap.find(cs);
308 assert(it != callSiteRetMap.end() && "this call site doesn't have return");
309 return it->second;
310 }
311 inline bool callsiteHasRet(const RetICFGNode* cs) const
312 {
313 return callSiteRetMap.find(cs) != callSiteRetMap.end();
314 }
317 {
318 return funRetMap;
319 }
321 inline const SVFVar* getFunRet(const SVFFunction* func) const
322 {
323 FunToRetMap::const_iterator it = funRetMap.find(func);
324 assert(it != funRetMap.end() && "this function doesn't have return");
325 return it->second;
326 }
327 inline bool funHasRet(const SVFFunction* func) const
328 {
329 return funRetMap.find(func) != funRetMap.end();
330 }
332
334
336 {
337 return GepValObjMap.size();
338 }
340 {
341 return GepObjVarMap.size();
342 }
344
347 const AccessPath& ap) const;
348
350
352 {
354 }
355 inline NodeID getFunPtr(const CallICFGNode* cs) const
356 {
357 CallSiteToFunPtrMap::const_iterator it = indCallSiteToFunPtrMap.find(cs);
358 assert(it!=indCallSiteToFunPtrMap.end() && "indirect callsite not have a function pointer?");
359 return it->second;
360 }
362 {
363 FunPtrToCallSitesMap::const_iterator it = funPtrToCallSitesMap.find(funPtr);
364 assert(it!=funPtrToCallSitesMap.end() && "function pointer not used at any indirect callsite?");
365 return it->second;
366 }
367 inline bool isIndirectCallSites(const CallICFGNode* cs) const
368 {
369 return (indCallSiteToFunPtrMap.find(cs) != indCallSiteToFunPtrMap.end());
370 }
371 inline bool isFunPtr(NodeID id) const
372 {
373 return (funPtrToCallSitesMap.find(id) != funPtrToCallSitesMap.end());
374 }
376
379 {
380 return getIntraPAGEdge(getGNode(src), getGNode(dst), kind);
381 }
383 {
384 SVFStmt edge(src, dst, kind, false);
386 SVFStmt::SVFStmtSetTy::const_iterator it = edgeSet.find(&edge);
387 assert(it != edgeSet.end() && "can not find pag edge");
388 return (*it);
389 }
391
395
396 inline const MemObj* getObject(NodeID id) const
397 {
398 const SVFVar* node = getGNode(id);
399 if (const ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(node))
400 return getObject(objPN);
401 else
402 return nullptr;
403 }
404
405 inline const BaseObjVar* getBaseObject(NodeID id) const
406 {
407 const SVFVar* node = getGNode(id);
408 if(const GepObjVar* gepObjVar = SVFUtil::dyn_cast<GepObjVar>(node))
409 return SVFUtil::dyn_cast<BaseObjVar>(
410 getGNode(gepObjVar->getBaseNode()));
411 else
412 return SVFUtil::dyn_cast<BaseObjVar>(node);
413 }
414
415 inline const ValVar* getBaseValVar(NodeID id) const
416 {
417 const SVFVar* node = getGNode(id);
418 if(const GepValVar* gepVar = SVFUtil::dyn_cast<GepValVar>(node))
419 return SVFUtil::dyn_cast<ValVar>(
420 getGNode(gepVar->getBaseNode()));
421 else
422 return SVFUtil::dyn_cast<ValVar>(node);
423 }
424
425 inline const MemObj*getObject(const ObjVar* node) const
426 {
427 return node->getMemObj();
428 }
430
432 NodeID getGepObjVar(const MemObj* obj, const APOffset& ap);
434 NodeID getGepObjVar(NodeID id, const APOffset& ap) ;
436
437 inline NodeID getFIObjVar(const MemObj* obj) const
438 {
439 return obj->getId();
440 }
441 inline NodeID getFIObjVar(NodeID id) const
442 {
443 return getBaseObjVar(id);
444 }
446
448
449 inline bool isBlkPtr(NodeID id) const
450 {
451 return (SymbolTableInfo::isBlkPtr(id));
452 }
453 inline bool isNullPtr(NodeID id) const
454 {
455 return (SymbolTableInfo::isNullPtr(id));
456 }
457 inline bool isBlkObjOrConstantObj(NodeID id) const
458 {
459 return (isBlkObj(id) || isConstantObj(id));
460 }
461 inline bool isBlkObj(NodeID id) const
462 {
463 return SymbolTableInfo::isBlkObj(id);
464 }
465 inline bool isConstantObj(NodeID id) const
466 {
467 const MemObj* obj = getObject(id);
468 assert(obj && "not an object node?");
470 obj->isConstDataOrConstGlobal();
471 }
473
475
476
477 inline NodeID getBaseObjVar(NodeID id) const
478 {
479 return getBaseObj(id)->getId();
480 }
481 inline const MemObj* getBaseObj(NodeID id) const
482 {
483 const SVFVar* node = pag->getGNode(id);
484 assert(SVFUtil::isa<ObjVar>(node) && "need an object node");
485 const ObjVar* obj = SVFUtil::cast<ObjVar>(node);
486 return obj->getMemObj();
487 }
489
491
497 {
498 return addDummyValNode(NodeIDAllocator::get()->allocateValueId());
499 }
501 {
502 return addDummyObjNode(NodeIDAllocator::get()->allocateObjectId(), type);
503 }
505
506 bool isValidPointer(NodeID nodeId) const;
507
508 bool isValidTopLevelPtr(const SVFVar* node);
510
512 void print();
513
514private:
515
518 {
519 bool added = KindToSVFStmtSetMap[edge->getEdgeKind()].insert(edge).second;
520 (void)added; // Suppress warning of unused variable under release build
521 assert(added && "duplicated edge, not added!!!");
523 if (edge->isPTAEdge() || (SVFUtil::isa<CopyStmt>(edge) && SVFUtil::cast<CopyStmt>(edge)->isInt2Ptr()))
524 {
526 KindToPTASVFStmtSetMap[edge->getEdgeKind()].insert(edge);
527 }
528 }
530
531
532 inline void addFunArgs(const SVFFunction* fun, const SVFVar* arg)
533 {
536 funArgsListMap[fun].push_back(arg);
537 }
539 inline void addFunRet(const SVFFunction* fun, const SVFVar* ret)
540 {
543 funRetMap[fun] = ret;
544 }
546 inline void addCallSiteArgs(CallICFGNode* callBlockNode,const ValVar* arg)
547 {
548 callBlockNode->addActualParms(arg);
549 callSiteArgsListMap[callBlockNode].push_back(arg);
550 }
553 {
554 retBlockNode->addActualRet(arg);
556 }
559 {
560 bool added = indCallSiteToFunPtrMap.emplace(cs, funPtr).second;
561 (void) added;
562 funPtrToCallSitesMap[funPtr].insert(cs);
563 assert(added && "adding the same indirect callsite twice?");
564 }
565
567
568
569 inline NodeID addValNode(const SVFValue* val, NodeID i, const ICFGNode* icfgNode)
570 {
571 SVFVar *node = new ValVar(val,i, ValVar::ValNode, icfgNode);
572 return addValNode(val, node, i);
573 }
574
575 NodeID addFunValNode(const CallGraphNode* callGraphNode, NodeID i, const ICFGNode* icfgNode)
576 {
577 FunValVar* node = new FunValVar(callGraphNode, i, icfgNode);
578 return addValNode(nullptr, node, i);
579 }
580
581 inline NodeID addConstantFPValNode(const SVFValue* curInst, double dval, const NodeID i,
582 const ICFGNode* icfgNode)
583 {
584 SVFVar* node = new ConstantFPValVar(curInst, dval, i, icfgNode);
585 return addNode(node, i);
586 }
587
588 inline NodeID addConstantIntValNode(const SVFValue* curInst, s64_t sval, u64_t zval, const NodeID i,
589 const ICFGNode* icfgNode)
590 {
591 SVFVar* node = new ConstantIntValVar(curInst, sval, zval, i, icfgNode);
592 return addNode(node, i);
593 }
594
595 inline NodeID addConstantNullPtrValNode(const SVFValue* curInst, const NodeID i, const ICFGNode* icfgNode)
596 {
597 SVFVar* node = new ConstantNullPtrValVar(curInst, i, icfgNode);
598 return addNode(node, i);
599 }
600
601 inline NodeID addGlobalValueValNode(const SVFValue* curInst, const NodeID i, const ICFGNode* icfgNode)
602 {
603 SVFVar* node = new GlobalValVar(curInst, i, icfgNode);
604 return addNode(node, i);
605 }
606
607 inline NodeID addConstantDataValNode(const SVFValue* curInst, const NodeID i, const ICFGNode* icfgNode)
608 {
609 SVFVar* node = new ConstantDataValVar(curInst, i, icfgNode);
610 return addNode(node, i);
611 }
612
613
616 {
617 const MemObj* mem = getMemObj(val);
618 assert(mem->getId() == i && "not same object id?");
619 return addFIObjNode(mem);
620 }
621
626 {
627 const MemObj* mem = getMemObj(val);
628 assert(mem->getId() == i && "not same object id?");
629 memToFieldsMap[i].set(i);
630 HeapObjVar *node = new HeapObjVar(f, val->getType(), i, mem);
631 return addObjNode(val, node, i);
632 }
633
638 {
639 const MemObj* mem = getMemObj(val);
640 assert(mem->getId() == i && "not same object id?");
641 memToFieldsMap[i].set(i);
642 StackObjVar *node = new StackObjVar(f, val->getType(), i, mem);
643 return addObjNode(val, node, i);
644 }
645
646 NodeID addFunObjNode(const CallGraphNode* callGraphNode, NodeID id);
647
648
649 inline NodeID addConstantFPObjNode(const SVFValue* curInst, double dval, const NodeID i)
650 {
651 const MemObj* mem = getMemObj(curInst);
652 NodeID base = mem->getId();
653 memToFieldsMap[base].set(mem->getId());
654 ConstantFPObjVar* node = new ConstantFPObjVar(curInst, dval, mem->getId(), mem);
655 return addObjNode(curInst, node, mem->getId());
656 }
657
658
659 inline NodeID addConstantIntObjNode(const SVFValue* curInst, s64_t sval, u64_t zval, const NodeID i)
660 {
661 const MemObj* mem = getMemObj(curInst);
662 NodeID base = mem->getId();
663 memToFieldsMap[base].set(mem->getId());
664 ConstantIntObjVar* node =
665 new ConstantIntObjVar(curInst, sval, zval, mem->getId(), mem);
666 return addObjNode(curInst, node, mem->getId());
667 }
668
669
671 {
672 const MemObj* mem = getMemObj(curInst);
673 NodeID base = mem->getId();
674 memToFieldsMap[base].set(mem->getId());
676 return addObjNode(mem->getValue(), node, mem->getId());
677 }
678
680 {
681 const MemObj* mem = getMemObj(curInst);
682 NodeID base = mem->getId();
683 memToFieldsMap[base].set(mem->getId());
684 GlobalObjVar* node = new GlobalObjVar(curInst, mem->getId(), mem);
685 return addObjNode(mem->getValue(), node, mem->getId());
686 }
687
689 {
690 const MemObj* mem = getMemObj(curInst);
691 NodeID base = mem->getId();
692 memToFieldsMap[base].set(mem->getId());
693 ConstantDataObjVar* node = new ConstantDataObjVar(curInst, mem->getId(), mem);
694 return addObjNode(mem->getValue(), node, mem->getId());
695 }
696
698 inline NodeID addRetNode(const CallGraphNode* callGraphNode, NodeID i)
699 {
700 SVFVar *node = new RetPN(callGraphNode,i);
701 return addRetNode(callGraphNode, node, i);
702 }
705 {
706 SVFVar *node = new VarArgPN(val,i);
707 return addNode(node,i);
708 }
709
711 NodeID addGepValNode(const SVFValue* curInst,const SVFValue* val, const AccessPath& ap, NodeID i, const SVFType* type);
713 NodeID addGepObjNode(const MemObj* obj, const APOffset& apOffset, const NodeID gepId);
716
718
720
722 {
723 return addValNode(nullptr, new DummyValVar(i), i);
724 }
726 {
727 const MemObj* mem = addDummyMemObj(i, type);
728 return addObjNode(nullptr, new DummyObjVar(i,mem), i);
729 }
730 inline const MemObj* addDummyMemObj(NodeID i, const SVFType* type)
731 {
733 }
735 {
736 return addObjNode(
739 }
741 {
742 return addObjNode(nullptr,
745 }
747 {
748 return addDummyValNode(getBlkPtr());
749 }
751
753 inline NodeID addValNode(const SVFValue*, SVFVar *node, NodeID i)
754 {
755 assert(hasGNode(i) == false &&
756 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
757 "Strategy::DBUG to SEQ or DENSE");
758 return addNode(node, i);
759 }
761 inline NodeID addObjNode(const SVFValue*, SVFVar *node, NodeID i)
762 {
763 assert(hasGNode(i) == false &&
764 "This NodeID clashes here. Please check NodeIDAllocator. Switch "
765 "Strategy::DBUG to SEQ or DENSE");
766 return addNode(node, i);
767 }
770 {
771 return addNode(node,i);
772 }
775 {
776 return addNode(node,i);
777 }
778
780 inline void addGlobalPAGEdge(const SVFStmt* edge)
781 {
782 globSVFStmtSet.insert(edge);
783 }
785 inline void addCallSite(const CallICFGNode* call)
786 {
787 callSiteSet.insert(call);
788 }
790
791
795
804 u32_t opcode);
806 UnaryOPStmt* addUnaryOPStmt(NodeID src, NodeID dst, u32_t opcode);
813 StoreStmt* addStoreStmt(NodeID src, NodeID dst, const ICFGNode* val);
815 CallPE* addCallPE(NodeID src, NodeID dst, const CallICFGNode* cs,
816 const FunEntryICFGNode* entry);
818 RetPE* addRetPE(NodeID src, NodeID dst, const CallICFGNode* cs,
819 const FunExitICFGNode* exit);
821 GepStmt* addGepStmt(NodeID src, NodeID dst, const AccessPath& ap,
822 bool constGep);
824 GepStmt* addNormalGepStmt(NodeID src, NodeID dst, const AccessPath& ap);
826 GepStmt* addVariantGepStmt(NodeID src, NodeID dst, const AccessPath& ap);
829 const FunEntryICFGNode* entry);
832 const FunExitICFGNode* exit);
834
837};
838
839typedef SVFIR PAG;
840
841} // End namespace SVF
842
843
844
845#endif /* INCLUDE_SVFIR_H_ */
newitem type
Definition cJSON.cpp:2739
const cJSON *const b
Definition cJSON.h:255
std::vector< std::pair< const ICFGNode *, s32_t > > SuccAndCondPairVec
void addActualParms(const ValVar *ap)
Add actual parameters.
Definition ICFGNode.h:494
Common base for class hierarchy graph. Only implements what PointerAnalysis needs.
Definition CHG.h:51
void addFormalParms(const SVFVar *fp)
Add formal parameters.
Definition ICFGNode.h:307
void addFormalRet(const SVFVar *fr)
Add formal return parameter.
Definition ICFGNode.h:378
bool hasGNode(NodeID id) const
Has a node.
NodeType * getGNode(NodeID id) const
Get a node.
Class representing a heap object variable in the SVFIR.
FunEntryICFGNode * getFunEntryICFGNode(const SVFFunction *fun)
Add a function entry node.
Definition ICFG.cpp:234
NodeID totalICFGNode
Definition ICFG.h:66
FunExitICFGNode * getFunExitICFGNode(const SVFFunction *fun)
Add a function exit node.
Definition ICFG.cpp:241
const MemObj * getConstantObj() const
Definition IRGraph.h:181
Set< const SVFStmt * > SVFStmtSet
Definition IRGraph.h:55
NodeID getBlkPtr() const
Definition IRGraph.h:169
NodeID getBlackHoleNode() const
Definition IRGraph.h:161
SVFStmt::KindToSVFStmtMapTy KindToSVFStmtSetMap
SVFIR edge map containing all PAGEdges.
Definition IRGraph.h:59
const MemObj * getBlackHoleObj() const
Definition IRGraph.h:177
NodeID addNode(SVFVar *node, NodeID i)
Add a node into the graph.
Definition IRGraph.h:68
SymbolTableInfo * getSymbolInfo() const
Definition IRGraph.h:114
u32_t totalPTAPAGEdge
Definition IRGraph.h:63
const MemObj * getMemObj(const SVFValue *val) const
get MemObj according to LLVM value
Definition IRGraph.h:98
NodeID getConstantNode() const
Definition IRGraph.h:165
SVFStmt::KindToSVFStmtMapTy KindToPTASVFStmtSetMap
SVFIR edge map containing only pointer-related edges, i.e., both LHS and RHS are of pointer type.
Definition IRGraph.h:60
SymID getId() const
Get the memory object id.
const SVFValue * getValue() const
Get the reference value to this object.
static NodeIDAllocator * get(void)
Return (singleton) allocator.
const MemObj * getMemObj() const
Return memory object.
static void releaseSVFIR()
Definition SVFIR.h:124
const CallSiteSet & getCallSiteSet() const
Get all callsites.
Definition SVFIR.h:255
CSToArgsListMap & getCallSiteArgsMap()
Get callsite argument list.
Definition SVFIR.h:288
SVFStmt::SVFStmtSetTy & getPTASVFStmtSet(SVFStmt::PEDGEK kind)
Get PTA edges set according to its kind.
Definition SVFIR.h:207
bool hasPTASVFStmtList(const ICFGNode *inst) const
Definition SVFIR.h:216
NodeID addFIObjNode(const MemObj *obj)
Add a field-insensitive node, this method can only invoked by getFIGepObjNode.
Definition SVFIR.cpp:466
NodeID addVarargNode(const SVFFunction *, SVFVar *node, NodeID i)
Add a unique vararg node for a procedure.
Definition SVFIR.h:774
GepStmt * addVariantGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Variant(Gep) edge.
Definition SVFIR.cpp:366
SVFStmt::SVFStmtSetTy & getSVFStmtSet(SVFStmt::PEDGEK kind)
Get/set methods to get SVFStmts based on their kinds and ICFGNodes.
Definition SVFIR.h:202
Map< const SVFVar *, PhiStmt * > PHINodeMap
Definition SVFIR.h:61
NodeOffsetMap GepObjVarMap
Map a pair<base,off> to a gep obj node id.
Definition SVFIR.h:85
CallSiteToFunPtrMap indCallSiteToFunPtrMap
Map an indirect callsite to its function pointer.
Definition SVFIR.h:93
CopyStmt * addCopyStmt(NodeID src, NodeID dst, CopyStmt::CopyKind type)
Add Copy edge.
Definition SVFIR.cpp:65
CSToRetMap callSiteRetMap
Map a callsite to its callsite returns PAGNodes.
Definition SVFIR.h:91
NodeID addStackObjNode(const SVFValue *val, const SVFFunction *f, NodeID i)
Definition SVFIR.h:637
CallGraph * getCallGraph()
Definition SVFIR.h:193
bool isBlkObj(NodeID id) const
Definition SVFIR.h:461
RetPE * addRetPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Return edge.
Definition SVFIR.cpp:260
NodeID getFunPtr(const CallICFGNode *cs) const
Definition SVFIR.h:355
bool isNullPtr(NodeID id) const
Definition SVFIR.h:453
GepStmt * addGepStmt(NodeID src, NodeID dst, const AccessPath &ap, bool constGep)
Add Gep edge.
Definition SVFIR.cpp:328
NodeID addObjNode(const SVFValue *val, NodeID i)
Add a memory obj node.
Definition SVFIR.h:615
NodeID addGlobalValueObjNode(const SVFValue *curInst, const NodeID i)
Definition SVFIR.h:679
void print()
Print SVFIR.
Definition SVFIR.cpp:566
static void handleBlackHole(bool b)
SVFIR build configurations.
Definition SVFIR.cpp:706
const MemObj * addDummyMemObj(NodeID i, const SVFType *type)
Definition SVFIR.h:730
NodeID getFIObjVar(const MemObj *obj) const
Get a field-insensitive obj SVFIR node according to a mem obj.
Definition SVFIR.h:437
void addToStmt2TypeMap(SVFStmt *edge)
Map a SVFStatement type to a set of corresponding SVF statements.
Definition SVFIR.h:517
friend class ExternalPAG
Definition SVFIR.h:47
NodeID addBlackholePtrNode()
Definition SVFIR.h:746
Set< const CallICFGNode * > CallSiteSet
Definition SVFIR.h:55
NodeID addBlackholeObjNode()
Definition SVFIR.h:734
const MemObj * getObject(const ObjVar *node) const
Definition SVFIR.h:425
CommonCHGraph * chgraph
Definition SVFIR.h:100
Map< const CallICFGNode *, SVFVarList > CSToArgsListMap
Definition SVFIR.h:63
SVFStmt * addBlackHoleAddrStmt(NodeID node)
Set a pointer points-to black hole (e.g. int2ptr)
Definition SVFIR.cpp:278
NodeID addDummyObjNode(NodeID i, const SVFType *type)
Definition SVFIR.h:725
LoadStmt * addLoadStmt(NodeID src, NodeID dst)
Add Load edge.
Definition SVFIR.cpp:205
GepStmt * addNormalGepStmt(NodeID src, NodeID dst, const AccessPath &ap)
Add Offset(Gep) edge.
Definition SVFIR.cpp:347
u32_t getFieldObjNodeNum() const
Definition SVFIR.h:339
MemObjToFieldsMap memToFieldsMap
Map a mem object id to all its fields.
Definition SVFIR.h:86
Map< const RetICFGNode *, const SVFVar * > CSToRetMap
Definition SVFIR.h:64
virtual ~SVFIR()
Destructor.
Definition SVFIR.h:148
NodeID addGlobalValueValNode(const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
Definition SVFIR.h:601
bool isIndirectCallSites(const CallICFGNode *cs) const
Definition SVFIR.h:367
SVFStmt * getIntraPAGEdge(SVFVar *src, SVFVar *dst, SVFStmt::PEDGEK kind)
Definition SVFIR.h:382
PHINodeMap phiNodeMap
A set of phi copy edges.
Definition SVFIR.h:88
NodeBS getFieldsAfterCollapse(NodeID id)
Definition SVFIR.cpp:511
std::pair< NodeID, APOffset > NodeOffset
Definition SVFIR.h:69
Map< const SVFFunction *, SVFVarList > FunToArgsListMap
Definition SVFIR.h:62
Map< const ICFGNode *, SVFStmtList > ICFGNode2SVFStmtsMap
Definition SVFIR.h:67
FunToRetMap funRetMap
Map a function to its unique function return PAGNodes.
Definition SVFIR.h:92
OrderedMap< const CallICFGNode *, NodeID > CallSiteToFunPtrMap
Definition SVFIR.h:56
void setModule(SVFModule *mod)
Set/Get LLVM Module.
Definition SVFIR.h:158
void addFunRet(const SVFFunction *fun, const SVFVar *ret)
Add function returns.
Definition SVFIR.h:539
NodeID addGepValNode(const SVFValue *curInst, const SVFValue *val, const AccessPath &ap, NodeID i, const SVFType *type)
Add a temp field value node, this method can only invoked by getGepValVar.
Definition SVFIR.cpp:387
NodeID addConstantIntValNode(const SVFValue *curInst, s64_t sval, u64_t zval, const NodeID i, const ICFGNode *icfgNode)
Definition SVFIR.h:588
CallPE * addCallPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Call edge.
Definition SVFIR.cpp:242
SVFStmtList & getSVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PAGEdges.
Definition SVFIR.h:222
bool isValidTopLevelPtr(const SVFVar *node)
Definition SVFIR.cpp:685
bool isConstantObj(NodeID id) const
Definition SVFIR.h:465
NodeID addConstantFPObjNode(const SVFValue *curInst, double dval, const NodeID i)
Definition SVFIR.h:649
bool isPhiNode(const SVFVar *node) const
Whether this SVFVar is a result operand a of phi node.
Definition SVFIR.h:260
OrderedNodeSet & getAllValidPtrs()
Return valid pointers.
Definition SVFIR.h:140
NodeID addConstantNullPtrObjNode(const SVFValue *curInst, const NodeID i)
Definition SVFIR.h:670
NodeID addValNode(const SVFValue *val, NodeID i, const ICFGNode *icfgNode)
add node into SVFIR
Definition SVFIR.h:569
bool hasSVFStmtList(const ICFGNode *inst) const
Whether this instruction has SVFIR Edge.
Definition SVFIR.h:212
TypeLocSetsMap typeLocSetsMap
Map an arg to its base SVFType* and all its field location sets.
Definition SVFIR.h:84
std::vector< const SVFVar * > SVFVarList
Definition SVFIR.h:60
TDJoinPE * addThreadJoinPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunExitICFGNode *exit)
Add Thread join edge for parameter passing.
Definition SVFIR.cpp:307
CallGraph * callGraph
all the callsites of a program
Definition SVFIR.h:102
Map< NodeID, NodeID > NodeToNodeMap
Definition SVFIR.h:68
const SVFVarList & getFunArgsList(const SVFFunction *func) const
Get function arguments list.
Definition SVFIR.h:276
CSToRetMap & getCallSiteRets()
Get callsite return.
Definition SVFIR.h:300
void destroy()
Clean up memory.
Definition SVFIR.cpp:551
NodeID addGepObjNode(const MemObj *obj, const APOffset &apOffset, const NodeID gepId)
Add a field obj node, this method can only invoked by getGepObjVar.
Definition SVFIR.cpp:450
NodeID addConstantFPValNode(const SVFValue *curInst, double dval, const NodeID i, const ICFGNode *icfgNode)
Definition SVFIR.h:581
bool isBlkPtr(NodeID id) const
Get black hole and constant id.
Definition SVFIR.h:449
void addToSVFStmtList(ICFGNode *inst, SVFStmt *edge)
Add a SVFStmt into instruction map.
Definition SVFIR.h:232
NodeID addDummyValNode(NodeID i)
Add a dummy value/object node according to node ID (llvm value is null)
Definition SVFIR.h:721
std::vector< const SVFStmt * > SVFStmtList
Definition SVFIR.h:59
const BaseObjVar * getBaseObject(NodeID id) const
Definition SVFIR.h:405
NodeID addFunValNode(const CallGraphNode *callGraphNode, NodeID i, const ICFGNode *icfgNode)
Definition SVFIR.h:575
SVFStmtSet globSVFStmtSet
Global PAGEdges without control flow information.
Definition SVFIR.h:87
NodeBS & getAllFieldsObjVars(const MemObj *obj)
Get all fields of an object.
Definition SVFIR.cpp:489
void addCallSiteRets(RetICFGNode *retBlockNode, const SVFVar *arg)
Add callsite returns.
Definition SVFIR.h:552
std::pair< NodeID, AccessPath > NodeAccessPath
Definition SVFIR.h:70
void setICFG(ICFG *i)
Set/Get ICFG.
Definition SVFIR.h:168
NodeID getBaseObjVar(NodeID id) const
Base and Offset methods for Value and Object node.
Definition SVFIR.h:477
Map< NodeAccessPath, NodeID > NodeAccessPathMap
Definition SVFIR.h:72
CmpStmt * addCmpStmt(NodeID op1, NodeID op2, NodeID dst, u32_t predict)
Add Copy edge.
Definition SVFIR.cpp:128
NodeID addConstantIntObjNode(const SVFValue *curInst, s64_t sval, u64_t zval, const NodeID i)
Definition SVFIR.h:659
FunToRetMap & getFunRets()
Get function return list.
Definition SVFIR.h:316
const MemObj * getBaseObj(NodeID id) const
Definition SVFIR.h:481
SVFStmtSet & getGlobalSVFStmtSet()
Get global PAGEdges (not in a procedure)
Definition SVFIR.h:250
NodeID addRetNode(const CallGraphNode *, SVFVar *node, NodeID i)
Add a unique return node for a procedure.
Definition SVFIR.h:769
void addCallSiteArgs(CallICFGNode *callBlockNode, const ValVar *arg)
Add callsite arguments.
Definition SVFIR.h:546
AddrStmt * addAddrStmt(NodeID src, NodeID dst)
Add an edge into SVFIR.
Definition SVFIR.cpp:47
FunToArgsListMap funArgsListMap
Map a function to a list of all its formal parameters.
Definition SVFIR.h:89
ICFGNode2SVFStmtsMap icfgNode2SVFStmtsMap
Map an ICFGNode to its SVFStmts.
Definition SVFIR.h:81
ICFG * getICFG() const
Definition SVFIR.h:172
u32_t getFieldValNodeNum() const
Node and edge statistics.
Definition SVFIR.h:335
UnaryOPStmt * addUnaryOPStmt(NodeID src, NodeID dst, u32_t opcode)
Add Unary edge.
Definition SVFIR.cpp:169
SVFModule * svfModule
Definition SVFIR.h:98
NodeID addConstantNullPtrValNode(const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
Definition SVFIR.h:595
std::pair< const SVFType *, std::vector< AccessPath > > SVFTypeLocSetsPair
Definition SVFIR.h:74
TDForkPE * addThreadForkPE(NodeID src, NodeID dst, const CallICFGNode *cs, const FunEntryICFGNode *entry)
Add Thread fork edge for parameter passing.
Definition SVFIR.cpp:289
bool isFunPtr(NodeID id) const
Definition SVFIR.h:371
SVFStmt * getIntraPAGEdge(NodeID src, NodeID dst, SVFStmt::PEDGEK kind)
Get an edge according to src, dst and kind.
Definition SVFIR.h:378
const SVFVar * getFunRet(const SVFFunction *func) const
Get function return list.
Definition SVFIR.h:321
BinaryOPStmt * addBinaryOPStmt(NodeID op1, NodeID op2, NodeID dst, u32_t opcode)
Add Copy edge.
Definition SVFIR.cpp:149
bool hasCallSiteArgsMap(const CallICFGNode *cs) const
Callsite has argument list.
Definition SVFIR.h:283
void addCallSite(const CallICFGNode *call)
Add callsites.
Definition SVFIR.h:785
static std::unique_ptr< SVFIR > pag
call graph
Definition SVFIR.h:104
StoreStmt * addStoreStmt(NodeID src, NodeID dst, const ICFGNode *val)
Add Store edge.
Definition SVFIR.cpp:224
void addToTypeLocSetsMap(NodeID argId, SVFTypeLocSetsPair &locSets)
Add a base SVFType* and all its field location sets to an arg NodeId.
Definition SVFIR.h:240
CSToArgsListMap callSiteArgsListMap
Map a callsite to a list of all its actual parameters.
Definition SVFIR.h:90
NodeID addRetNode(const CallGraphNode *callGraphNode, NodeID i)
Add a unique return node for a procedure.
Definition SVFIR.h:698
void setCHG(CommonCHGraph *c)
Set/Get CHG.
Definition SVFIR.h:178
SVFModule * getModule()
Definition SVFIR.h:162
NodeOffsetMap & getGepObjNodeMap()
Return GepObjVarMap.
Definition SVFIR.h:135
const CallSiteToFunPtrMap & getIndirectCallsites() const
Add/get indirect callsites.
Definition SVFIR.h:351
CommonCHGraph * getCHG()
Definition SVFIR.h:182
bool callsiteHasRet(const RetICFGNode *cs) const
Definition SVFIR.h:311
NodeID addDummyValNode()
Definition SVFIR.h:496
NodeID addVarargNode(const CallGraphNode *val, NodeID i)
Add a unique vararg node for a procedure.
Definition SVFIR.h:704
SVFStmtList & getPTASVFStmtList(const ICFGNode *inst)
Given an instruction, get all its PTA PAGEdges.
Definition SVFIR.h:227
ICFGNode2SVFStmtsMap icfgNode2PTASVFStmtsMap
Map an ICFGNode to its PointerAnalysis related SVFStmts.
Definition SVFIR.h:82
Map< NodeID, NodeBS > MemObjToFieldsMap
Definition SVFIR.h:58
Map< NodePair, NodeID > NodePairSetMap
Definition SVFIR.h:76
NodeID addHeapObjNode(const SVFValue *val, const SVFFunction *f, NodeID i)
Definition SVFIR.h:625
const MemObj * getObject(NodeID id) const
Definition SVFIR.h:396
PhiStmt * addPhiStmt(NodeID res, NodeID opnd, const ICFGNode *pred)
Add phi node information.
Definition SVFIR.cpp:83
OrderedNodeSet candidatePointers
Definition SVFIR.h:97
ICFG * icfg
SVF Module.
Definition SVFIR.h:99
void addFunArgs(const SVFFunction *fun, const SVFVar *arg)
Get/set method for function/callsite arguments and returns.
Definition SVFIR.h:532
bool hasFunArgsList(const SVFFunction *func) const
Function has arguments list.
Definition SVFIR.h:266
CallSiteSet callSiteSet
Definition SVFIR.h:101
friend class TypeBasedHeapCloning
Definition SVFIR.h:49
const SVFVarList & getCallSiteArgsList(const CallICFGNode *cs) const
Get callsite argument list.
Definition SVFIR.h:293
Map< const SVFFunction *, SVFStmtSet > FunToPAGEdgeSetMap
Definition SVFIR.h:66
NodeID addConstantDataValNode(const SVFValue *curInst, const NodeID i, const ICFGNode *icfgNode)
Definition SVFIR.h:607
NodeID getFIObjVar(NodeID id) const
Definition SVFIR.h:441
SelectStmt * addSelectStmt(NodeID res, NodeID op1, NodeID op2, NodeID cond)
Add SelectStmt.
Definition SVFIR.cpp:107
void setCallGraph(CallGraph *c)
Set/Get CG.
Definition SVFIR.h:189
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:116
NodeID addConstantDataObjNode(const SVFValue *curInst, const NodeID i)
Definition SVFIR.h:688
NodeID getGepValVar(const SVFValue *curInst, NodeID base, const AccessPath &ap) const
Due to constraint expression, curInst is used to distinguish different instructions (e....
Definition SVFIR.cpp:529
Map< NodeID, SVFTypeLocSetsPair > TypeLocSetsMap
Definition SVFIR.h:75
GepValueVarMap GepValObjMap
Map a pair<base,off> to a gep value node id.
Definition SVFIR.h:83
const ValVar * getBaseValVar(NodeID id) const
Definition SVFIR.h:415
NodeID addFunObjNode(const CallGraphNode *callGraphNode, NodeID id)
Definition SVFIR.cpp:475
bool isBlkObjOrConstantObj(NodeID id) const
Definition SVFIR.h:457
const CallSiteSet & getIndCallSites(NodeID funPtr) const
Definition SVFIR.h:361
bool isValidPointer(NodeID nodeId) const
Whether a node is a valid pointer.
Definition SVFIR.cpp:667
Map< NodeID, CallSiteSet > FunPtrToCallSitesMap
Definition SVFIR.h:57
const SVFVar * getCallSiteRet(const RetICFGNode *cs) const
Get callsite return.
Definition SVFIR.h:305
NodeID getGepObjVar(const MemObj *obj, const APOffset &ap)
Get a field SVFIR Object node according to base mem obj and offset.
Definition SVFIR.cpp:423
Map< const SVFFunction *, const SVFVar * > FunToRetMap
Definition SVFIR.h:65
void addGlobalPAGEdge(const SVFStmt *edge)
Add global PAGEdges (not in a procedure)
Definition SVFIR.h:780
BranchStmt * addBranchStmt(NodeID br, NodeID cond, const BranchStmt::SuccAndCondPairVec &succs)
Add BranchStmt.
Definition SVFIR.cpp:187
Map< NodeOffset, NodeID > NodeOffsetMap
Definition SVFIR.h:71
NodeID addValNode(const SVFValue *, SVFVar *node, NodeID i)
Add a value (pointer) node.
Definition SVFIR.h:753
void addIndirectCallsites(const CallICFGNode *cs, NodeID funPtr)
Add indirect callsites.
Definition SVFIR.h:558
FunToArgsListMap & getFunArgsMap()
Get function arguments list.
Definition SVFIR.h:271
void initialiseCandidatePointers()
Initialize candidate pointers.
Definition SVFIR.cpp:651
Map< const SVFValue *, NodeAccessPathMap > GepValueVarMap
Definition SVFIR.h:73
NodeID addObjNode(const SVFValue *, SVFVar *node, NodeID i)
Add a memory obj node.
Definition SVFIR.h:761
FunPtrToCallSitesMap funPtrToCallSitesMap
Definition SVFIR.h:94
SVFTypeLocSetsPair & getTypeLocSetsMap(NodeID argId)
Given an arg NodeId, get its base SVFType* and all its field location sets.
Definition SVFIR.h:245
NodeID addDummyObjNode(const SVFType *type)
Definition SVFIR.h:500
MemObjToFieldsMap & getMemToFieldsMap()
Return memToFieldsMap.
Definition SVFIR.h:130
bool funHasRet(const SVFFunction *func) const
Definition SVFIR.h:327
NodeID addConstantObjNode()
Definition SVFIR.h:740
GenericNode< SVFVar, SVFStmt >::GEdgeSetTy SVFStmtSetTy
Represents a stack-allocated object variable in the SVFIR (SVF Intermediate Representation) @inherits...
static bool isConstantObj(NodeID id)
static bool isBlkPtr(NodeID id)
special value
static bool isNullPtr(NodeID id)
static bool isBlkObj(NodeID id)
const MemObj * createDummyObj(SymID symId, const SVFType *type)
Can only be invoked by SVFIR::addDummyNode() when creating SVFIR from file.
for isBitcode
Definition BasicTypes.h:68
unsigned long long u64_t
Definition GeneralType.h:48
OrderedSet< NodeID > OrderedNodeSet
u32_t NodeID
Definition GeneralType.h:55
s64_t APOffset
Definition GeneralType.h:60
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74
SVFIR PAG
Definition SVFIR.h:839
unsigned u32_t
Definition GeneralType.h:46
signed long long s64_t
Definition GeneralType.h:49