From f057dfe5ffb03c51351d95d50be8f52dc583fda3 Mon Sep 17 00:00:00 2001 From: hwg Date: Mon, 21 Oct 2024 16:04:38 +1100 Subject: [PATCH] rename CallGraph to PTACallGraph --- svf-llvm/include/SVF-LLVM/LLVMModule.h | 2 +- svf-llvm/include/SVF-LLVM/SVFIRBuilder.h | 2 +- svf-llvm/lib/LLVMModule.cpp | 2 +- svf-llvm/lib/LLVMUtil.cpp | 2 +- svf-llvm/lib/SVFIRBuilder.cpp | 10 +- svf-llvm/tools/AE/ae.cpp | 2 +- svf-llvm/tools/Example/svf-ex.cpp | 2 +- .../AE/Svfexe/AbstractInterpretation.h | 2 +- svf/include/DDA/DDAVFSolver.h | 10 +- svf/include/Graphs/ICFG.h | 4 +- .../Graphs/{CallGraph.h => PTACallGraph.h} | 86 +++++----- svf/include/Graphs/ThreadCallGraph.h | 56 +++--- svf/include/Graphs/VFG.h | 10 +- svf/include/MSSA/MemRegion.h | 8 +- svf/include/MTA/LockAnalysis.h | 2 +- svf/include/MTA/MHP.h | 4 +- svf/include/MTA/TCT.h | 12 +- svf/include/MemoryModel/PointerAnalysis.h | 18 +- svf/include/SABER/SaberSVFGBuilder.h | 2 +- svf/include/SABER/SrcSnkDDA.h | 4 +- svf/include/SVFIR/SVFIR.h | 8 +- svf/include/Util/CallGraphBuilder.h | 4 +- svf/lib/DDA/DDAClient.cpp | 4 +- svf/lib/Graphs/ICFG.cpp | 16 +- .../{CallGraph.cpp => PTACallGraph.cpp} | 159 +++++++++--------- svf/lib/Graphs/SVFG.cpp | 8 +- svf/lib/Graphs/SVFGReadWrite.cpp | 8 +- svf/lib/Graphs/SVFGStat.cpp | 2 +- svf/lib/Graphs/ThreadCallGraph.cpp | 24 +-- svf/lib/Graphs/VFG.cpp | 2 +- svf/lib/MSSA/MemRegion.cpp | 14 +- svf/lib/MSSA/MemSSA.cpp | 2 +- svf/lib/MSSA/SVFGBuilder.cpp | 2 +- svf/lib/MTA/LockAnalysis.cpp | 36 ++-- svf/lib/MTA/MHP.cpp | 38 ++--- svf/lib/MTA/TCT.cpp | 50 +++--- svf/lib/MemoryModel/PointerAnalysis.cpp | 6 +- svf/lib/SABER/LeakChecker.cpp | 8 +- svf/lib/SABER/SaberCondAllocator.cpp | 2 +- svf/lib/SABER/SaberSVFGBuilder.cpp | 6 +- svf/lib/Util/CDGBuilder.cpp | 4 +- svf/lib/Util/CallGraphBuilder.cpp | 6 +- svf/lib/Util/PTAStat.cpp | 24 +-- svf/lib/Util/SVFStat.cpp | 2 +- svf/lib/Util/SVFUtil.cpp | 8 +- svf/lib/Util/ThreadAPI.cpp | 4 +- svf/lib/WPA/VersionedFlowSensitive.cpp | 2 +- 47 files changed, 348 insertions(+), 341 deletions(-) rename svf/include/Graphs/{CallGraph.h => PTACallGraph.h} (80%) rename svf/lib/Graphs/{CallGraph.cpp => PTACallGraph.cpp} (58%) diff --git a/svf-llvm/include/SVF-LLVM/LLVMModule.h b/svf-llvm/include/SVF-LLVM/LLVMModule.h index 7b5a81e38..fa56bca99 100644 --- a/svf-llvm/include/SVF-LLVM/LLVMModule.h +++ b/svf-llvm/include/SVF-LLVM/LLVMModule.h @@ -105,7 +105,7 @@ class LLVMModuleSet InstToBlockNodeMapTy InstToBlockNodeMap; ///< map a basic block to its ICFGNode FunToFunEntryNodeMapTy FunToFunEntryNodeMap; ///< map a function to its FunExitICFGNode FunToFunExitNodeMapTy FunToFunExitNodeMap; ///< map a function to its FunEntryICFGNode - CallGraph* callgraph; + PTACallGraph* callgraph; /// Constructor LLVMModuleSet(); diff --git a/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h b/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h index 15ea462cb..fe67316be 100644 --- a/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h +++ b/svf-llvm/include/SVF-LLVM/SVFIRBuilder.h @@ -201,7 +201,7 @@ class SVFIRBuilder: public llvm::InstVisitor //}@ /// connect PAG edges based on callgraph - void updateCallGraph(CallGraph* callgraph); + void updateCallGraph(PTACallGraph* callgraph); protected: /// Handle globals including (global variable and functions) diff --git a/svf-llvm/lib/LLVMModule.cpp b/svf-llvm/lib/LLVMModule.cpp index a2ac9076d..5ecc89316 100644 --- a/svf-llvm/lib/LLVMModule.cpp +++ b/svf-llvm/lib/LLVMModule.cpp @@ -41,7 +41,7 @@ #include "SVF-LLVM/ObjTypeInference.h" #include "llvm/Transforms/Utils/Cloning.h" #include "SVF-LLVM/ICFGBuilder.h" -#include "Graphs/CallGraph.h" +#include "Graphs/PTACallGraph.h" #include "Util/CallGraphBuilder.h" using namespace std; diff --git a/svf-llvm/lib/LLVMUtil.cpp b/svf-llvm/lib/LLVMUtil.cpp index a258913dc..ad5f99ff2 100644 --- a/svf-llvm/lib/LLVMUtil.cpp +++ b/svf-llvm/lib/LLVMUtil.cpp @@ -689,7 +689,7 @@ const std::string SVFBaseNode::valueOnlyToString() const { std::string str; llvm::raw_string_ostream rawstr(str); - if (const SVF::CallGraphNode* fun = SVFUtil::dyn_cast(this)) + if (const SVF::PTACallGraphNode* fun = SVFUtil::dyn_cast(this)) { rawstr << "Function: " << fun->getFunction()->getName() << " "; } diff --git a/svf-llvm/lib/SVFIRBuilder.cpp b/svf-llvm/lib/SVFIRBuilder.cpp index 24aa1198f..2db52cf1b 100644 --- a/svf-llvm/lib/SVFIRBuilder.cpp +++ b/svf-llvm/lib/SVFIRBuilder.cpp @@ -1189,17 +1189,17 @@ void SVFIRBuilder::handleIndCall(CallBase* cs) pag->addIndirectCallsites(cbn,pag->getValueNode(svfcalledval)); } -void SVFIRBuilder::updateCallGraph(CallGraph* callgraph) +void SVFIRBuilder::updateCallGraph(PTACallGraph* callgraph) { - CallGraph::CallEdgeMap::const_iterator iter = callgraph->getIndCallMap().begin(); - CallGraph::CallEdgeMap::const_iterator eiter = callgraph->getIndCallMap().end(); + PTACallGraph::CallEdgeMap::const_iterator iter = callgraph->getIndCallMap().begin(); + PTACallGraph::CallEdgeMap::const_iterator eiter = callgraph->getIndCallMap().end(); for (; iter != eiter; iter++) { const CallICFGNode* callBlock = iter->first; const CallBase* callbase = SVFUtil::cast(llvmModuleSet()->getLLVMValue(callBlock)); assert(callBlock->isIndirectCall() && "this is not an indirect call?"); - const CallGraph::FunctionSet& functions = iter->second; - for (CallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++) + const PTACallGraph::FunctionSet& functions = iter->second; + for (PTACallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++) { const Function* callee = SVFUtil::cast(llvmModuleSet()->getLLVMValue(*func_iter)); diff --git a/svf-llvm/tools/AE/ae.cpp b/svf-llvm/tools/AE/ae.cpp index 2d5889430..55e4b51fd 100644 --- a/svf-llvm/tools/AE/ae.cpp +++ b/svf-llvm/tools/AE/ae.cpp @@ -879,7 +879,7 @@ int main(int argc, char** argv) SVFIRBuilder builder(svfModule); SVFIR* pag = builder.build(); AndersenWaveDiff* ander = AndersenWaveDiff::createAndersenWaveDiff(pag); - CallGraph* callgraph = ander->getCallGraph(); + PTACallGraph* callgraph = ander->getCallGraph(); builder.updateCallGraph(callgraph); pag->getICFG()->updateCallGraph(callgraph); AbstractInterpretation& ae = AbstractInterpretation::getAEInstance(); diff --git a/svf-llvm/tools/Example/svf-ex.cpp b/svf-llvm/tools/Example/svf-ex.cpp index f271434c6..7749140f8 100644 --- a/svf-llvm/tools/Example/svf-ex.cpp +++ b/svf-llvm/tools/Example/svf-ex.cpp @@ -168,7 +168,7 @@ int main(int argc, char ** argv) /// Call Graph - CallGraph* callgraph = ander->getCallGraph(); + PTACallGraph* callgraph = ander->getCallGraph(); /// ICFG ICFG* icfg = pag->getICFG(); diff --git a/svf/include/AE/Svfexe/AbstractInterpretation.h b/svf/include/AE/Svfexe/AbstractInterpretation.h index e33cb4507..a39339fc0 100644 --- a/svf/include/AE/Svfexe/AbstractInterpretation.h +++ b/svf/include/AE/Svfexe/AbstractInterpretation.h @@ -106,7 +106,7 @@ class AbstractInterpretation friend class BufOverflowDetector; public: - typedef SCCDetection CallGraphSCC; + typedef SCCDetection CallGraphSCC; /// Constructor AbstractInterpretation(); diff --git a/svf/include/DDA/DDAVFSolver.h b/svf/include/DDA/DDAVFSolver.h index 7067245eb..5bf2c5f34 100644 --- a/svf/include/DDA/DDAVFSolver.h +++ b/svf/include/DDA/DDAVFSolver.h @@ -49,8 +49,8 @@ class DDAVFSolver friend class DDAStat; public: typedef SCCDetection SVFGSCC; - typedef SCCDetection CallGraphSCC; - typedef CallGraphEdge::CallInstSet CallInstSet; + typedef SCCDetection CallGraphSCC; + typedef PTACallGraphEdge::CallInstSet CallInstSet; typedef SVFIR::CallSiteSet CallSiteSet; typedef OrderedSet DPTItemSet; typedef OrderedMap DPImToCPtSetMap; @@ -624,7 +624,7 @@ class DDAVFSolver return (getSVFGSCCRepNode(edge->getSrcID()) == getSVFGSCCRepNode(edge->getDstID())); } /// Set callgraph - inline void setCallGraph (CallGraph* cg) + inline void setCallGraph (PTACallGraph* cg) { _callGraph = cg; } @@ -775,8 +775,8 @@ class DDAVFSolver SVFG* _svfg; ///< SVFG AndersenWaveDiff* _ander; ///< Andersen's analysis NodeBS candidateQueries; ///< candidate pointers; - CallGraph* _callGraph; ///< CallGraph - CallGraphSCC* _callGraphSCC; ///< SCC for CallGraph + PTACallGraph* _callGraph; ///< PTACallGraph + CallGraphSCC* _callGraphSCC; ///< SCC for PTACallGraph SVFGSCC* _svfgSCC; ///< SCC for SVFG DPTItemSet backwardVisited; ///< visited map during backward traversing DPImToCPtSetMap dpmToTLCPtSetMap; ///< points-to caching map for top-level vars diff --git a/svf/include/Graphs/ICFG.h b/svf/include/Graphs/ICFG.h index 747a10c8b..33d67bbe1 100644 --- a/svf/include/Graphs/ICFG.h +++ b/svf/include/Graphs/ICFG.h @@ -38,7 +38,7 @@ namespace SVF { -class CallGraph; +class PTACallGraph; /*! * Interprocedural Control-Flow Graph (ICFG) @@ -111,7 +111,7 @@ class ICFG : public GenericICFGTy void view(); /// update ICFG for indirect calls - void updateCallGraph(CallGraph* callgraph); + void updateCallGraph(PTACallGraph* callgraph); /// Whether node is in a loop inline bool isInLoop(const ICFGNode *node) diff --git a/svf/include/Graphs/CallGraph.h b/svf/include/Graphs/PTACallGraph.h similarity index 80% rename from svf/include/Graphs/CallGraph.h rename to svf/include/Graphs/PTACallGraph.h index 7b08b8e3f..f1fc2bc6e 100644 --- a/svf/include/Graphs/CallGraph.h +++ b/svf/include/Graphs/PTACallGraph.h @@ -1,4 +1,4 @@ -//===- CallGraph.h -- Call graph representation----------------------------// +//===- PTACallGraph.h -- Call graph representation----------------------------// // // SVF: Static Value-Flow Analysis // @@ -21,14 +21,14 @@ //===----------------------------------------------------------------------===// /* - * CallGraph.h + * PTACallGraph.h * * Created on: Nov 7, 2013 * Author: Yulei Sui */ -#ifndef CALLGRAPH_H_ -#define CALLGRAPH_H_ +#ifndef PTACALLGRAPH_H_ +#define PTACALLGRAPH_H_ #include "Graphs/GenericGraph.h" #include "SVFIR/SVFValue.h" @@ -38,7 +38,7 @@ namespace SVF { -class CallGraphNode; +class PTACallGraphNode; class SVFModule; @@ -47,8 +47,8 @@ class SVFModule; * Multiple calls from function A to B are merged into one call edge * Each call edge has a set of direct callsites and a set of indirect callsites */ -typedef GenericEdge GenericCallGraphEdgeTy; -class CallGraphEdge : public GenericCallGraphEdgeTy +typedef GenericEdge GenericCallGraphEdgeTy; +class PTACallGraphEdge : public GenericCallGraphEdgeTy { public: @@ -65,12 +65,12 @@ class CallGraphEdge : public GenericCallGraphEdgeTy CallSiteID csId; public: /// Constructor - CallGraphEdge(CallGraphNode* s, CallGraphNode* d, CEDGEK kind, CallSiteID cs) : + PTACallGraphEdge(PTACallGraphNode* s, PTACallGraphNode* d, CEDGEK kind, CallSiteID cs) : GenericCallGraphEdgeTy(s, d, makeEdgeFlagWithInvokeID(kind, cs)), csId(cs) { } /// Destructor - virtual ~CallGraphEdge() + virtual ~PTACallGraphEdge() { } /// Compute the unique edgeFlag value from edge kind and CallSiteID. @@ -140,21 +140,21 @@ class CallGraphEdge : public GenericCallGraphEdgeTy /// ClassOf //@{ - static inline bool classof(const CallGraphEdge*) + static inline bool classof(const PTACallGraphEdge*) { return true; } static inline bool classof(const GenericCallGraphEdgeTy *edge) { - return edge->getEdgeKind() == CallGraphEdge::CallRetEdge || - edge->getEdgeKind() == CallGraphEdge::TDForkEdge || - edge->getEdgeKind() == CallGraphEdge::TDJoinEdge; + return edge->getEdgeKind() == PTACallGraphEdge::CallRetEdge || + edge->getEdgeKind() == PTACallGraphEdge::TDForkEdge || + edge->getEdgeKind() == PTACallGraphEdge::TDJoinEdge; } //@} /// Overloading operator << for dumping ICFG node ID //@{ - friend OutStream& operator<< (OutStream &o, const CallGraphEdge &edge) + friend OutStream& operator<< (OutStream &o, const PTACallGraphEdge&edge) { o << edge.toString(); return o; @@ -163,28 +163,28 @@ class CallGraphEdge : public GenericCallGraphEdgeTy virtual const std::string toString() const; - typedef GenericNode::GEdgeSetTy CallGraphEdgeSet; + typedef GenericNode::GEdgeSetTy CallGraphEdgeSet; }; /* * Call Graph node representing a function */ -typedef GenericNode GenericCallGraphNodeTy; -class CallGraphNode : public GenericCallGraphNodeTy +typedef GenericNode GenericCallGraphNodeTy; +class PTACallGraphNode : public GenericCallGraphNodeTy { public: - typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet; - typedef CallGraphEdge::CallGraphEdgeSet::iterator iterator; - typedef CallGraphEdge::CallGraphEdgeSet::const_iterator const_iterator; + typedef PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet; + typedef PTACallGraphEdge::CallGraphEdgeSet::iterator iterator; + typedef PTACallGraphEdge::CallGraphEdgeSet::const_iterator const_iterator; private: const SVFFunction* fun; public: /// Constructor - CallGraphNode(NodeID i, const SVFFunction* f) : GenericCallGraphNodeTy(i,CallNodeKd), fun(f) + PTACallGraphNode(NodeID i, const SVFFunction* f) : GenericCallGraphNodeTy(i,CallNodeKd), fun(f) { } @@ -206,7 +206,7 @@ class CallGraphNode : public GenericCallGraphNodeTy /// Overloading operator << for dumping ICFG node ID //@{ - friend OutStream& operator<< (OutStream &o, const CallGraphNode &node) + friend OutStream& operator<< (OutStream &o, const PTACallGraphNode&node) { o << node.toString(); return o; @@ -217,7 +217,7 @@ class CallGraphNode : public GenericCallGraphNodeTy /// Methods for support type inquiry through isa, cast, and dyn_cast: //@{ - static inline bool classof(const CallGraphNode *) + static inline bool classof(const PTACallGraphNode*) { return true; } @@ -237,13 +237,13 @@ class CallGraphNode : public GenericCallGraphNodeTy /*! * Pointer Analysis Call Graph used internally for various pointer analysis */ -typedef GenericGraph GenericCallGraphTy; -class CallGraph : public GenericCallGraphTy +typedef GenericGraph GenericCallGraphTy; +class PTACallGraph : public GenericCallGraphTy { public: - typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet; - typedef Map FunToCallGraphNodeMap; + typedef PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet; + typedef Map FunToCallGraphNodeMap; typedef Map CallInstToCallGraphEdgesMap; typedef std::pair CallSitePair; typedef Map CallSiteToIdMap; @@ -280,15 +280,15 @@ class CallGraph : public GenericCallGraphTy public: /// Constructor - CallGraph(CGEK k = NormCallGraph); + PTACallGraph(CGEK k = NormCallGraph); /// Copy constructor - CallGraph(const CallGraph& other); + PTACallGraph(const PTACallGraph& other); void addCallGraphNode(const SVFFunction* fun); /// Destructor - virtual ~CallGraph() + virtual ~PTACallGraph() { destroy(); } @@ -336,11 +336,11 @@ class CallGraph : public GenericCallGraphTy /// Get call graph node //@{ - inline CallGraphNode* getCallGraphNode(NodeID id) const + inline PTACallGraphNode* getCallGraphNode(NodeID id) const { return getGNode(id); } - inline CallGraphNode* getCallGraphNode(const SVFFunction* fun) const + inline PTACallGraphNode* getCallGraphNode(const SVFFunction* fun) const { FunToCallGraphNodeMap::const_iterator it = funToCallGraphNodeMap.find(fun); assert(it!=funToCallGraphNodeMap.end() && "call graph node not found!!"); @@ -398,9 +398,11 @@ class CallGraph : public GenericCallGraphTy } //@} /// Whether we have already created this call graph edge - CallGraphEdge* hasGraphEdge(CallGraphNode* src, CallGraphNode* dst,CallGraphEdge::CEDGEK kind, CallSiteID csId) const; + PTACallGraphEdge* hasGraphEdge(PTACallGraphNode* src, PTACallGraphNode* dst, + PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const; /// Get call graph edge via nodes - CallGraphEdge* getGraphEdge(CallGraphNode* src, CallGraphNode* dst,CallGraphEdge::CEDGEK kind, CallSiteID csId); + PTACallGraphEdge* getGraphEdge(PTACallGraphNode* src, PTACallGraphNode* dst, + PTACallGraphEdge::CEDGEK kind, CallSiteID csId); /// Get all callees for a callsite inline void getCallees(const CallICFGNode* cs, FunctionSet& callees) @@ -438,7 +440,7 @@ class CallGraph : public GenericCallGraphTy } //@} /// Add call graph edge - inline void addEdge(CallGraphEdge* edge) + inline void addEdge(PTACallGraphEdge* edge) { edge->getDstNode()->addIncomingEdge(edge); edge->getSrcNode()->addOutgoingEdge(edge); @@ -452,9 +454,9 @@ class CallGraph : public GenericCallGraphTy /// Get callsites invoking the callee //@{ - void getAllCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet); - void getDirCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet); - void getIndCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet); + void getAllCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet); + void getDirCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet); + void getIndCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet); //@} /// Whether its reachable between two functions @@ -475,19 +477,19 @@ namespace SVF * GenericGraphTraits specializations for generic graph algorithms. * Provide graph traits for traversing from a constraint node using standard graph traversals. */ -template<> struct GenericGraphTraits : public GenericGraphTraits* > +template<> struct GenericGraphTraits : public GenericGraphTraits* > { }; /// Inverse GenericGraphTraits specializations for call graph node, it is used for inverse traversal. template<> -struct GenericGraphTraits > : public GenericGraphTraits* > > +struct GenericGraphTraits > : public GenericGraphTraits* > > { }; -template<> struct GenericGraphTraits : public GenericGraphTraits* > +template<> struct GenericGraphTraits : public GenericGraphTraits* > { - typedef SVF::CallGraphNode *NodeRef; + typedef SVF::PTACallGraphNode*NodeRef; }; } // End namespace llvm diff --git a/svf/include/Graphs/ThreadCallGraph.h b/svf/include/Graphs/ThreadCallGraph.h index 8bc2578cf..1431e5dbd 100644 --- a/svf/include/Graphs/ThreadCallGraph.h +++ b/svf/include/Graphs/ThreadCallGraph.h @@ -30,7 +30,7 @@ #ifndef RCG_H_ #define RCG_H_ -#include "Graphs/CallGraph.h" +#include "Graphs/PTACallGraph.h" namespace SVF { @@ -41,13 +41,13 @@ class PointerAnalysis; /*! * PTA thread fork edge from fork site to the entry of a start routine function */ -class ThreadForkEdge: public CallGraphEdge +class ThreadForkEdge: public PTACallGraphEdge { public: /// Constructor - ThreadForkEdge(CallGraphNode* s, CallGraphNode* d, CallSiteID csId) : - CallGraphEdge(s, d, CallGraphEdge::TDForkEdge, csId) + ThreadForkEdge(PTACallGraphNode* s, PTACallGraphNode* d, CallSiteID csId) : + PTACallGraphEdge(s, d, PTACallGraphEdge::TDForkEdge, csId) { } /// Destructor @@ -61,9 +61,9 @@ class ThreadForkEdge: public CallGraphEdge { return true; } - static inline bool classof(const CallGraphEdge *edge) + static inline bool classof(const PTACallGraphEdge*edge) { - return edge->getEdgeKind() == CallGraphEdge::TDForkEdge; + return edge->getEdgeKind() == PTACallGraphEdge::TDForkEdge; } //@} @@ -78,19 +78,19 @@ class ThreadForkEdge: public CallGraphEdge return rawstr.str(); } - typedef GenericNode::GEdgeSetTy ForkEdgeSet; + typedef GenericNode::GEdgeSetTy ForkEdgeSet; }; /*! * PTA thread join edge from the exit of a start routine function to a join point of the thread */ -class ThreadJoinEdge: public CallGraphEdge +class ThreadJoinEdge: public PTACallGraphEdge { public: /// Constructor - ThreadJoinEdge(CallGraphNode* s, CallGraphNode* d, CallSiteID csId) : - CallGraphEdge(s, d, CallGraphEdge::TDJoinEdge, csId) + ThreadJoinEdge(PTACallGraphNode* s, PTACallGraphNode* d, CallSiteID csId) : + PTACallGraphEdge(s, d, PTACallGraphEdge::TDJoinEdge, csId) { } /// Destructor @@ -102,9 +102,9 @@ class ThreadJoinEdge: public CallGraphEdge { return true; } - static inline bool classof(const CallGraphEdge *edge) + static inline bool classof(const PTACallGraphEdge*edge) { - return edge->getEdgeKind() == CallGraphEdge::TDJoinEdge; + return edge->getEdgeKind() == PTACallGraphEdge::TDJoinEdge; } virtual const std::string toString() const @@ -118,19 +118,19 @@ class ThreadJoinEdge: public CallGraphEdge return rawstr.str(); } - typedef GenericNode::GEdgeSetTy JoinEdgeSet; + typedef GenericNode::GEdgeSetTy JoinEdgeSet; }; /*! * hare_parallel_for edge from fork site to the entry of a start routine function */ -class HareParForEdge: public CallGraphEdge +class HareParForEdge: public PTACallGraphEdge { public: /// Constructor - HareParForEdge(CallGraphNode* s, CallGraphNode* d, CallSiteID csId) : - CallGraphEdge(s, d, CallGraphEdge::HareParForEdge, csId) + HareParForEdge(PTACallGraphNode* s, PTACallGraphNode* d, CallSiteID csId) : + PTACallGraphEdge(s, d, PTACallGraphEdge::HareParForEdge, csId) { } /// Destructor @@ -144,20 +144,20 @@ class HareParForEdge: public CallGraphEdge { return true; } - static inline bool classof(const CallGraphEdge *edge) + static inline bool classof(const PTACallGraphEdge*edge) { - return edge->getEdgeKind() == CallGraphEdge::HareParForEdge; + return edge->getEdgeKind() == PTACallGraphEdge::HareParForEdge; } //@} - typedef GenericNode::GEdgeSetTy ParForEdgeSet; + typedef GenericNode::GEdgeSetTy ParForEdgeSet; }; /*! * Thread sensitive call graph */ -class ThreadCallGraph: public CallGraph +class ThreadCallGraph: public PTACallGraph { public: @@ -172,7 +172,7 @@ class ThreadCallGraph: public CallGraph typedef Map CallInstToParForEdgesMap; /// Constructor - ThreadCallGraph(const CallGraph& cg); + ThreadCallGraph(const PTACallGraph& cg); ThreadCallGraph(ThreadCallGraph& cg) = delete; @@ -187,9 +187,9 @@ class ThreadCallGraph: public CallGraph { return true; } - static inline bool classof(const CallGraph *g) + static inline bool classof(const PTACallGraph*g) { - return g->getKind() == CallGraph::ThdCallGraph; + return g->getKind() == PTACallGraph::ThdCallGraph; } //@} @@ -239,7 +239,7 @@ class ThreadCallGraph: public CallGraph assert(it != callinstToThreadJoinEdgesMap.end() && "call instruction does not have a valid callee"); return it->second.end(); } - inline void getJoinSites(const CallGraphNode* routine, InstSet& csSet) + inline void getJoinSites(const PTACallGraphNode* routine, InstSet& csSet) { for(CallInstToJoinEdgesMap::const_iterator it = callinstToThreadJoinEdgesMap.begin(), eit = callinstToThreadJoinEdgesMap.end(); it!=eit; ++it) { @@ -359,7 +359,7 @@ class ThreadCallGraph: public CallGraph //@} - /// map call instruction to its CallGraphEdge map + /// map call instruction to its PTACallGraphEdge map inline void addThreadForkEdgeSetMap(const CallICFGNode* cs, ThreadForkEdge* edge) { if(edge!=nullptr) @@ -369,7 +369,7 @@ class ThreadCallGraph: public CallGraph } } - /// map call instruction to its CallGraphEdge map + /// map call instruction to its PTACallGraphEdge map inline void addThreadJoinEdgeSetMap(const CallICFGNode* cs, ThreadJoinEdge* edge) { if(edge!=nullptr) @@ -379,7 +379,7 @@ class ThreadCallGraph: public CallGraph } } - /// map call instruction to its CallGraphEdge map + /// map call instruction to its PTACallGraphEdge map inline void addHareParForEdgeSetMap(const CallICFGNode* cs, HareParForEdge* edge) { if(edge!=nullptr) @@ -390,7 +390,7 @@ class ThreadCallGraph: public CallGraph } /// has thread join edge - inline ThreadJoinEdge* hasThreadJoinEdge(const CallICFGNode* call, CallGraphNode* joinFunNode, CallGraphNode* threadRoutineFunNode, CallSiteID csId) const + inline ThreadJoinEdge* hasThreadJoinEdge(const CallICFGNode* call, PTACallGraphNode* joinFunNode, PTACallGraphNode* threadRoutineFunNode, CallSiteID csId) const { ThreadJoinEdge joinEdge(joinFunNode,threadRoutineFunNode, csId); CallInstToJoinEdgesMap::const_iterator it = callinstToThreadJoinEdgesMap.find(call); diff --git a/svf/include/Graphs/VFG.h b/svf/include/Graphs/VFG.h index fdb470356..63f2d3cec 100644 --- a/svf/include/Graphs/VFG.h +++ b/svf/include/Graphs/VFG.h @@ -32,7 +32,7 @@ #include "SVFIR/SVFIR.h" -#include "Graphs/CallGraph.h" +#include "Graphs/PTACallGraph.h" #include "Graphs/VFGNode.h" #include "Graphs/VFGEdge.h" @@ -100,7 +100,7 @@ class VFG : public GenericVFGTy FunToVFGNodesMapTy funToVFGNodesMap; ///< map a function to its VFGNodes; GlobalVFGNodeSet globalVFGNodes; ///< set of global store VFG nodes - CallGraph* callgraph; + PTACallGraph* callgraph; SVFIR* pag; VFGK kind; @@ -109,7 +109,7 @@ class VFG : public GenericVFGTy public: /// Constructor - VFG(CallGraph* callgraph, VFGK k = FULLSVFG); + VFG(PTACallGraph* callgraph, VFGK k = FULLSVFG); /// Destructor virtual ~VFG() @@ -135,8 +135,8 @@ class VFG : public GenericVFGTy return pag; } - /// Return CallGraph - inline CallGraph* getCallGraph() const + /// Return PTACallGraph + inline PTACallGraph* getCallGraph() const { return callgraph; } diff --git a/svf/include/MSSA/MemRegion.h b/svf/include/MSSA/MemRegion.h index ee1c1a867..f109fac7f 100644 --- a/svf/include/MSSA/MemRegion.h +++ b/svf/include/MSSA/MemRegion.h @@ -35,7 +35,7 @@ #define MEMORYREGION_H_ #include "Graphs/ICFG.h" -#include "Graphs/CallGraph.h" +#include "Graphs/PTACallGraph.h" #include "Graphs/SCC.h" #include "SVFIR/SVFIR.h" #include "Util/WorkList.h" @@ -175,7 +175,7 @@ class MRGenerator /// SVFIR edge list typedef SVFIR::SVFStmtList SVFStmtList; /// Call Graph SCC - typedef SCCDetection SCC; + typedef SCCDetection SCC; MRSet& getMRSet() { @@ -196,7 +196,7 @@ class MRGenerator BVDataPTAImpl* pta; SCC* callGraphSCC; - CallGraph* callGraph; + PTACallGraph* callGraph; bool ptrOnlyMSSA; /// Map a function to all its memory regions @@ -330,7 +330,7 @@ class MRGenerator } /// Mod-Ref analysis for callsite invoking this callGraphNode - virtual void modRefAnalysis(CallGraphNode* callGraphNode, WorkList& worklist); + virtual void modRefAnalysis(PTACallGraphNode* callGraphNode, WorkList& worklist); /// Get Mod-Ref of a callee function virtual bool handleCallsiteModRef(NodeBS& mod, NodeBS& ref, const CallICFGNode* cs, const SVFFunction* fun); diff --git a/svf/include/MTA/LockAnalysis.h b/svf/include/MTA/LockAnalysis.h index 27390f470..6fa47bd09 100644 --- a/svf/include/MTA/LockAnalysis.h +++ b/svf/include/MTA/LockAnalysis.h @@ -339,7 +339,7 @@ class LockAnalysis void handleIntra(const CxtStmt& cts); /// Handle call relations - void handleCallRelation(CxtLockProc& clp, const CallGraphEdge* cgEdge, const CallICFGNode* call); + void handleCallRelation(CxtLockProc& clp, const PTACallGraphEdge* cgEdge, const CallICFGNode* call); /// Return true it a lock matches an unlock bool isAliasedLocks(const CxtLock& cl1, const CxtLock& cl2) diff --git a/svf/include/MTA/MHP.h b/svf/include/MTA/MHP.h index 08756daa4..df4aef72e 100644 --- a/svf/include/MTA/MHP.h +++ b/svf/include/MTA/MHP.h @@ -123,7 +123,7 @@ class MHP private: - inline const CallGraph::FunctionSet& getCallee(const CallICFGNode* inst, CallGraph::FunctionSet& callees) + inline const PTACallGraph::FunctionSet& getCallee(const CallICFGNode* inst, PTACallGraph::FunctionSet& callees) { tcg->getCallees(inst, callees); return callees; @@ -482,7 +482,7 @@ class ForkJoinAnalysis { return getTCG()->getThreadAPI()->getJoinedThread(call); } - inline const CallGraph::FunctionSet& getCallee(const ICFGNode* inst, CallGraph::FunctionSet& callees) + inline const PTACallGraph::FunctionSet& getCallee(const ICFGNode* inst, PTACallGraph::FunctionSet& callees) { getTCG()->getCallees(SVFUtil::cast(inst), callees); return callees; diff --git a/svf/include/MTA/TCT.h b/svf/include/MTA/TCT.h index dbad8ef8f..05eca06a1 100644 --- a/svf/include/MTA/TCT.h +++ b/svf/include/MTA/TCT.h @@ -160,14 +160,14 @@ class TCT: public GenericThreadCreateTreeTy typedef Set FunSet; typedef std::vector InstVec; typedef Set InstSet; - typedef Set PTACGNodeSet; + typedef Set PTACGNodeSet; typedef Map CxtThreadToNodeMap; typedef Map CxtThreadToForkCxt; typedef Map CxtThreadToFun; typedef Map InstToLoopMap; typedef FIFOWorkList CxtThreadProcVec; typedef Set CxtThreadProcSet; - typedef SCCDetection ThreadCallGraphSCC; + typedef SCCDetection ThreadCallGraphSCC; /// Constructor TCT(PointerAnalysis* p) :pta(p),TCTNodeNum(0),TCTEdgeNum(0),MaxCxtSize(0) @@ -288,9 +288,9 @@ class TCT: public GenericThreadCreateTreeTy //@} /// Whether it is a candidate function for indirect call - inline bool isCandidateFun(const CallGraph::FunctionSet& callees) const + inline bool isCandidateFun(const PTACallGraph::FunctionSet& callees) const { - for(CallGraph::FunctionSet::const_iterator cit = callees.begin(), + for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++) { if(candidateFuncSet.find((*cit))!=candidateFuncSet.end()) @@ -303,7 +303,7 @@ class TCT: public GenericThreadCreateTreeTy return candidateFuncSet.find(fun)!=candidateFuncSet.end(); } /// Whether two functions in the same callgraph scc - inline bool inSameCallGraphSCC(const CallGraphNode* src,const CallGraphNode* dst) + inline bool inSameCallGraphSCC(const PTACallGraphNode* src,const PTACallGraphNode* dst) { return (tcgSCC->repNode(src->getId()) == tcgSCC->repNode(dst->getId())); } @@ -506,7 +506,7 @@ class TCT: public GenericThreadCreateTreeTy //@} /// Handle call relations - void handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, const CallICFGNode* call); + void handleCallRelation(CxtThreadProc& ctp, const PTACallGraphEdge* cgEdge, const CallICFGNode* call); /// Get or create a tct node based on CxtThread //@{ diff --git a/svf/include/MemoryModel/PointerAnalysis.h b/svf/include/MemoryModel/PointerAnalysis.h index 535be9878..f51f7d1a8 100644 --- a/svf/include/MemoryModel/PointerAnalysis.h +++ b/svf/include/MemoryModel/PointerAnalysis.h @@ -103,7 +103,7 @@ class PointerAnalysis typedef SVFIR::CallSiteToFunPtrMap CallSiteToFunPtrMap; typedef Set FunctionSet; typedef OrderedMap CallEdgeMap; - typedef SCCDetection CallGraphSCC; + typedef SCCDetection CallGraphSCC; typedef Set VTableSet; typedef Set VFunSet; //@} @@ -148,8 +148,8 @@ class PointerAnalysis /// Statistics PTAStat* stat; /// Call graph used for pointer analysis - CallGraph* callgraph; - /// SCC for CallGraph + PTACallGraph* callgraph; + /// SCC for PTACallGraph CallGraphSCC* callGraphSCC; /// Interprocedural control-flow graph ICFG* icfg; @@ -168,7 +168,7 @@ class PointerAnalysis return getCallGraph()->getNumOfResolvedIndCallEdge(); } /// Return call graph - inline CallGraph* getCallGraph() const + inline PTACallGraph* getCallGraph() const { return callgraph; } @@ -382,9 +382,9 @@ class PointerAnalysis /// Resolve indirect call edges virtual void resolveIndCalls(const CallICFGNode* cs, const PointsTo& target, CallEdgeMap& newEdges); - /// CallGraph SCC related methods + /// PTACallGraph SCC related methods //@{ - /// CallGraph SCC detection + /// PTACallGraph SCC detection inline void callGraphSCCDetection() { if(callGraphSCC==nullptr) @@ -397,11 +397,11 @@ class PointerAnalysis { return callGraphSCC->repNode(id); } - /// Return TRUE if this edge is inside a CallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG. + /// Return TRUE if this edge is inside a PTACallGraph SCC, i.e., src node and dst node are in the same SCC on the SVFG. inline bool inSameCallGraphSCC(const SVFFunction* fun1,const SVFFunction* fun2) { - const CallGraphNode* src = callgraph->getCallGraphNode(fun1); - const CallGraphNode* dst = callgraph->getCallGraphNode(fun2); + const PTACallGraphNode* src = callgraph->getCallGraphNode(fun1); + const PTACallGraphNode* dst = callgraph->getCallGraphNode(fun2); return (getCallGraphSCCRepNode(src->getId()) == getCallGraphSCCRepNode(dst->getId())); } inline bool isInRecursion(const SVFFunction* fun) const diff --git a/svf/include/SABER/SaberSVFGBuilder.h b/svf/include/SABER/SaberSVFGBuilder.h index 2f47c2dc2..06125f10d 100644 --- a/svf/include/SABER/SaberSVFGBuilder.h +++ b/svf/include/SABER/SaberSVFGBuilder.h @@ -89,7 +89,7 @@ class SaberSVFGBuilder : public SVFGBuilder /// Add actual parameter SVFGNode for 1st argument of a deallocation like external function /// In order to path sensitive leak detection - virtual void AddExtActualParmSVFGNodes(CallGraph* callgraph); + virtual void AddExtActualParmSVFGNodes(PTACallGraph* callgraph); /// Collect memory pointed global pointers, /// note that this collection is recursively performed, for example gp-->obj-->obj' diff --git a/svf/include/SABER/SrcSnkDDA.h b/svf/include/SABER/SrcSnkDDA.h index 9bbf578af..150946b47 100644 --- a/svf/include/SABER/SrcSnkDDA.h +++ b/svf/include/SABER/SrcSnkDDA.h @@ -76,7 +76,7 @@ class SrcSnkDDA : public CFLSrcSnkSolver protected: SaberSVFGBuilder memSSA; SVFG* svfg; - CallGraph* callgraph; + PTACallGraph* callgraph; SVFBugReport report; /// Bug Reporter public: @@ -129,7 +129,7 @@ class SrcSnkDDA : public CFLSrcSnkSolver } /// Get Callgraph - inline CallGraph* getCallgraph() const + inline PTACallGraph* getCallgraph() const { return callgraph; } diff --git a/svf/include/SVFIR/SVFIR.h b/svf/include/SVFIR/SVFIR.h index 0cf19c22a..4076383aa 100644 --- a/svf/include/SVFIR/SVFIR.h +++ b/svf/include/SVFIR/SVFIR.h @@ -98,7 +98,7 @@ class SVFIR : public IRGraph ICFG* icfg; // ICFG CommonCHGraph* chgraph; // class hierarchy graph CallSiteSet callSiteSet; /// all the callsites of a program - CallGraph* callGraph; /// call graph + PTACallGraph* callGraph; /// call graph static std::unique_ptr pag; ///< Singleton pattern here to enable instance of SVFIR can only be created once. @@ -185,13 +185,13 @@ class SVFIR : public IRGraph } /// Set/Get CG - inline void setCallGraph(CallGraph* c) + inline void setCallGraph(PTACallGraph* c) { callGraph = c; } - inline CallGraph* getCallGraph() + inline PTACallGraph* getCallGraph() { - assert(callGraph && "empty CallGraph! Build SVF IR first!"); + assert(callGraph && "empty PTACallGraph! Build SVF IR first!"); return callGraph; } diff --git a/svf/include/Util/CallGraphBuilder.h b/svf/include/Util/CallGraphBuilder.h index d2f20880b..c8b65a85d 100644 --- a/svf/include/Util/CallGraphBuilder.h +++ b/svf/include/Util/CallGraphBuilder.h @@ -31,7 +31,7 @@ #ifndef INCLUDE_SVF_FE_CALLGRAPHBUILDER_H_ #define INCLUDE_SVF_FE_CALLGRAPHBUILDER_H_ -#include "Graphs/CallGraph.h" +#include "Graphs/PTACallGraph.h" #include "Graphs/ThreadCallGraph.h" namespace SVF @@ -46,7 +46,7 @@ class CallGraphBuilder CallGraphBuilder()=default; /// Buidl SVFIR callgraoh - CallGraph* buildSVFIRCallGraph(SVFModule* svfModule); + PTACallGraph* buildSVFIRCallGraph(SVFModule* svfModule); /// Build thread-aware callgraph ThreadCallGraph* buildThreadCallGraph(); diff --git a/svf/lib/DDA/DDAClient.cpp b/svf/lib/DDA/DDAClient.cpp index dbba6b666..668b5d55f 100644 --- a/svf/lib/DDA/DDAClient.cpp +++ b/svf/lib/DDA/DDAClient.cpp @@ -115,7 +115,7 @@ void FunptrDDAClient::performStat(PointerAnalysis* pta) const PointsTo& ddaPts = pta->getPts(vtptr); const PointsTo& anderPts = ander->getPts(vtptr); - CallGraph* callgraph = ander->getCallGraph(); + PTACallGraph* callgraph = ander->getCallGraph(); const CallICFGNode* cbn = nIter->second; if(!callgraph->hasIndCSCallees(cbn)) @@ -124,7 +124,7 @@ void FunptrDDAClient::performStat(PointerAnalysis* pta) continue; } - const CallGraph::FunctionSet& callees = callgraph->getIndCSCallees(cbn); + const PTACallGraph::FunctionSet& callees = callgraph->getIndCSCallees(cbn); totalCallsites++; if(callees.size() == 0) zeroTargetCallsites++; diff --git a/svf/lib/Graphs/ICFG.cpp b/svf/lib/Graphs/ICFG.cpp index 7e99b720c..533cb2129 100644 --- a/svf/lib/Graphs/ICFG.cpp +++ b/svf/lib/Graphs/ICFG.cpp @@ -27,11 +27,11 @@ * Author: Yulei Sui */ -#include -#include "SVFIR/SVFModule.h" #include "Graphs/ICFG.h" +#include "Graphs/PTACallGraph.h" #include "SVFIR/SVFIR.h" -#include "Graphs/CallGraph.h" +#include "SVFIR/SVFModule.h" +#include using namespace SVF; using namespace SVFUtil; @@ -416,16 +416,16 @@ void ICFG::view() /*! * Update ICFG for indirect calls */ -void ICFG::updateCallGraph(CallGraph* callgraph) +void ICFG::updateCallGraph(PTACallGraph* callgraph) { - CallGraph::CallEdgeMap::const_iterator iter = callgraph->getIndCallMap().begin(); - CallGraph::CallEdgeMap::const_iterator eiter = callgraph->getIndCallMap().end(); + PTACallGraph::CallEdgeMap::const_iterator iter = callgraph->getIndCallMap().begin(); + PTACallGraph::CallEdgeMap::const_iterator eiter = callgraph->getIndCallMap().end(); for (; iter != eiter; iter++) { CallICFGNode* callBlockNode = const_cast(iter->first); assert(callBlockNode->isIndirectCall() && "this is not an indirect call?"); - const CallGraph::FunctionSet & functions = iter->second; - for (CallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++) + const PTACallGraph::FunctionSet & functions = iter->second; + for (PTACallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++) { const SVFFunction* callee = *func_iter; RetICFGNode* retBlockNode = const_cast(callBlockNode->getRetICFGNode()); diff --git a/svf/lib/Graphs/CallGraph.cpp b/svf/lib/Graphs/PTACallGraph.cpp similarity index 58% rename from svf/lib/Graphs/CallGraph.cpp rename to svf/lib/Graphs/PTACallGraph.cpp index 77e0d7937..2d73de30c 100644 --- a/svf/lib/Graphs/CallGraph.cpp +++ b/svf/lib/Graphs/PTACallGraph.cpp @@ -1,4 +1,4 @@ -//===- CallGraph.cpp -- Call graph used internally in SVF------------------// +//===- PTACallGraph.cpp -- Call graph used internally in SVF------------------// // // SVF: Static Value-Flow Analysis // @@ -22,42 +22,42 @@ /* - * CallGraph.cpp + * PTACallGraph.cpp * * Created on: Nov 7, 2013 * Author: Yulei Sui */ -#include +#include "Graphs/PTACallGraph.h" +#include "SVFIR/SVFIR.h" #include "SVFIR/SVFModule.h" #include "Util/SVFUtil.h" -#include "Graphs/CallGraph.h" -#include "SVFIR/SVFIR.h" +#include using namespace SVF; using namespace SVFUtil; -CallGraph::CallSiteToIdMap CallGraph::csToIdMap; -CallGraph::IdToCallSiteMap CallGraph::idToCSMap; -CallSiteID CallGraph::totalCallSiteNum = 1; +PTACallGraph::CallSiteToIdMap PTACallGraph::csToIdMap; +PTACallGraph::IdToCallSiteMap PTACallGraph::idToCSMap; +CallSiteID PTACallGraph::totalCallSiteNum = 1; /// Add direct and indirect callsite //@{ -void CallGraphEdge::addDirectCallSite(const CallICFGNode* call) +void PTACallGraphEdge::addDirectCallSite(const CallICFGNode* call) { assert(call->getCalledFunction() && "not a direct callsite??"); directCalls.insert(call); } -void CallGraphEdge::addInDirectCallSite(const CallICFGNode* call) +void PTACallGraphEdge::addInDirectCallSite(const CallICFGNode* call) { assert((nullptr == call->getCalledFunction() || nullptr == SVFUtil::dyn_cast (SVFUtil::getForkedFun(call)->getValue())) && "not an indirect callsite??"); indirectCalls.insert(call); } //@} -const std::string CallGraphEdge::toString() const +const std::string PTACallGraphEdge::toString() const { std::string str; std::stringstream rawstr(str); @@ -70,24 +70,24 @@ const std::string CallGraphEdge::toString() const return rawstr.str(); } -const std::string CallGraphNode::toString() const +const std::string PTACallGraphNode::toString() const { std::string str; std::stringstream rawstr(str); - rawstr << "CallGraphNode ID: " << getId() << " {fun: " << fun->getName() << "}"; + rawstr << "PTACallGraphNode ID: " << getId() << " {fun: " << fun->getName() << "}"; return rawstr.str(); } -bool CallGraphNode::isReachableFromProgEntry() const +bool PTACallGraphNode::isReachableFromProgEntry() const { - std::stack nodeStack; + std::stack nodeStack; NodeBS visitedNodes; nodeStack.push(this); visitedNodes.set(getId()); while (nodeStack.empty() == false) { - CallGraphNode* node = const_cast(nodeStack.top()); + PTACallGraphNode* node = const_cast(nodeStack.top()); nodeStack.pop(); if (SVFUtil::isProgEntryFunction(node->getFunction())) @@ -95,7 +95,7 @@ bool CallGraphNode::isReachableFromProgEntry() const for (const_iterator it = node->InEdgeBegin(), eit = node->InEdgeEnd(); it != eit; ++it) { - CallGraphEdge* edge = *it; + PTACallGraphEdge* edge = *it; if (visitedNodes.test_and_set(edge->getSrcID())) nodeStack.push(edge->getSrcNode()); } @@ -106,14 +106,14 @@ bool CallGraphNode::isReachableFromProgEntry() const /// Constructor -CallGraph::CallGraph(CGEK k): kind(k) +PTACallGraph::PTACallGraph(CGEK k): kind(k) { callGraphNodeNum = 0; numOfResolvedIndCallEdge = 0; } /// Copy constructor -CallGraph::CallGraph(const CallGraph& other) +PTACallGraph::PTACallGraph(const PTACallGraph& other) { callGraphNodeNum = other.callGraphNodeNum; numOfResolvedIndCallEdge = 0; @@ -122,8 +122,8 @@ CallGraph::CallGraph(const CallGraph& other) /// copy call graph nodes for (const auto& item : other) { - const CallGraphNode* cgn = item.second; - CallGraphNode* callGraphNode = new CallGraphNode(cgn->getId(), cgn->getFunction()); + const PTACallGraphNode* cgn = item.second; + PTACallGraphNode* callGraphNode = new PTACallGraphNode(cgn->getId(), cgn->getFunction()); addGNode(cgn->getId(),callGraphNode); funToCallGraphNodeMap[cgn->getFunction()] = callGraphNode; } @@ -132,11 +132,11 @@ CallGraph::CallGraph(const CallGraph& other) for (const auto& item : other.callinstToCallGraphEdgesMap) { const CallICFGNode* cs = item.first; - for (const CallGraphEdge* edge : item.second) + for (const PTACallGraphEdge* edge : item.second) { - CallGraphNode* src = getCallGraphNode(edge->getSrcID()); - CallGraphNode* dst = getCallGraphNode(edge->getDstID()); - CallGraphEdge* newEdge = new CallGraphEdge(src,dst,CallGraphEdge::CallRetEdge,edge->getCallSiteID()); + PTACallGraphNode* src = getCallGraphNode(edge->getSrcID()); + PTACallGraphNode* dst = getCallGraphNode(edge->getDstID()); + PTACallGraphEdge* newEdge = new PTACallGraphEdge(src,dst, PTACallGraphEdge::CallRetEdge,edge->getCallSiteID()); newEdge->addDirectCallSite(cs); addEdge(newEdge); callinstToCallGraphEdgesMap[cs].insert(newEdge); @@ -148,17 +148,17 @@ CallGraph::CallGraph(const CallGraph& other) /*! * Memory has been cleaned up at GenericGraph */ -void CallGraph::destroy() +void PTACallGraph::destroy() { } /*! * Add call graph node */ -void CallGraph::addCallGraphNode(const SVFFunction* fun) +void PTACallGraph::addCallGraphNode(const SVFFunction* fun) { NodeID id = callGraphNodeNum; - CallGraphNode *callGraphNode = new CallGraphNode(id, fun); + PTACallGraphNode*callGraphNode = new PTACallGraphNode(id, fun); addGNode(id, callGraphNode); funToCallGraphNodeMap[callGraphNode->getFunction()] = callGraphNode; callGraphNodeNum++; @@ -167,11 +167,13 @@ void CallGraph::addCallGraphNode(const SVFFunction* fun) /*! * Whether we have already created this call graph edge */ -CallGraphEdge* CallGraph::hasGraphEdge(CallGraphNode* src, CallGraphNode* dst,CallGraphEdge::CEDGEK kind, CallSiteID csId) const +PTACallGraphEdge* PTACallGraph::hasGraphEdge(PTACallGraphNode* src, + PTACallGraphNode* dst, + PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const { - CallGraphEdge edge(src,dst,kind,csId); - CallGraphEdge* outEdge = src->hasOutgoingEdge(&edge); - CallGraphEdge* inEdge = dst->hasIncomingEdge(&edge); + PTACallGraphEdge edge(src,dst,kind,csId); + PTACallGraphEdge* outEdge = src->hasOutgoingEdge(&edge); + PTACallGraphEdge* inEdge = dst->hasIncomingEdge(&edge); if (outEdge && inEdge) { assert(outEdge == inEdge && "edges not match"); @@ -182,14 +184,16 @@ CallGraphEdge* CallGraph::hasGraphEdge(CallGraphNode* src, CallGraphNode* dst,Ca } /*! - * get CallGraph edge via nodes + * get PTACallGraph edge via nodes */ -CallGraphEdge* CallGraph::getGraphEdge(CallGraphNode* src, CallGraphNode* dst,CallGraphEdge::CEDGEK kind, CallSiteID) +PTACallGraphEdge* PTACallGraph::getGraphEdge(PTACallGraphNode* src, + PTACallGraphNode* dst, + PTACallGraphEdge::CEDGEK kind, CallSiteID) { - for (CallGraphEdge::CallGraphEdgeSet::iterator iter = src->OutEdgeBegin(); + for (PTACallGraphEdge::CallGraphEdgeSet::iterator iter = src->OutEdgeBegin(); iter != src->OutEdgeEnd(); ++iter) { - CallGraphEdge* edge = (*iter); + PTACallGraphEdge* edge = (*iter); if (edge->getEdgeKind() == kind && edge->getDstID() == dst->getId()) return edge; } @@ -199,17 +203,17 @@ CallGraphEdge* CallGraph::getGraphEdge(CallGraphNode* src, CallGraphNode* dst,Ca /*! * Add direct call edges */ -void CallGraph::addDirectCallGraphEdge(const CallICFGNode* cs,const SVFFunction* callerFun, const SVFFunction* calleeFun) +void PTACallGraph::addDirectCallGraphEdge(const CallICFGNode* cs,const SVFFunction* callerFun, const SVFFunction* calleeFun) { - CallGraphNode* caller = getCallGraphNode(callerFun); - CallGraphNode* callee = getCallGraphNode(calleeFun); + PTACallGraphNode* caller = getCallGraphNode(callerFun); + PTACallGraphNode* callee = getCallGraphNode(calleeFun); CallSiteID csId = addCallSite(cs, callee->getFunction()); - if(!hasGraphEdge(caller,callee, CallGraphEdge::CallRetEdge,csId)) + if(!hasGraphEdge(caller,callee, PTACallGraphEdge::CallRetEdge,csId)) { - CallGraphEdge* edge = new CallGraphEdge(caller,callee,CallGraphEdge::CallRetEdge,csId); + PTACallGraphEdge* edge = new PTACallGraphEdge(caller,callee, PTACallGraphEdge::CallRetEdge,csId); edge->addDirectCallSite(cs); addEdge(edge); callinstToCallGraphEdgesMap[cs].insert(edge); @@ -219,19 +223,19 @@ void CallGraph::addDirectCallGraphEdge(const CallICFGNode* cs,const SVFFunction* /*! * Add indirect call edge to update call graph */ -void CallGraph::addIndirectCallGraphEdge(const CallICFGNode* cs,const SVFFunction* callerFun, const SVFFunction* calleeFun) +void PTACallGraph::addIndirectCallGraphEdge(const CallICFGNode* cs,const SVFFunction* callerFun, const SVFFunction* calleeFun) { - CallGraphNode* caller = getCallGraphNode(callerFun); - CallGraphNode* callee = getCallGraphNode(calleeFun); + PTACallGraphNode* caller = getCallGraphNode(callerFun); + PTACallGraphNode* callee = getCallGraphNode(calleeFun); numOfResolvedIndCallEdge++; CallSiteID csId = addCallSite(cs, callee->getFunction()); - if(!hasGraphEdge(caller,callee, CallGraphEdge::CallRetEdge,csId)) + if(!hasGraphEdge(caller,callee, PTACallGraphEdge::CallRetEdge,csId)) { - CallGraphEdge* edge = new CallGraphEdge(caller,callee,CallGraphEdge::CallRetEdge, csId); + PTACallGraphEdge* edge = new PTACallGraphEdge(caller,callee, PTACallGraphEdge::CallRetEdge, csId); edge->addInDirectCallSite(cs); addEdge(edge); callinstToCallGraphEdgesMap[cs].insert(edge); @@ -241,18 +245,18 @@ void CallGraph::addIndirectCallGraphEdge(const CallICFGNode* cs,const SVFFunctio /*! * Get all callsite invoking this callee */ -void CallGraph::getAllCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet) +void PTACallGraph::getAllCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet) { - CallGraphNode* callGraphNode = getCallGraphNode(callee); - for(CallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd(); + PTACallGraphNode* callGraphNode = getCallGraphNode(callee); + for(PTACallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd(); it!=eit; ++it) { - for(CallGraphEdge::CallInstSet::const_iterator cit = (*it)->directCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->directCallsBegin(), ecit = (*it)->directCallsEnd(); cit!=ecit; ++cit) { csSet.insert((*cit)); } - for(CallGraphEdge::CallInstSet::const_iterator cit = (*it)->indirectCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->indirectCallsBegin(), ecit = (*it)->indirectCallsEnd(); cit!=ecit; ++cit) { csSet.insert((*cit)); @@ -263,13 +267,13 @@ void CallGraph::getAllCallSitesInvokingCallee(const SVFFunction* callee, CallGra /*! * Get direct callsite invoking this callee */ -void CallGraph::getDirCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet) +void PTACallGraph::getDirCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet) { - CallGraphNode* callGraphNode = getCallGraphNode(callee); - for(CallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd(); + PTACallGraphNode* callGraphNode = getCallGraphNode(callee); + for(PTACallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd(); it!=eit; ++it) { - for(CallGraphEdge::CallInstSet::const_iterator cit = (*it)->directCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->directCallsBegin(), ecit = (*it)->directCallsEnd(); cit!=ecit; ++cit) { csSet.insert((*cit)); @@ -280,13 +284,13 @@ void CallGraph::getDirCallSitesInvokingCallee(const SVFFunction* callee, CallGra /*! * Get indirect callsite invoking this callee */ -void CallGraph::getIndCallSitesInvokingCallee(const SVFFunction* callee, CallGraphEdge::CallInstSet& csSet) +void PTACallGraph::getIndCallSitesInvokingCallee(const SVFFunction* callee, PTACallGraphEdge::CallInstSet& csSet) { - CallGraphNode* callGraphNode = getCallGraphNode(callee); - for(CallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd(); + PTACallGraphNode* callGraphNode = getCallGraphNode(callee); + for(PTACallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd(); it!=eit; ++it) { - for(CallGraphEdge::CallInstSet::const_iterator cit = (*it)->indirectCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*it)->indirectCallsBegin(), ecit = (*it)->indirectCallsEnd(); cit!=ecit; ++cit) { csSet.insert((*cit)); @@ -297,7 +301,7 @@ void CallGraph::getIndCallSitesInvokingCallee(const SVFFunction* callee, CallGra /*! * Issue a warning if the function which has indirect call sites can not be reached from program entry. */ -void CallGraph::verifyCallGraph() +void PTACallGraph::verifyCallGraph() { CallEdgeMap::const_iterator it = indirectCallMap.begin(); CallEdgeMap::const_iterator eit = indirectCallMap.end(); @@ -317,18 +321,18 @@ void CallGraph::verifyCallGraph() /*! * Whether its reachable between two functions */ -bool CallGraph::isReachableBetweenFunctions(const SVFFunction* srcFn, const SVFFunction* dstFn) const +bool PTACallGraph::isReachableBetweenFunctions(const SVFFunction* srcFn, const SVFFunction* dstFn) const { - CallGraphNode* dstNode = getCallGraphNode(dstFn); + PTACallGraphNode* dstNode = getCallGraphNode(dstFn); - std::stack nodeStack; + std::stack nodeStack; NodeBS visitedNodes; nodeStack.push(dstNode); visitedNodes.set(dstNode->getId()); while (nodeStack.empty() == false) { - CallGraphNode* node = const_cast(nodeStack.top()); + PTACallGraphNode* node = const_cast(nodeStack.top()); nodeStack.pop(); if (node->getFunction() == srcFn) @@ -336,7 +340,7 @@ bool CallGraph::isReachableBetweenFunctions(const SVFFunction* srcFn, const SVFF for (CallGraphEdgeConstIter it = node->InEdgeBegin(), eit = node->InEdgeEnd(); it != eit; ++it) { - CallGraphEdge* edge = *it; + PTACallGraphEdge* edge = *it; if (visitedNodes.test_and_set(edge->getSrcID())) nodeStack.push(edge->getSrcNode()); } @@ -348,12 +352,12 @@ bool CallGraph::isReachableBetweenFunctions(const SVFFunction* srcFn, const SVFF /*! * Dump call graph into dot file */ -void CallGraph::dump(const std::string& filename) +void PTACallGraph::dump(const std::string& filename) { GraphPrinter::WriteGraphToFile(outs(), filename, this); } -void CallGraph::view() +void PTACallGraph::view() { SVF::ViewGraph(this, "Call Graph"); } @@ -365,10 +369,10 @@ namespace SVF * Write value flow graph into dot file for debugging */ template<> -struct DOTGraphTraits : public DefaultDOTGraphTraits +struct DOTGraphTraits : public DefaultDOTGraphTraits { - typedef CallGraphNode NodeType; + typedef PTACallGraphNode NodeType; typedef NodeType::iterator ChildIteratorType; DOTGraphTraits(bool isSimple = false) : DefaultDOTGraphTraits(isSimple) @@ -376,17 +380,17 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits } /// Return name of the graph - static std::string getGraphName(CallGraph*) + static std::string getGraphName(PTACallGraph*) { return "Call Graph"; } /// Return function name; - static std::string getNodeLabel(CallGraphNode *node, CallGraph*) + static std::string getNodeLabel(PTACallGraphNode*node, PTACallGraph*) { return node->toString(); } - static std::string getNodeAttributes(CallGraphNode *node, CallGraph*) + static std::string getNodeAttributes(PTACallGraphNode*node, PTACallGraph*) { const SVFFunction* fun = node->getFunction(); if (!SVFUtil::isExtCall(fun)) @@ -398,20 +402,21 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits } template - static std::string getEdgeAttributes(CallGraphNode*, EdgeIter EI, CallGraph*) + static std::string getEdgeAttributes(PTACallGraphNode*, EdgeIter EI, + PTACallGraph*) { //TODO: mark indirect call of Fork with different color - CallGraphEdge* edge = *(EI.getCurrent()); + PTACallGraphEdge* edge = *(EI.getCurrent()); assert(edge && "No edge found!!"); std::string color; - if (edge->getEdgeKind() == CallGraphEdge::TDJoinEdge) + if (edge->getEdgeKind() == PTACallGraphEdge::TDJoinEdge) { color = "color=green"; } - else if (edge->getEdgeKind() == CallGraphEdge::TDForkEdge) + else if (edge->getEdgeKind() == PTACallGraphEdge::TDForkEdge) { color = "color=blue"; } @@ -429,7 +434,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits template static std::string getEdgeSourceLabel(NodeType*, EdgeIter EI) { - CallGraphEdge* edge = *(EI.getCurrent()); + PTACallGraphEdge* edge = *(EI.getCurrent()); assert(edge && "No edge found!!"); std::string str; diff --git a/svf/lib/Graphs/SVFG.cpp b/svf/lib/Graphs/SVFG.cpp index 380cfa34d..da55360de 100644 --- a/svf/lib/Graphs/SVFG.cpp +++ b/svf/lib/Graphs/SVFG.cpp @@ -360,9 +360,9 @@ void SVFG::connectIndirectSVFGEdges() } else if(const FormalINSVFGNode* formalIn = SVFUtil::dyn_cast(node)) { - CallGraphEdge::CallInstSet callInstSet; + PTACallGraphEdge::CallInstSet callInstSet; mssa->getPTA()->getCallGraph()->getDirCallSitesInvokingCallee(formalIn->getFun(),callInstSet); - for(CallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it) + for(PTACallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it) { const CallICFGNode* cs = *it; if(!mssa->hasMU(cs)) @@ -377,10 +377,10 @@ void SVFG::connectIndirectSVFGEdges() } else if(const FormalOUTSVFGNode* formalOut = SVFUtil::dyn_cast(node)) { - CallGraphEdge::CallInstSet callInstSet; + PTACallGraphEdge::CallInstSet callInstSet; // const MemSSA::RETMU* retMu = formalOut->getRetMU(); mssa->getPTA()->getCallGraph()->getDirCallSitesInvokingCallee(formalOut->getFun(),callInstSet); - for(CallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it) + for(PTACallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it) { const CallICFGNode* cs = *it; if(!mssa->hasCHI(cs)) diff --git a/svf/lib/Graphs/SVFGReadWrite.cpp b/svf/lib/Graphs/SVFGReadWrite.cpp index a0cc3e477..4b0eb0c78 100644 --- a/svf/lib/Graphs/SVFGReadWrite.cpp +++ b/svf/lib/Graphs/SVFGReadWrite.cpp @@ -144,9 +144,9 @@ void SVFG::writeToFile(const string& filename) } else if(const FormalINSVFGNode* formalIn = SVFUtil::dyn_cast(node)) { - CallGraphEdge::CallInstSet callInstSet; + PTACallGraphEdge::CallInstSet callInstSet; mssa->getPTA()->getCallGraph()->getDirCallSitesInvokingCallee(formalIn->getFun(),callInstSet); - for(CallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it) + for(PTACallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it) { const CallICFGNode* cs = *it; if(!mssa->hasMU(cs)) @@ -161,9 +161,9 @@ void SVFG::writeToFile(const string& filename) } else if(const FormalOUTSVFGNode* formalOut = SVFUtil::dyn_cast(node)) { - CallGraphEdge::CallInstSet callInstSet; + PTACallGraphEdge::CallInstSet callInstSet; mssa->getPTA()->getCallGraph()->getDirCallSitesInvokingCallee(formalOut->getFun(),callInstSet); - for(CallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it) + for(PTACallGraphEdge::CallInstSet::iterator it = callInstSet.begin(), eit = callInstSet.end(); it!=eit; ++it) { const CallICFGNode* cs = *it; if(!mssa->hasCHI(cs)) diff --git a/svf/lib/Graphs/SVFGStat.cpp b/svf/lib/Graphs/SVFGStat.cpp index bd6d7ef27..79bc1b074 100644 --- a/svf/lib/Graphs/SVFGStat.cpp +++ b/svf/lib/Graphs/SVFGStat.cpp @@ -29,7 +29,7 @@ #include "Graphs/SVFG.h" #include "Graphs/SVFGStat.h" -#include "Graphs/CallGraph.h" +#include "Graphs/PTACallGraph.h" using namespace SVF; using namespace std; diff --git a/svf/lib/Graphs/ThreadCallGraph.cpp b/svf/lib/Graphs/ThreadCallGraph.cpp index bb3528f77..843b8016e 100644 --- a/svf/lib/Graphs/ThreadCallGraph.cpp +++ b/svf/lib/Graphs/ThreadCallGraph.cpp @@ -39,8 +39,8 @@ using namespace SVFUtil; /*! * Constructor */ -ThreadCallGraph::ThreadCallGraph(const CallGraph& cg) : - CallGraph(cg), tdAPI(ThreadAPI::getThreadAPI()) +ThreadCallGraph::ThreadCallGraph(const PTACallGraph& cg) : + PTACallGraph(cg), tdAPI(ThreadAPI::getThreadAPI()) { kind = ThdCallGraph; DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Building ThreadCallGraph\n")); @@ -61,8 +61,8 @@ void ThreadCallGraph::updateCallGraph(PointerAnalysis* pta) for (; iter != eiter; iter++) { const CallICFGNode* cs = iter->first; - const CallGraph::FunctionSet &functions = iter->second; - for (CallGraph::FunctionSet::const_iterator func_iter = + const PTACallGraph::FunctionSet &functions = iter->second; + for (PTACallGraph::FunctionSet::const_iterator func_iter = functions.begin(); func_iter != functions.end(); func_iter++) { const SVFFunction* callee = *func_iter; @@ -125,13 +125,13 @@ void ThreadCallGraph::updateJoinEdge(PointerAnalysis* pta) bool ThreadCallGraph::addDirectForkEdge(const CallICFGNode* cs) { - CallGraphNode* caller = getCallGraphNode(cs->getCaller()); + PTACallGraphNode* caller = getCallGraphNode(cs->getCaller()); const SVFFunction* forkee = SVFUtil::dyn_cast(tdAPI->getForkedFun(cs)->getValue()); assert(forkee && "callee does not exist"); - CallGraphNode* callee = getCallGraphNode(forkee->getDefFunForMultipleModule()); + PTACallGraphNode* callee = getCallGraphNode(forkee->getDefFunForMultipleModule()); CallSiteID csId = addCallSite(cs, callee->getFunction()); - if (!hasGraphEdge(caller, callee, CallGraphEdge::TDForkEdge, csId)) + if (!hasGraphEdge(caller, callee, PTACallGraphEdge::TDForkEdge, csId)) { assert(cs->getCaller() == caller->getFunction() && "callee instruction not inside caller??"); @@ -151,12 +151,12 @@ bool ThreadCallGraph::addDirectForkEdge(const CallICFGNode* cs) */ bool ThreadCallGraph::addIndirectForkEdge(const CallICFGNode* cs, const SVFFunction* calleefun) { - CallGraphNode* caller = getCallGraphNode(cs->getCaller()); - CallGraphNode* callee = getCallGraphNode(calleefun); + PTACallGraphNode* caller = getCallGraphNode(cs->getCaller()); + PTACallGraphNode* callee = getCallGraphNode(calleefun); CallSiteID csId = addCallSite(cs, callee->getFunction()); - if (!hasGraphEdge(caller, callee, CallGraphEdge::TDForkEdge, csId)) + if (!hasGraphEdge(caller, callee, PTACallGraphEdge::TDForkEdge, csId)) { assert(cs->getCaller() == caller->getFunction() && "callee instruction not inside caller??"); @@ -180,14 +180,14 @@ bool ThreadCallGraph::addIndirectForkEdge(const CallICFGNode* cs, const SVFFunct void ThreadCallGraph::addDirectJoinEdge(const CallICFGNode* cs,const CallSiteSet& forkset) { - CallGraphNode* joinFunNode = getCallGraphNode(cs->getCaller()); + PTACallGraphNode* joinFunNode = getCallGraphNode(cs->getCaller()); for (CallSiteSet::const_iterator it = forkset.begin(), eit = forkset.end(); it != eit; ++it) { const SVFFunction* threadRoutineFun = SVFUtil::dyn_cast(tdAPI->getForkedFun(*it)->getValue()); assert(threadRoutineFun && "thread routine function does not exist"); - CallGraphNode* threadRoutineFunNode = getCallGraphNode(threadRoutineFun); + PTACallGraphNode* threadRoutineFunNode = getCallGraphNode(threadRoutineFun); CallSiteID csId = addCallSite(cs, threadRoutineFun); if (!hasThreadJoinEdge(cs,joinFunNode,threadRoutineFunNode, csId)) diff --git a/svf/lib/Graphs/VFG.cpp b/svf/lib/Graphs/VFG.cpp index 4f7c89110..c4609c97f 100644 --- a/svf/lib/Graphs/VFG.cpp +++ b/svf/lib/Graphs/VFG.cpp @@ -438,7 +438,7 @@ PHIVFGNode::PHIVFGNode(NodeID id, const PAGNode* r,VFGNodeK k): VFGNode(id, k), * 2) connect VFG edges * between two statements (PAGEdges) */ -VFG::VFG(CallGraph* cg, VFGK k): totalVFGNode(0), callgraph(cg), pag(SVFIR::getPAG()), kind(k) +VFG::VFG(PTACallGraph* cg, VFGK k): totalVFGNode(0), callgraph(cg), pag(SVFIR::getPAG()), kind(k) { DBOUT(DGENERAL, outs() << pasMsg("\tCreate VFG Top Level Node\n")); diff --git a/svf/lib/MSSA/MemRegion.cpp b/svf/lib/MSSA/MemRegion.cpp index 14d65ae84..5d194507b 100644 --- a/svf/lib/MSSA/MemRegion.cpp +++ b/svf/lib/MSSA/MemRegion.cpp @@ -173,7 +173,7 @@ SVFIR::SVFStmtList& MRGenerator::getPAGEdgesFromInst(const ICFGNode* node) void MRGenerator::collectModRefForLoadStore() { - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { const SVFFunction& fun = *item.second->getFunction(); @@ -247,7 +247,7 @@ void MRGenerator::collectModRefForCall() const NodeBS& subNodes = callGraphSCC->subNodes(callGraphNodeID); for(NodeBS::iterator it = subNodes.begin(), eit = subNodes.end(); it!=eit; ++it) { - CallGraphNode* subCallGraphNode = callGraph->getCallGraphNode(*it); + PTACallGraphNode* subCallGraphNode = callGraph->getCallGraphNode(*it); /// Get mod-ref of all callsites calling callGraphNode modRefAnalysis(subCallGraphNode,worklist); } @@ -629,17 +629,17 @@ bool MRGenerator::handleCallsiteModRef(NodeBS& mod, NodeBS& ref, const CallICFGN * Call site mod-ref analysis * Compute mod-ref of all callsites invoking this call graph node */ -void MRGenerator::modRefAnalysis(CallGraphNode* callGraphNode, WorkList& worklist) +void MRGenerator::modRefAnalysis(PTACallGraphNode* callGraphNode, WorkList& worklist) { /// add ref/mod set of callee to its invocation callsites at caller - for(CallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd(); + for(PTACallGraphNode::iterator it = callGraphNode->InEdgeBegin(), eit = callGraphNode->InEdgeEnd(); it!=eit; ++it) { - CallGraphEdge* edge = *it; + PTACallGraphEdge* edge = *it; /// handle direct callsites - for(CallGraphEdge::CallInstSet::iterator cit = edge->getDirectCalls().begin(), + for(PTACallGraphEdge::CallInstSet::iterator cit = edge->getDirectCalls().begin(), ecit = edge->getDirectCalls().end(); cit!=ecit; ++cit) { NodeBS mod, ref; @@ -649,7 +649,7 @@ void MRGenerator::modRefAnalysis(CallGraphNode* callGraphNode, WorkList& worklis worklist.push(edge->getSrcID()); } /// handle indirect callsites - for(CallGraphEdge::CallInstSet::iterator cit = edge->getIndirectCalls().begin(), + for(PTACallGraphEdge::CallInstSet::iterator cit = edge->getIndirectCalls().begin(), ecit = edge->getIndirectCalls().end(); cit!=ecit; ++cit) { NodeBS mod, ref; diff --git a/svf/lib/MSSA/MemSSA.cpp b/svf/lib/MSSA/MemSSA.cpp index d13477682..2aaac4260 100644 --- a/svf/lib/MSSA/MemSSA.cpp +++ b/svf/lib/MSSA/MemSSA.cpp @@ -575,7 +575,7 @@ u32_t MemSSA::getBBPhiNum() const void MemSSA::dumpMSSA(OutStream& Out) { - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { const SVFFunction* fun = item.second->getFunction(); diff --git a/svf/lib/MSSA/SVFGBuilder.cpp b/svf/lib/MSSA/SVFGBuilder.cpp index 43383c303..4e5b2484b 100644 --- a/svf/lib/MSSA/SVFGBuilder.cpp +++ b/svf/lib/MSSA/SVFGBuilder.cpp @@ -101,7 +101,7 @@ std::unique_ptr SVFGBuilder::buildMSSA(BVDataPTAImpl* pta, bool ptrOnlyM auto mssa = std::make_unique(pta, ptrOnlyMSSA); - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { diff --git a/svf/lib/MTA/LockAnalysis.cpp b/svf/lib/MTA/LockAnalysis.cpp index cce3da71b..755304272 100644 --- a/svf/lib/MTA/LockAnalysis.cpp +++ b/svf/lib/MTA/LockAnalysis.cpp @@ -98,12 +98,12 @@ void LockAnalysis::buildCandidateFuncSetforLock() ThreadCallGraph* tcg=tct->getThreadCallGraph(); TCT::PTACGNodeSet visited; - FIFOWorkList worklist; + FIFOWorkList worklist; for (InstSet::iterator it = locksites.begin(), eit = locksites.end(); it != eit; ++it) { const SVFFunction* fun=(*it)->getFun(); - CallGraphNode* cgnode = tcg->getCallGraphNode(fun); + PTACallGraphNode* cgnode = tcg->getCallGraphNode(fun); if (visited.find(cgnode) == visited.end()) { worklist.push(cgnode); @@ -113,7 +113,7 @@ void LockAnalysis::buildCandidateFuncSetforLock() for (InstSet::iterator it = unlocksites.begin(), eit = unlocksites.end(); it != eit; ++it) { const SVFFunction* fun = (*it)->getFun(); - CallGraphNode* cgnode = tcg->getCallGraphNode(fun); + PTACallGraphNode* cgnode = tcg->getCallGraphNode(fun); if (visited.find(cgnode) == visited.end()) { worklist.push(cgnode); @@ -122,11 +122,11 @@ void LockAnalysis::buildCandidateFuncSetforLock() } while (!worklist.empty()) { - const CallGraphNode* node = worklist.pop(); + const PTACallGraphNode* node = worklist.pop(); lockcandidateFuncSet.insert(node->getFunction()); - for (CallGraphNode::const_iterator nit = node->InEdgeBegin(), neit = node->InEdgeEnd(); nit != neit; nit++) + for (PTACallGraphNode::const_iterator nit = node->InEdgeBegin(), neit = node->InEdgeEnd(); nit != neit; nit++) { - const CallGraphNode* srcNode = (*nit)->getSrcNode(); + const PTACallGraphNode* srcNode = (*nit)->getSrcNode(); if (visited.find(srcNode) == visited.end()) { visited.insert(srcNode); @@ -271,16 +271,16 @@ void LockAnalysis::collectCxtLock() while (!clpList.empty()) { CxtLockProc clp = popFromCTPWorkList(); - CallGraphNode* cgNode = getTCG()->getCallGraphNode(clp.getProc()); + PTACallGraphNode* cgNode = getTCG()->getCallGraphNode(clp.getProc()); // lzh TODO. if (!isLockCandidateFun(cgNode->getFunction())) continue; - for (CallGraphNode::const_iterator nit = cgNode->OutEdgeBegin(), neit = cgNode->OutEdgeEnd(); nit != neit; nit++) + for (PTACallGraphNode::const_iterator nit = cgNode->OutEdgeBegin(), neit = cgNode->OutEdgeEnd(); nit != neit; nit++) { - const CallGraphEdge* cgEdge = (*nit); + const PTACallGraphEdge* cgEdge = (*nit); - for (CallGraphEdge::CallInstSet::const_iterator cit = cgEdge->directCallsBegin(), ecit = cgEdge->directCallsEnd(); + for (PTACallGraphEdge::CallInstSet::const_iterator cit = cgEdge->directCallsBegin(), ecit = cgEdge->directCallsEnd(); cit != ecit; ++cit) { DBOUT(DMTA, @@ -288,7 +288,7 @@ void LockAnalysis::collectCxtLock() << "-->" << cgEdge->getDstNode()->getFunction()->getName() << "\n"); handleCallRelation(clp, cgEdge, *cit); } - for (CallGraphEdge::CallInstSet::const_iterator ind = cgEdge->indirectCallsBegin(), eind = cgEdge->indirectCallsEnd(); + for (PTACallGraphEdge::CallInstSet::const_iterator ind = cgEdge->indirectCallsBegin(), eind = cgEdge->indirectCallsEnd(); ind != eind; ++ind) { DBOUT(DMTA, @@ -305,7 +305,7 @@ void LockAnalysis::collectCxtLock() /*! * Handling call relations when collecting context-sensitive locks */ -void LockAnalysis::handleCallRelation(CxtLockProc& clp, const CallGraphEdge* cgEdge, const CallICFGNode* cs) +void LockAnalysis::handleCallRelation(CxtLockProc& clp, const PTACallGraphEdge* cgEdge, const CallICFGNode* cs) { CallStrCxt cxt(clp.getContext()); @@ -432,7 +432,7 @@ void LockAnalysis::handleCall(const CxtStmt& cts) const CallICFGNode* call = SVFUtil::dyn_cast(cts.getStmt()); if (getTCG()->hasCallGraphEdge(call)) { - for (CallGraph::CallGraphEdgeSet::const_iterator cgIt = getTCG()->getCallEdgeBegin(call), ecgIt = getTCG()->getCallEdgeEnd(call); + for (PTACallGraph::CallGraphEdgeSet::const_iterator cgIt = getTCG()->getCallEdgeBegin(call), ecgIt = getTCG()->getCallEdgeEnd(call); cgIt != ecgIt; ++cgIt) { const SVFFunction* svfcallee = (*cgIt)->getDstNode()->getFunction(); @@ -454,14 +454,14 @@ void LockAnalysis::handleRet(const CxtStmt& cts) const ICFGNode* curInst = cts.getStmt(); const CallStrCxt& curCxt = cts.getContext(); const SVFFunction* svffun = curInst->getFun(); - CallGraphNode* curFunNode = getTCG()->getCallGraphNode(svffun); + PTACallGraphNode* curFunNode = getTCG()->getCallGraphNode(svffun); - for (CallGraphNode::const_iterator it = curFunNode->getInEdges().begin(), eit = curFunNode->getInEdges().end(); it != eit; ++it) + for (PTACallGraphNode::const_iterator it = curFunNode->getInEdges().begin(), eit = curFunNode->getInEdges().end(); it != eit; ++it) { - CallGraphEdge* edge = *it; + PTACallGraphEdge* edge = *it; if (SVFUtil::isa(edge)) continue; - for (CallGraphEdge::CallInstSet::const_iterator cit = (edge)->directCallsBegin(), ecit = (edge)->directCallsEnd(); cit != ecit; + for (PTACallGraphEdge::CallInstSet::const_iterator cit = (edge)->directCallsBegin(), ecit = (edge)->directCallsEnd(); cit != ecit; ++cit) { CallStrCxt newCxt = curCxt; @@ -478,7 +478,7 @@ void LockAnalysis::handleRet(const CxtStmt& cts) } } } - for (CallGraphEdge::CallInstSet::const_iterator cit = (edge)->indirectCallsBegin(), ecit = (edge)->indirectCallsEnd(); + for (PTACallGraphEdge::CallInstSet::const_iterator cit = (edge)->indirectCallsBegin(), ecit = (edge)->indirectCallsEnd(); cit != ecit; ++cit) { CallStrCxt newCxt = curCxt; diff --git a/svf/lib/MTA/MHP.cpp b/svf/lib/MTA/MHP.cpp index 8d697209f..e9ef74ab6 100644 --- a/svf/lib/MTA/MHP.cpp +++ b/svf/lib/MTA/MHP.cpp @@ -115,7 +115,7 @@ void MHP::analyzeInterleaving() else if (tct->isCallSite(curInst) && !tct->isExtCall(curInst)) { handleCall(cts, rootTid); - CallGraph::FunctionSet callees; + PTACallGraph::FunctionSet callees; if (!tct->isCandidateFun(getCallee(SVFUtil::cast(curInst), callees))) handleIntra(cts); } @@ -184,8 +184,8 @@ void MHP::handleNonCandidateFun(const CxtThreadStmt& cts) const SVFFunction* curfun = curInst->getFun(); assert((curInst == curfun->getEntryBlock()->front()) && "curInst is not the entry of non candidate function."); const CallStrCxt& curCxt = cts.getContext(); - CallGraphNode* node = tcg->getCallGraphNode(curfun); - for (CallGraphNode::const_iterator nit = node->OutEdgeBegin(), neit = node->OutEdgeEnd(); nit != neit; nit++) + PTACallGraphNode* node = tcg->getCallGraphNode(curfun); + for (PTACallGraphNode::const_iterator nit = node->OutEdgeBegin(), neit = node->OutEdgeEnd(); nit != neit; nit++) { const SVFFunction* callee = (*nit)->getDstNode()->getFunction(); if (!isExtCall(callee)) @@ -295,7 +295,7 @@ void MHP::handleCall(const CxtThreadStmt& cts, NodeID rootTid) const CallICFGNode* cbn = cast(call); if (tct->getThreadCallGraph()->hasCallGraphEdge(cbn)) { - for (CallGraph::CallGraphEdgeSet::const_iterator cgIt = tcg->getCallEdgeBegin(cbn), + for (PTACallGraph::CallGraphEdgeSet::const_iterator cgIt = tcg->getCallEdgeBegin(cbn), ecgIt = tcg->getCallEdgeEnd(cbn); cgIt != ecgIt; ++cgIt) { @@ -318,12 +318,12 @@ void MHP::handleCall(const CxtThreadStmt& cts, NodeID rootTid) */ void MHP::handleRet(const CxtThreadStmt& cts) { - CallGraphNode* curFunNode = tcg->getCallGraphNode(cts.getStmt()->getFun()); - for (CallGraphEdge* edge : curFunNode->getInEdges()) + PTACallGraphNode* curFunNode = tcg->getCallGraphNode(cts.getStmt()->getFun()); + for (PTACallGraphEdge* edge : curFunNode->getInEdges()) { if (SVFUtil::isa(edge)) continue; - for (CallGraphEdge::CallInstSet::const_iterator cit = (edge)->directCallsBegin(), + for (PTACallGraphEdge::CallInstSet::const_iterator cit = (edge)->directCallsBegin(), ecit = (edge)->directCallsEnd(); cit != ecit; ++cit) { @@ -340,7 +340,7 @@ void MHP::handleRet(const CxtThreadStmt& cts) } } } - for (CallGraphEdge::CallInstSet::const_iterator cit = (edge)->indirectCallsBegin(), + for (PTACallGraphEdge::CallInstSet::const_iterator cit = (edge)->indirectCallsBegin(), ecit = (edge)->indirectCallsEnd(); cit != ecit; ++cit) { @@ -520,19 +520,19 @@ bool MHP::isHBPair(NodeID tid1, NodeID tid2) bool MHP::isConnectedfromMain(const SVFFunction* fun) { - CallGraphNode* cgnode = tcg->getCallGraphNode(fun); - FIFOWorkList worklist; + PTACallGraphNode* cgnode = tcg->getCallGraphNode(fun); + FIFOWorkList worklist; TCT::PTACGNodeSet visited; worklist.push(cgnode); visited.insert(cgnode); while (!worklist.empty()) { - const CallGraphNode* node = worklist.pop(); + const PTACallGraphNode* node = worklist.pop(); if ("main" == node->getFunction()->getName()) return true; - for (CallGraphNode::const_iterator nit = node->InEdgeBegin(), neit = node->InEdgeEnd(); nit != neit; nit++) + for (PTACallGraphNode::const_iterator nit = node->InEdgeBegin(), neit = node->InEdgeEnd(); nit != neit; nit++) { - const CallGraphNode* srcNode = (*nit)->getSrcNode(); + const PTACallGraphNode* srcNode = (*nit)->getSrcNode(); if (visited.find(srcNode) == visited.end()) { visited.insert(srcNode); @@ -746,7 +746,7 @@ void ForkJoinAnalysis::analyzeForkJoinPair() DBOUT(DMTA, outs() << "-----\nForkJoinAnalysis root thread: " << tpair.first << " "); DBOUT(DMTA, cts.dump()); DBOUT(DMTA, outs() << "-----\n"); - CallGraph::FunctionSet callees; + PTACallGraph::FunctionSet callees; if (isTDFork(curInst)) { handleFork(cts, rootTid); @@ -882,7 +882,7 @@ void ForkJoinAnalysis::handleCall(const CxtStmt& cts, NodeID rootTid) const CallICFGNode* cbn = SVFUtil::cast(call); if (getTCG()->hasCallGraphEdge(cbn)) { - for (CallGraph::CallGraphEdgeSet::const_iterator cgIt = getTCG()->getCallEdgeBegin(cbn), + for (PTACallGraph::CallGraphEdgeSet::const_iterator cgIt = getTCG()->getCallEdgeBegin(cbn), ecgIt = getTCG()->getCallEdgeEnd(cbn); cgIt != ecgIt; ++cgIt) { @@ -904,12 +904,12 @@ void ForkJoinAnalysis::handleRet(const CxtStmt& cts) const ICFGNode* curInst = cts.getStmt(); const CallStrCxt& curCxt = cts.getContext(); - CallGraphNode* curFunNode = getTCG()->getCallGraphNode(curInst->getFun()); - for (CallGraphEdge* edge : curFunNode->getInEdges()) + PTACallGraphNode* curFunNode = getTCG()->getCallGraphNode(curInst->getFun()); + for (PTACallGraphEdge* edge : curFunNode->getInEdges()) { if (SVFUtil::isa(edge)) continue; - for (CallGraphEdge::CallInstSet::const_iterator cit = edge->directCallsBegin(), + for (PTACallGraphEdge::CallInstSet::const_iterator cit = edge->directCallsBegin(), ecit = edge->directCallsEnd(); cit != ecit; ++cit) { @@ -927,7 +927,7 @@ void ForkJoinAnalysis::handleRet(const CxtStmt& cts) } } } - for (CallGraphEdge::CallInstSet::const_iterator cit = edge->indirectCallsBegin(), + for (PTACallGraphEdge::CallInstSet::const_iterator cit = edge->indirectCallsBegin(), ecit = edge->indirectCallsEnd(); cit != ecit; ++cit) { diff --git a/svf/lib/MTA/TCT.cpp b/svf/lib/MTA/TCT.cpp index 323c24ecd..547aaba40 100644 --- a/svf/lib/MTA/TCT.cpp +++ b/svf/lib/MTA/TCT.cpp @@ -54,16 +54,16 @@ bool TCT::isInLoopInstruction(const ICFGNode* inst) { const ICFGNode* inst = worklist.pop(); insts.insert(inst); - CallGraphNode* cgnode = tcg->getCallGraphNode(inst->getFun()); - for(CallGraphNode::const_iterator nit = cgnode->InEdgeBegin(), neit = cgnode->InEdgeEnd(); nit!=neit; nit++) + PTACallGraphNode* cgnode = tcg->getCallGraphNode(inst->getFun()); + for(PTACallGraphNode::const_iterator nit = cgnode->InEdgeBegin(), neit = cgnode->InEdgeEnd(); nit!=neit; nit++) { - for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->directCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*nit)->directCallsBegin(), ecit = (*nit)->directCallsEnd(); cit!=ecit; ++cit) { if(insts.insert(*cit).second) worklist.push(*cit); } - for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->indirectCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*nit)->indirectCallsBegin(), ecit = (*nit)->indirectCallsEnd(); cit!=ecit; ++cit) { if(insts.insert(*cit).second) @@ -101,18 +101,18 @@ bool TCT::isInRecursion(const ICFGNode* inst) const if(tcgSCC->isInCycle(tcg->getCallGraphNode(svffun)->getId())) return true; - const CallGraphNode* cgnode = tcg->getCallGraphNode(svffun); + const PTACallGraphNode* cgnode = tcg->getCallGraphNode(svffun); - for(CallGraphNode::const_iterator nit = cgnode->InEdgeBegin(), neit = cgnode->InEdgeEnd(); nit!=neit; nit++) + for(PTACallGraphNode::const_iterator nit = cgnode->InEdgeBegin(), neit = cgnode->InEdgeEnd(); nit!=neit; nit++) { - for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->directCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*nit)->directCallsBegin(), ecit = (*nit)->directCallsEnd(); cit!=ecit; ++cit) { const SVFFunction* caller = (*cit)->getFun(); if(visits.find(caller)==visits.end()) worklist.push(caller); } - for(CallGraphEdge::CallInstSet::const_iterator cit = (*nit)->indirectCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator cit = (*nit)->indirectCallsBegin(), ecit = (*nit)->indirectCallsEnd(); cit!=ecit; ++cit) { const SVFFunction* caller = (*cit)->getFun(); @@ -138,7 +138,7 @@ void TCT::markRelProcs() for(ThreadCallGraph::ForkEdgeSet::const_iterator nit = tcg->getForkEdgeBegin(*it), neit = tcg->getForkEdgeEnd(*it); nit!=neit; nit++) { - const CallGraphNode* forkeeNode = (*nit)->getDstNode(); + const PTACallGraphNode* forkeeNode = (*nit)->getDstNode(); candidateFuncSet.insert(forkeeNode->getFunction()); } @@ -159,18 +159,18 @@ void TCT::markRelProcs() */ void TCT::markRelProcs(const SVFFunction* svffun) { - CallGraphNode* cgnode = tcg->getCallGraphNode(svffun); - FIFOWorkList worklist; + PTACallGraphNode* cgnode = tcg->getCallGraphNode(svffun); + FIFOWorkList worklist; PTACGNodeSet visited; worklist.push(cgnode); visited.insert(cgnode); while(!worklist.empty()) { - const CallGraphNode* node = worklist.pop(); + const PTACallGraphNode* node = worklist.pop(); candidateFuncSet.insert(node->getFunction()); - for(CallGraphNode::const_iterator nit = node->InEdgeBegin(), neit = node->InEdgeEnd(); nit!=neit; nit++) + for(PTACallGraphNode::const_iterator nit = node->InEdgeBegin(), neit = node->InEdgeEnd(); nit!=neit; nit++) { - const CallGraphNode* srcNode = (*nit)->getSrcNode(); + const PTACallGraphNode* srcNode = (*nit)->getSrcNode(); if(visited.find(srcNode)==visited.end()) { visited.insert(srcNode); @@ -185,13 +185,13 @@ void TCT::markRelProcs(const SVFFunction* svffun) */ void TCT::collectEntryFunInCallGraph() { - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { const SVFFunction* fun = item.second->getFunction(); if (SVFUtil::isExtCall(fun)) continue; - CallGraphNode* node = tcg->getCallGraphNode(fun); + PTACallGraphNode* node = tcg->getCallGraphNode(fun); if (!node->hasIncomingEdge()) { entryFuncSet.insert(fun); @@ -241,7 +241,7 @@ void TCT::collectMultiForkedThreads() /*! * Handle call relations */ -void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, const CallICFGNode* cs) +void TCT::handleCallRelation(CxtThreadProc& ctp, const PTACallGraphEdge* cgEdge, const CallICFGNode* cs) { const SVFFunction* callee = cgEdge->getDstNode()->getFunction(); @@ -250,7 +250,7 @@ void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, co const CallICFGNode* callNode = cs; pushCxt(cxt,callNode,callee); - if(cgEdge->getEdgeKind() == CallGraphEdge::CallRetEdge) + if(cgEdge->getEdgeKind() == PTACallGraphEdge::CallRetEdge) { CxtThreadProc newctp(ctp.getTid(),cxt,callee); if(pushToCTPWorkList(newctp)) @@ -260,7 +260,7 @@ void TCT::handleCallRelation(CxtThreadProc& ctp, const CallGraphEdge* cgEdge, co } } - else if(cgEdge->getEdgeKind() == CallGraphEdge::TDForkEdge) + else if(cgEdge->getEdgeKind() == PTACallGraphEdge::TDForkEdge) { /// Create spawnee TCT node TCTNode* spawneeNode = getOrCreateTCTNode(cxt,callNode, oldCxt, callee); @@ -405,21 +405,21 @@ void TCT::build() while(!ctpList.empty()) { CxtThreadProc ctp = popFromCTPWorkList(); - CallGraphNode* cgNode = tcg->getCallGraphNode(ctp.getProc()); + PTACallGraphNode* cgNode = tcg->getCallGraphNode(ctp.getProc()); if(isCandidateFun(cgNode->getFunction()) == false) continue; - for(CallGraphNode::const_iterator nit = cgNode->OutEdgeBegin(), neit = cgNode->OutEdgeEnd(); nit!=neit; nit++) + for(PTACallGraphNode::const_iterator nit = cgNode->OutEdgeBegin(), neit = cgNode->OutEdgeEnd(); nit!=neit; nit++) { - const CallGraphEdge* cgEdge = (*nit); + const PTACallGraphEdge* cgEdge = (*nit); - for(CallGraphEdge::CallInstSet::const_iterator cit = cgEdge->directCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator cit = cgEdge->directCallsBegin(), ecit = cgEdge->directCallsEnd(); cit!=ecit; ++cit) { DBOUT(DMTA,outs() << "\nTCT handling direct call:" << **cit << "\t" << cgEdge->getSrcNode()->getFunction()->getName() << "-->" << cgEdge->getDstNode()->getFunction()->getName() << "\n"); handleCallRelation(ctp,cgEdge,*cit); } - for(CallGraphEdge::CallInstSet::const_iterator ind = cgEdge->indirectCallsBegin(), + for(PTACallGraphEdge::CallInstSet::const_iterator ind = cgEdge->indirectCallsBegin(), eind = cgEdge->indirectCallsEnd(); ind!=eind; ++ind) { DBOUT(DMTA,outs() << "\nTCT handling indirect call:" << **ind << "\t" << cgEdge->getSrcNode()->getFunction()->getName() << "-->" << cgEdge->getDstNode()->getFunction()->getName() << "\n"); @@ -546,7 +546,7 @@ TCTEdge* TCT::hasGraphEdge(TCTNode* src, TCTNode* dst, TCTEdge::CEDGEK kind) con } /*! - * get CallGraph edge via nodes + * get PTACallGraph edge via nodes */ TCTEdge* TCT::getGraphEdge(TCTNode* src, TCTNode* dst, TCTEdge::CEDGEK kind) { diff --git a/svf/lib/MemoryModel/PointerAnalysis.cpp b/svf/lib/MemoryModel/PointerAnalysis.cpp index b2ba50e05..32520fe12 100644 --- a/svf/lib/MemoryModel/PointerAnalysis.cpp +++ b/svf/lib/MemoryModel/PointerAnalysis.cpp @@ -116,8 +116,8 @@ void PointerAnalysis::initialize() } else { - CallGraph* cg = pag->getCallGraph(); - callgraph = new CallGraph(*cg); + PTACallGraph* cg = pag->getCallGraph(); + callgraph = new PTACallGraph(*cg); } callGraphSCCDetection(); @@ -413,7 +413,7 @@ void PointerAnalysis::resolveIndCalls(const CallICFGNode* cs, const PointsTo& ta callgraph->addIndirectCallGraphEdge(cs, cs->getCaller(), callee); // FIXME: do we need to update llvm call graph here? // The indirect call is maintained by ourself, We may update llvm's when we need to - //CallGraphNode* callgraphNode = callgraph->getOrInsertFunction(cs.getCaller()); + //PTACallGraphNode* callgraphNode = callgraph->getOrInsertFunction(cs.getCaller()); //callgraphNode->addCalledFunction(cs,callgraph->getOrInsertFunction(callee)); } } diff --git a/svf/lib/SABER/LeakChecker.cpp b/svf/lib/SABER/LeakChecker.cpp index 88cca277e..7cfc96c67 100644 --- a/svf/lib/SABER/LeakChecker.cpp +++ b/svf/lib/SABER/LeakChecker.cpp @@ -51,9 +51,9 @@ void LeakChecker::initSrcs() if(cs->getFun()->isUncalledFunction() || !cs->getType()->isPointerTy()) continue; - CallGraph::FunctionSet callees; + PTACallGraph::FunctionSet callees; getCallgraph()->getCallees(cs->getCallICFGNode(),callees); - for(CallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++) + for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++) { const SVFFunction* fun = *cit; if (isSourceLikeFun(fun)) @@ -111,9 +111,9 @@ void LeakChecker::initSnks() eit = pag->getCallSiteArgsMap().end(); it!=eit; ++it) { - CallGraph::FunctionSet callees; + PTACallGraph::FunctionSet callees; getCallgraph()->getCallees(it->first,callees); - for(CallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++) + for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit!=ecit; cit++) { const SVFFunction* fun = *cit; if (isSinkLikeFun(fun)) diff --git a/svf/lib/SABER/SaberCondAllocator.cpp b/svf/lib/SABER/SaberCondAllocator.cpp index 872227c58..ba9dff0a4 100644 --- a/svf/lib/SABER/SaberCondAllocator.cpp +++ b/svf/lib/SABER/SaberCondAllocator.cpp @@ -59,7 +59,7 @@ void SaberCondAllocator::allocate(const SVFModule *M) { DBOUT(DGENERAL, outs() << pasMsg("path condition allocation starts\n")); - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { const SVFFunction *func = (item.second)->getFunction(); diff --git a/svf/lib/SABER/SaberSVFGBuilder.cpp b/svf/lib/SABER/SaberSVFGBuilder.cpp index 826843470..b883adbe6 100644 --- a/svf/lib/SABER/SaberSVFGBuilder.cpp +++ b/svf/lib/SABER/SaberSVFGBuilder.cpp @@ -291,15 +291,15 @@ void SaberSVFGBuilder::rmIncomingEdgeForSUStore(BVDataPTAImpl* pta) /// Add actual parameter SVFGNode for 1st argument of a deallocation like external function -void SaberSVFGBuilder::AddExtActualParmSVFGNodes(CallGraph* callgraph) +void SaberSVFGBuilder::AddExtActualParmSVFGNodes(PTACallGraph* callgraph) { SVFIR* pag = SVFIR::getPAG(); for(SVFIR::CSToArgsListMap::iterator it = pag->getCallSiteArgsMap().begin(), eit = pag->getCallSiteArgsMap().end(); it!=eit; ++it) { - CallGraph::FunctionSet callees; + PTACallGraph::FunctionSet callees; callgraph->getCallees(it->first, callees); - for (CallGraph::FunctionSet::const_iterator cit = callees.begin(), + for (PTACallGraph::FunctionSet::const_iterator cit = callees.begin(), ecit = callees.end(); cit != ecit; cit++) { diff --git a/svf/lib/Util/CDGBuilder.cpp b/svf/lib/Util/CDGBuilder.cpp index 12739ad65..dd3dbb0e7 100644 --- a/svf/lib/Util/CDGBuilder.cpp +++ b/svf/lib/Util/CDGBuilder.cpp @@ -27,7 +27,7 @@ * Author: Xiao Cheng */ #include "Util/CDGBuilder.h" -#include "Graphs/CallGraph.h" +#include "Graphs/PTACallGraph.h" using namespace SVF; using namespace SVFUtil; @@ -123,7 +123,7 @@ s64_t CDGBuilder::getBBSuccessorBranchID(const SVFBasicBlock *BB, const SVFBasic */ void CDGBuilder::buildControlDependence(const SVFModule *svfgModule) { - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { const SVFFunction *svfFun = (item.second)->getFunction(); diff --git a/svf/lib/Util/CallGraphBuilder.cpp b/svf/lib/Util/CallGraphBuilder.cpp index 3fcaed624..a0fa7a952 100644 --- a/svf/lib/Util/CallGraphBuilder.cpp +++ b/svf/lib/Util/CallGraphBuilder.cpp @@ -36,9 +36,9 @@ using namespace SVF; using namespace SVFUtil; -CallGraph* CallGraphBuilder::buildSVFIRCallGraph(SVFModule* svfModule) +PTACallGraph* CallGraphBuilder::buildSVFIRCallGraph(SVFModule* svfModule) { - CallGraph* callgraph = new CallGraph(); + PTACallGraph* callgraph = new PTACallGraph(); for (const SVFFunction* svfFunc: svfModule->getFunctionSet()) { callgraph->addCallGraphNode(svfFunc); @@ -66,7 +66,7 @@ CallGraph* CallGraphBuilder::buildSVFIRCallGraph(SVFModule* svfModule) ThreadCallGraph* CallGraphBuilder::buildThreadCallGraph() { - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); ThreadCallGraph* cg = new ThreadCallGraph(*svfirCallGraph); ThreadAPI* tdAPI = ThreadAPI::getThreadAPI(); diff --git a/svf/lib/Util/PTAStat.cpp b/svf/lib/Util/PTAStat.cpp index 705b6f2ee..2a0e18216 100644 --- a/svf/lib/Util/PTAStat.cpp +++ b/svf/lib/Util/PTAStat.cpp @@ -28,7 +28,7 @@ */ #include -#include "Graphs/CallGraph.h" +#include "Graphs/PTACallGraph.h" #include "Util/PTAStat.h" #include "MemoryModel/PointerAnalysisImpl.h" #include "SVFIR/SVFIR.h" @@ -81,7 +81,7 @@ void PTAStat::performStat() void PTAStat::callgraphStat() { - CallGraph* graph = pta->getCallGraph(); + PTACallGraph* graph = pta->getCallGraph(); PointerAnalysis::CallGraphSCC* callgraphSCC = new PointerAnalysis::CallGraphSCC(graph); callgraphSCC->find(); @@ -93,8 +93,8 @@ void PTAStat::callgraphStat() unsigned edgeInCycle = 0; NodeSet sccRepNodeSet; - CallGraph::iterator it = graph->begin(); - CallGraph::iterator eit = graph->end(); + PTACallGraph::iterator it = graph->begin(); + PTACallGraph::iterator eit = graph->end(); for (; it != eit; ++it) { totalNode++; @@ -107,11 +107,11 @@ void PTAStat::callgraphStat() maxNodeInCycle = subNodes.count(); } - CallGraphNode::const_iterator edgeIt = it->second->InEdgeBegin(); - CallGraphNode::const_iterator edgeEit = it->second->InEdgeEnd(); + PTACallGraphNode::const_iterator edgeIt = it->second->InEdgeBegin(); + PTACallGraphNode::const_iterator edgeEit = it->second->InEdgeEnd(); for (; edgeIt != edgeEit; ++edgeIt) { - CallGraphEdge *edge = *edgeIt; + PTACallGraphEdge*edge = *edgeIt; totalEdge+= edge->getDirectCalls().size() + edge->getIndirectCalls().size(); if(callgraphSCC->repNode(edge->getSrcID()) == callgraphSCC->repNode(edge->getDstID())) { @@ -130,15 +130,15 @@ void PTAStat::callgraphStat() PTNumStatMap["CalRetPairInCycle"] = edgeInCycle; if(pta->getAnalysisTy() >= PointerAnalysis::PTATY::Andersen_BASE && pta->getAnalysisTy() <= PointerAnalysis::PTATY::Steensgaard_WPA) - SVFStat::printStat("CallGraph Stats (Andersen analysis)"); + SVFStat::printStat("PTACallGraph Stats (Andersen analysis)"); else if(pta->getAnalysisTy() >= PointerAnalysis::PTATY::FSDATAFLOW_WPA && pta->getAnalysisTy() <= PointerAnalysis::PTATY::FSCS_WPA) - SVFStat::printStat("CallGraph Stats (Flow-sensitive analysis)"); + SVFStat::printStat("PTACallGraph Stats (Flow-sensitive analysis)"); else if(pta->getAnalysisTy() >= PointerAnalysis::PTATY::CFLFICI_WPA && pta->getAnalysisTy() <= PointerAnalysis::PTATY::CFLFSCS_WPA) - SVFStat::printStat("CallGraph Stats (CFL-R analysis)"); + SVFStat::printStat("PTACallGraph Stats (CFL-R analysis)"); else if(pta->getAnalysisTy() >= PointerAnalysis::PTATY::FieldS_DDA && pta->getAnalysisTy() <= PointerAnalysis::PTATY::Cxt_DDA) - SVFStat::printStat("CallGraph Stats (DDA analysis)"); + SVFStat::printStat("PTACallGraph Stats (DDA analysis)"); else - SVFStat::printStat("CallGraph Stats"); + SVFStat::printStat("PTACallGraph Stats"); delete callgraphSCC; } diff --git a/svf/lib/Util/SVFStat.cpp b/svf/lib/Util/SVFStat.cpp index ed2c8743f..2bd350e4a 100644 --- a/svf/lib/Util/SVFStat.cpp +++ b/svf/lib/Util/SVFStat.cpp @@ -216,7 +216,7 @@ void SVFStat::branchStat() { u32_t numOfBB_2Succ = 0; u32_t numOfBB_3Succ = 0; - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { const SVFFunction* func = item.second->getFunction(); diff --git a/svf/lib/Util/SVFUtil.cpp b/svf/lib/Util/SVFUtil.cpp index 98aa8d22f..46d893af2 100644 --- a/svf/lib/Util/SVFUtil.cpp +++ b/svf/lib/Util/SVFUtil.cpp @@ -401,10 +401,10 @@ bool SVFUtil::isProgExitCall(const CallICFGNode* cs) /// Get program entry function from module. const SVFFunction* SVFUtil::getProgFunction(const std::string& funName) { - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { - const CallGraphNode*fun = item.second; + const PTACallGraphNode*fun = item.second; if (fun->getName()==funName) return fun->getFunction(); } @@ -414,10 +414,10 @@ const SVFFunction* SVFUtil::getProgFunction(const std::string& funName) /// Get program entry function from module. const SVFFunction* SVFUtil::getProgEntryFunction() { - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { - const CallGraphNode*fun = item.second; + const PTACallGraphNode*fun = item.second; if (isProgEntryFunction(fun->getFunction())) return (fun->getFunction()); } diff --git a/svf/lib/Util/ThreadAPI.cpp b/svf/lib/Util/ThreadAPI.cpp index ff7237e31..5739d8eac 100644 --- a/svf/lib/Util/ThreadAPI.cpp +++ b/svf/lib/Util/ThreadAPI.cpp @@ -32,8 +32,8 @@ #include "Util/ThreadAPI.h" #include "Util/SVFUtil.h" +#include "Graphs/PTACallGraph.h" #include "SVFIR/SVFIR.h" -#include "Graphs/CallGraph.h" #include /// std output #include @@ -270,7 +270,7 @@ void ThreadAPI::performAPIStat(SVFModule* module) statInit(tdAPIStatMap); - CallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); + PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph(); for (const auto& item: *svfirCallGraph) { for (SVFFunction::const_iterator bit = (item.second)->getFunction()->begin(), ebit = (item.second)->getFunction()->end(); bit != ebit; ++bit) diff --git a/svf/lib/WPA/VersionedFlowSensitive.cpp b/svf/lib/WPA/VersionedFlowSensitive.cpp index 9b279442a..4f094632b 100644 --- a/svf/lib/WPA/VersionedFlowSensitive.cpp +++ b/svf/lib/WPA/VersionedFlowSensitive.cpp @@ -483,7 +483,7 @@ void VersionedFlowSensitive::buildDeltaMaps(void) bool isDelta = false; if (const SVFFunction *fn = svfg->isFunEntrySVFGNode(s)) { - CallGraphEdge::CallInstSet callsites; + PTACallGraphEdge::CallInstSet callsites; /// use pre-analysis call graph to approximate all potential callsites ander->getCallGraph()->getIndCallSitesInvokingCallee(fn, callsites); isDelta = !callsites.empty();