Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename CallGraph to PTACallGraph #1579

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion svf-llvm/include/SVF-LLVM/LLVMModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/include/SVF-LLVM/SVFIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class SVFIRBuilder: public llvm::InstVisitor<SVFIRBuilder>
//}@

/// connect PAG edges based on callgraph
void updateCallGraph(CallGraph* callgraph);
void updateCallGraph(PTACallGraph* callgraph);

protected:
/// Handle globals including (global variable and functions)
Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/lib/LLVMModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/lib/LLVMUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CallGraphNode>(this))
if (const SVF::PTACallGraphNode* fun = SVFUtil::dyn_cast<PTACallGraphNode>(this))
{
rawstr << "Function: " << fun->getFunction()->getName() << " ";
}
Expand Down
10 changes: 5 additions & 5 deletions svf-llvm/lib/SVFIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CallBase>(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<Function>(llvmModuleSet()->getLLVMValue(*func_iter));

Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/tools/AE/ae.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/tools/Example/svf-ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion svf/include/AE/Svfexe/AbstractInterpretation.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class AbstractInterpretation
friend class BufOverflowDetector;

public:
typedef SCCDetection<CallGraph*> CallGraphSCC;
typedef SCCDetection<PTACallGraph*> CallGraphSCC;
/// Constructor
AbstractInterpretation();

Expand Down
10 changes: 5 additions & 5 deletions svf/include/DDA/DDAVFSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class DDAVFSolver
friend class DDAStat;
public:
typedef SCCDetection<SVFG*> SVFGSCC;
typedef SCCDetection<CallGraph*> CallGraphSCC;
typedef CallGraphEdge::CallInstSet CallInstSet;
typedef SCCDetection<PTACallGraph*> CallGraphSCC;
typedef PTACallGraphEdge::CallInstSet CallInstSet;
typedef SVFIR::CallSiteSet CallSiteSet;
typedef OrderedSet<DPIm> DPTItemSet;
typedef OrderedMap<DPIm, CPtSet> DPImToCPtSetMap;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions svf/include/Graphs/ICFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
namespace SVF
{

class CallGraph;
class PTACallGraph;

/*!
* Interprocedural Control-Flow Graph (ICFG)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- CallGraph.h -- Call graph representation----------------------------//
//===- PTACallGraph.h -- Call graph representation----------------------------//
//
// SVF: Static Value-Flow Analysis
//
Expand All @@ -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"
Expand All @@ -38,7 +38,7 @@
namespace SVF
{

class CallGraphNode;
class PTACallGraphNode;
class SVFModule;


Expand All @@ -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<CallGraphNode> GenericCallGraphEdgeTy;
class CallGraphEdge : public GenericCallGraphEdgeTy
typedef GenericEdge<PTACallGraphNode> GenericCallGraphEdgeTy;
class PTACallGraphEdge : public GenericCallGraphEdgeTy
{

public:
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -163,28 +163,28 @@ class CallGraphEdge : public GenericCallGraphEdgeTy

virtual const std::string toString() const;

typedef GenericNode<CallGraphNode,CallGraphEdge>::GEdgeSetTy CallGraphEdgeSet;
typedef GenericNode<PTACallGraphNode, PTACallGraphEdge>::GEdgeSetTy CallGraphEdgeSet;

};

/*
* Call Graph node representing a function
*/
typedef GenericNode<CallGraphNode,CallGraphEdge> GenericCallGraphNodeTy;
class CallGraphNode : public GenericCallGraphNodeTy
typedef GenericNode<PTACallGraphNode, PTACallGraphEdge> 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)
{

}
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -237,13 +237,13 @@ class CallGraphNode : public GenericCallGraphNodeTy
/*!
* Pointer Analysis Call Graph used internally for various pointer analysis
*/
typedef GenericGraph<CallGraphNode,CallGraphEdge> GenericCallGraphTy;
class CallGraph : public GenericCallGraphTy
typedef GenericGraph<PTACallGraphNode, PTACallGraphEdge> GenericCallGraphTy;
class PTACallGraph : public GenericCallGraphTy
{

public:
typedef CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
typedef Map<const SVFFunction*, CallGraphNode *> FunToCallGraphNodeMap;
typedef PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet;
typedef Map<const SVFFunction*, PTACallGraphNode*> FunToCallGraphNodeMap;
typedef Map<const CallICFGNode*, CallGraphEdgeSet> CallInstToCallGraphEdgesMap;
typedef std::pair<const CallICFGNode*, const SVFFunction*> CallSitePair;
typedef Map<CallSitePair, CallSiteID> CallSiteToIdMap;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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!!");
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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<SVF::CallGraphNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::CallGraphNode,SVF::CallGraphEdge>* >
template<> struct GenericGraphTraits<SVF::PTACallGraphNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::PTACallGraphNode,SVF::PTACallGraphEdge>* >
{
};

/// Inverse GenericGraphTraits specializations for call graph node, it is used for inverse traversal.
template<>
struct GenericGraphTraits<Inverse<SVF::CallGraphNode *> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::CallGraphNode,SVF::CallGraphEdge>* > >
struct GenericGraphTraits<Inverse<SVF::PTACallGraphNode*> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::PTACallGraphNode,SVF::PTACallGraphEdge>* > >
{
};

template<> struct GenericGraphTraits<SVF::CallGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::CallGraphNode,SVF::CallGraphEdge>* >
template<> struct GenericGraphTraits<SVF::PTACallGraph*> : public GenericGraphTraits<SVF::GenericGraph<SVF::PTACallGraphNode,SVF::PTACallGraphEdge>* >
{
typedef SVF::CallGraphNode *NodeRef;
typedef SVF::PTACallGraphNode*NodeRef;
};

} // End namespace llvm
Expand Down
Loading
Loading