Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SVF::CallGraphBuilder Class Reference

#include <CallGraphBuilder.h>

Public Member Functions

 CallGraphBuilder ()=default
 
CallGraphbuildSVFIRCallGraph (SVFModule *svfModule)
 Buidl SVFIR callgraoh.
 
PTACallGraphbuildPTACallGraph ()
 Buidl PTA callgraoh.
 
ThreadCallGraphbuildThreadCallGraph ()
 Build thread-aware callgraph.
 

Detailed Description

Definition at line 44 of file CallGraphBuilder.h.

Constructor & Destructor Documentation

◆ CallGraphBuilder()

SVF::CallGraphBuilder::CallGraphBuilder ( )
default

Member Function Documentation

◆ buildPTACallGraph()

PTACallGraph * CallGraphBuilder::buildPTACallGraph ( )

Buidl PTA callgraoh.

Definition at line 69 of file CallGraphBuilder.cpp.

70{
72 return new PTACallGraph(*svfirCallGraph);
73}
CallGraph * getCallGraph()
Definition SVFIR.h:193
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:116
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ buildSVFIRCallGraph()

CallGraph * CallGraphBuilder::buildSVFIRCallGraph ( SVFModule svfModule)

Buidl SVFIR callgraoh.

Definition at line 41 of file CallGraphBuilder.cpp.

42{
43 CallGraph* callgraph = new CallGraph();
44 for (const SVFFunction* svfFunc: svfModule->getFunctionSet())
45 {
46 callgraph->addCallGraphNode(svfFunc);
47 }
48
49 for (const auto& item : *callgraph)
50 {
51 for (const SVFBasicBlock* svfbb : (item.second)->getFunction()->getBasicBlockList())
52 {
53 for (const ICFGNode* inst : svfbb->getICFGNodeList())
54 {
56 {
57 const CallICFGNode* callBlockNode = cast<CallICFGNode>(inst);
58 if(const SVFFunction* callee = callBlockNode->getCalledFunction())
59 {
60 callgraph->addDirectCallGraphEdge(callBlockNode,(item.second)->getFunction(),callee);
61 }
62 }
63 }
64 }
65 }
66 return callgraph;
67}
cJSON * item
Definition cJSON.h:222
void addCallGraphNode(const SVFFunction *fun)
Definition CallGraph.cpp:86
void addDirectCallGraphEdge(const CallICFGNode *call, const SVFFunction *callerFun, const SVFFunction *calleeFun)
Add direct call edges.
const SVFFunction * getCalledFunction() const
Definition ICFGNode.h:518
const SVFFunction * getFunction(const std::string &name)
Get the corresponding Function based on its name.
Definition LLVMUtil.cpp:411
bool isNonInstricCallSite(const ICFGNode *inst)
Whether an instruction is a callsite in the application code, excluding llvm intrinsic calls.
Definition SVFUtil.h:189

◆ buildThreadCallGraph()

ThreadCallGraph * CallGraphBuilder::buildThreadCallGraph ( )

Build thread-aware callgraph.

Definition at line 75 of file CallGraphBuilder.cpp.

76{
79
81 for (const auto& item: *svfirCallGraph)
82 {
83 for (const SVFBasicBlock* svfbb : (item.second)->getFunction()->getBasicBlockList())
84 {
85 for (const ICFGNode* inst : svfbb->getICFGNodeList())
86 {
87 if (SVFUtil::isa<CallICFGNode>(inst) && tdAPI->isTDFork(SVFUtil::cast<CallICFGNode>(inst)))
88 {
89 const CallICFGNode* cs = cast<CallICFGNode>(inst);
90 cg->addForksite(cs);
91 const ValVar* svfVar = tdAPI->getForkedFun(cs);
92 if (SVFUtil::isa<FunValVar>(svfVar))
93 {
94 cg->addDirectForkEdge(cs);
95 }
96 // indirect call to the start routine function
97 else
98 {
99 cg->addThreadForkEdgeSetMap(cs, nullptr);
100 }
101 }
102 }
103 }
104 }
105 // record join sites
106 for (const auto& item: *svfirCallGraph)
107 {
108 for (const SVFBasicBlock* svfbb : (item.second)->getFunction()->getBasicBlockList())
109 {
110 for (const ICFGNode* node : svfbb->getICFGNodeList())
111 {
112 if (SVFUtil::isa<CallICFGNode>(node) && tdAPI->isTDJoin(SVFUtil::cast<CallICFGNode>(node)))
113 {
114 const CallICFGNode* cs = SVFUtil::cast<CallICFGNode>(node);
115 cg->addJoinsite(cs);
116 }
117 }
118 }
119 }
120
121 return cg;
122}
const ValVar * getForkedFun(const CallICFGNode *inst) const
bool isTDFork(const CallICFGNode *inst) const
Return true if this call create a new thread.
bool isTDJoin(const CallICFGNode *inst) const
Return true if this call wait for a worker thread.
static ThreadAPI * getThreadAPI()
Return a static reference.
Definition ThreadAPI.h:107

The documentation for this class was generated from the following files: