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

#include <ThreadCallGraph.h>

Inheritance diagram for SVF::ThreadCallGraph:
SVF::PTACallGraph SVF::GenericGraph< NodeTy, EdgeTy >

Public Types

typedef Set< const CallICFGNode * > InstSet
 
typedef InstSet CallSiteSet
 
typedef Set< CallSiteSet * > CtxSet
 
typedef ThreadForkEdge::ForkEdgeSet ForkEdgeSet
 
typedef Map< const CallICFGNode *, ForkEdgeSetCallInstToForkEdgesMap
 
typedef ThreadJoinEdge::JoinEdgeSet JoinEdgeSet
 
typedef Map< const CallICFGNode *, JoinEdgeSetCallInstToJoinEdgesMap
 
typedef HareParForEdge::ParForEdgeSet ParForEdgeSet
 
typedef Map< const CallICFGNode *, ParForEdgeSetCallInstToParForEdgesMap
 
- Public Types inherited from SVF::PTACallGraph
enum  CGEK { NormCallGraph , ThdCallGraph }
 
typedef PTACallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet
 
typedef Map< const SVFFunction *, PTACallGraphNode * > FunToCallGraphNodeMap
 
typedef Map< const CallICFGNode *, CallGraphEdgeSetCallInstToCallGraphEdgesMap
 
typedef std::pair< const CallICFGNode *, const SVFFunction * > CallSitePair
 
typedef Map< CallSitePair, CallSiteIDCallSiteToIdMap
 
typedef Map< CallSiteID, CallSitePairIdToCallSiteMap
 
typedef Set< const SVFFunction * > FunctionSet
 
typedef OrderedMap< const CallICFGNode *, FunctionSetCallEdgeMap
 
typedef CallGraphEdgeSet::iterator CallGraphEdgeIter
 
typedef CallGraphEdgeSet::const_iterator CallGraphEdgeConstIter
 
- Public Types inherited from SVF::GenericGraph< NodeTy, EdgeTy >
typedef NodeTy NodeType
 
typedef EdgeTy EdgeType
 
typedef OrderedMap< NodeID, NodeType * > IDToNodeMapTy
 NodeID to GenericNode map.
 
typedef IDToNodeMapTy::iterator iterator
 Node Iterators.
 
typedef IDToNodeMapTy::const_iterator const_iterator
 

Public Member Functions

 ThreadCallGraph (const CallGraph &cg)
 Constructor.
 
 ThreadCallGraph (ThreadCallGraph &cg)=delete
 
virtual ~ThreadCallGraph ()
 Destructor.
 
void updateCallGraph (PointerAnalysis *pta)
 Update call graph using pointer results.
 
void updateJoinEdge (PointerAnalysis *pta)
 Update join edge using pointer analysis results.
 
bool hasThreadForkEdge (const CallICFGNode *cs) const
 Get call graph edge via call instruction.
 
ForkEdgeSet::const_iterator getForkEdgeBegin (const CallICFGNode *cs) const
 
ForkEdgeSet::const_iterator getForkEdgeEnd (const CallICFGNode *cs) const
 
bool hasThreadJoinEdge (const CallICFGNode *cs) const
 Get call graph edge via call instruction.
 
JoinEdgeSet::const_iterator getJoinEdgeBegin (const CallICFGNode *cs) const
 
JoinEdgeSet::const_iterator getJoinEdgeEnd (const CallICFGNode *cs) const
 
void getJoinSites (const PTACallGraphNode *routine, InstSet &csSet)
 
- Public Member Functions inherited from SVF::PTACallGraph
 PTACallGraph (CGEK k=NormCallGraph)
 Constructor.
 
 PTACallGraph (const CallGraph &other)
 Copy constructor.
 
virtual ~PTACallGraph ()
 Destructor.
 
CGEK getKind () const
 Return type of this callgraph.
 
CallEdgeMapgetIndCallMap ()
 Get callees from an indirect callsite.
 
bool hasIndCSCallees (const CallICFGNode *cs) const
 
const FunctionSetgetIndCSCallees (const CallICFGNode *cs) const
 
u32_t getTotalCallSiteNumber () const
 
u32_t getNumOfResolvedIndCallEdge () const
 
const CallInstToCallGraphEdgesMapgetCallInstToCallGraphEdgesMap () const
 
void verifyCallGraph ()
 Issue a warning if the function which has indirect call sites can not be reached from program entry.
 
PTACallGraphNodegetCallGraphNode (NodeID id) const
 Get call graph node.
 
PTACallGraphNodegetCallGraphNode (const SVFFunction *fun) const
 
CallSiteID getCallSiteID (const CallICFGNode *cs, const SVFFunction *callee) const
 Get CallSiteID.
 
bool hasCallSiteID (const CallICFGNode *cs, const SVFFunction *callee) const
 
const CallSitePairgetCallSitePair (CallSiteID id) const
 
const CallICFGNodegetCallSite (CallSiteID id) const
 
const SVFFunctiongetCallerOfCallSite (CallSiteID id) const
 
const SVFFunctiongetCalleeOfCallSite (CallSiteID id) const
 
PTACallGraphEdgehasGraphEdge (PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const
 Whether we have already created this call graph edge.
 
PTACallGraphEdgegetGraphEdge (PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId)
 Get call graph edge via nodes.
 
void getCallees (const CallICFGNode *cs, FunctionSet &callees)
 Get all callees for a callsite.
 
bool hasCallGraphEdge (const CallICFGNode *inst) const
 Get call graph edge via call instruction.
 
CallGraphEdgeSet::const_iterator getCallEdgeBegin (const CallICFGNode *inst) const
 
CallGraphEdgeSet::const_iterator getCallEdgeEnd (const CallICFGNode *inst) const
 
void addIndirectCallGraphEdge (const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
 Add indirect call edges.
 
void getAllCallSitesInvokingCallee (const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
 Get callsites invoking the callee.
 
void getDirCallSitesInvokingCallee (const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
 
void getIndCallSitesInvokingCallee (const SVFFunction *callee, PTACallGraphEdge::CallInstSet &csSet)
 
bool isReachableBetweenFunctions (const SVFFunction *srcFn, const SVFFunction *dstFn) const
 Whether its reachable between two functions.
 
void dump (const std::string &filename)
 Dump the graph.
 
void view ()
 View the graph from the debugger.
 
- Public Member Functions inherited from SVF::GenericGraph< NodeTy, EdgeTy >
 GenericGraph ()
 Constructor.
 
virtual ~GenericGraph ()
 Destructor.
 
void destroy ()
 Release memory.
 
iterator begin ()
 Iterators.
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node.
 
NodeTypegetGNode (NodeID id) const
 Get a node.
 
bool hasGNode (NodeID id) const
 Has a node.
 
void removeGNode (NodeType *node)
 Delete a node.
 
u32_t getTotalNodeNum () const
 Get total number of node/edge.
 
u32_t getTotalEdgeNum () const
 
void incNodeNum ()
 Increase number of node/edge.
 
void incEdgeNum ()
 

Static Public Member Functions

static bool classof (const ThreadCallGraph *)
 ClassOf.
 
static bool classof (const PTACallGraph *g)
 
ThreadAPItdAPI
 Thread API.
 
CallSiteSet forksites
 all thread fork sites
 
CallSiteSet joinsites
 all thread fork sites
 
CallSiteSet parForSites
 all parallel for sites
 
CallInstToForkEdgesMap callinstToThreadForkEdgesMap
 Map a call instruction to its corresponding fork edges.
 
CallInstToJoinEdgesMap callinstToThreadJoinEdgesMap
 Map a call instruction to its corresponding join edges.
 
CallInstToParForEdgesMap callinstToHareParForEdgesMap
 Map a call instruction to its corresponding hare_parallel_for edges.
 
bool isForksite (const CallICFGNode *csInst)
 
bool isJoinsite (const CallICFGNode *csInst)
 
bool isParForSite (const CallICFGNode *csInst)
 
CallSiteSet::const_iterator forksitesBegin () const
 Fork sites iterators.
 
CallSiteSet::const_iterator forksitesEnd () const
 
CallSiteSet::const_iterator joinsitesBegin () const
 Join sites iterators.
 
CallSiteSet::const_iterator joinsitesEnd () const
 
CallSiteSet::const_iterator parForSitesBegin () const
 hare_parallel_for sites iterators
 
CallSiteSet::const_iterator parForSitesEnd () const
 
u32_t getNumOfForksite () const
 Num of fork/join sites.
 
u32_t getNumOfJoinsite () const
 
u32_t getNumOfParForSite () const
 
ThreadAPIgetThreadAPI () const
 Thread API.
 
bool addForksite (const CallICFGNode *cs)
 Add fork sites which directly or indirectly create a thread.
 
bool addJoinsite (const CallICFGNode *cs)
 
bool addParForSite (const CallICFGNode *cs)
 
bool addDirectForkEdge (const CallICFGNode *cs)
 Add direct/indirect thread fork edges.
 
bool addIndirectForkEdge (const CallICFGNode *cs, const SVFFunction *callee)
 
void addDirectJoinEdge (const CallICFGNode *cs, const CallSiteSet &forksite)
 Add thread join edges.
 
void addThreadForkEdgeSetMap (const CallICFGNode *cs, ThreadForkEdge *edge)
 map call instruction to its PTACallGraphEdge map
 
void addThreadJoinEdgeSetMap (const CallICFGNode *cs, ThreadJoinEdge *edge)
 map call instruction to its PTACallGraphEdge map
 
void addHareParForEdgeSetMap (const CallICFGNode *cs, HareParForEdge *edge)
 map call instruction to its PTACallGraphEdge map
 
ThreadJoinEdgehasThreadJoinEdge (const CallICFGNode *call, PTACallGraphNode *joinFunNode, PTACallGraphNode *threadRoutineFunNode, CallSiteID csId) const
 has thread join edge
 

Additional Inherited Members

- Public Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
u32_t edgeNum
 total num of node
 
u32_t nodeNum
 total num of edge
 
- Protected Member Functions inherited from SVF::PTACallGraph
void destroy ()
 Clean up memory.
 
CallSiteID addCallSite (const CallICFGNode *cs, const SVFFunction *callee)
 Add CallSiteID.
 
void addEdge (PTACallGraphEdge *edge)
 Add call graph edge.
 
- Protected Attributes inherited from SVF::PTACallGraph
FunToCallGraphNodeMap funToCallGraphNodeMap
 Call Graph node map.
 
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap
 Map a call instruction to its corresponding call edges.
 
NodeID callGraphNodeNum
 
u32_t numOfResolvedIndCallEdge
 
CGEK kind
 
- Protected Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
IDToNodeMapTy IDToNodeMap
 node map
 

Detailed Description

Thread sensitive call graph

Definition at line 160 of file ThreadCallGraph.h.

Member Typedef Documentation

◆ CallInstToForkEdgesMap

Definition at line 168 of file ThreadCallGraph.h.

◆ CallInstToJoinEdgesMap

Definition at line 170 of file ThreadCallGraph.h.

◆ CallInstToParForEdgesMap

Definition at line 172 of file ThreadCallGraph.h.

◆ CallSiteSet

Definition at line 165 of file ThreadCallGraph.h.

◆ CtxSet

Definition at line 166 of file ThreadCallGraph.h.

◆ ForkEdgeSet

Definition at line 167 of file ThreadCallGraph.h.

◆ InstSet

Definition at line 164 of file ThreadCallGraph.h.

◆ JoinEdgeSet

Definition at line 169 of file ThreadCallGraph.h.

◆ ParForEdgeSet

Definition at line 171 of file ThreadCallGraph.h.

Constructor & Destructor Documentation

◆ ThreadCallGraph() [1/2]

ThreadCallGraph::ThreadCallGraph ( const CallGraph cg)

Constructor.

Constructor

Definition at line 43 of file ThreadCallGraph.cpp.

43 :
45{
47 DBOUT(DGENERAL, outs() << SVFUtil::pasMsg("Building ThreadCallGraph\n"));
48}
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:484
#define DGENERAL
Definition SVFType.h:490
static ThreadAPI * getThreadAPI()
Return a static reference.
Definition ThreadAPI.h:107
ThreadAPI * tdAPI
Thread API.
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
Definition SVFUtil.cpp:100
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

◆ ThreadCallGraph() [2/2]

SVF::ThreadCallGraph::ThreadCallGraph ( ThreadCallGraph cg)
delete

◆ ~ThreadCallGraph()

virtual SVF::ThreadCallGraph::~ThreadCallGraph ( )
inlinevirtual

Destructor.

Definition at line 180 of file ThreadCallGraph.h.

181 {
182 }

Member Function Documentation

◆ addDirectForkEdge()

bool ThreadCallGraph::addDirectForkEdge ( const CallICFGNode cs)

Add direct/indirect thread fork edges.

Add direct fork edges

Definition at line 126 of file ThreadCallGraph.cpp.

127{
128
130 const SVFFunction* forkee = SVFUtil::dyn_cast<FunValVar>(tdAPI->getForkedFun(cs))
132 assert(forkee && "callee does not exist");
133 PTACallGraphNode* callee = getCallGraphNode(forkee->getDefFunForMultipleModule());
134 CallSiteID csId = addCallSite(cs, callee->getFunction());
135
137 {
138 assert(cs->getCaller() == caller->getFunction() && "callee instruction not inside caller??");
139
141 edge->addDirectCallSite(cs);
142
143 addEdge(edge);
145 return true;
146 }
147 else
148 return false;
149}
const SVFFunction * getFunction() const
Get function of this call node.
Definition CallGraph.h:131
const SVFFunction * getCaller() const
Return callsite.
Definition ICFGNode.h:470
void addEdge(PTACallGraphEdge *edge)
Add call graph edge.
PTACallGraphEdge * hasGraphEdge(PTACallGraphNode *src, PTACallGraphNode *dst, PTACallGraphEdge::CEDGEK kind, CallSiteID csId) const
Whether we have already created this call graph edge.
CallSiteID addCallSite(const CallICFGNode *cs, const SVFFunction *callee)
Add CallSiteID.
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
const CallGraphNode * getCallGraphNode() const
Definition SVFValue.h:363
const ValVar * getForkedFun(const CallICFGNode *inst) const
void addThreadForkEdgeSetMap(const CallICFGNode *cs, ThreadForkEdge *edge)
map call instruction to its PTACallGraphEdge map
unsigned CallSiteID
Definition GeneralType.h:58

◆ addDirectJoinEdge()

void ThreadCallGraph::addDirectJoinEdge ( const CallICFGNode cs,
const CallSiteSet forkset 
)

Add thread join edges.

Add direct fork edges As join edge is a special return which is back to join site(s) rather than its fork site A ThreadJoinEdge is created from the functions where join sites reside in to the start routine function But we don't invoke addEdge() method to add the edge to src and dst, otherwise it makes a scc cycle

Definition at line 182 of file ThreadCallGraph.cpp.

183{
184
186
187 for (CallSiteSet::const_iterator it = forkset.begin(), eit = forkset.end(); it != eit; ++it)
188 {
189
191 SVFUtil::dyn_cast<FunValVar>(tdAPI->getForkedFun(*it))
193 ->getFunction();
194 assert(threadRoutineFun && "thread routine function does not exist");
197
199 {
200 assert(cs->getCaller() == joinFunNode->getFunction() && "callee instruction not inside caller??");
202 edge->addDirectCallSite(cs);
203
205 }
206 }
207}
bool hasThreadJoinEdge(const CallICFGNode *cs) const
Get call graph edge via call instruction.
void addThreadJoinEdgeSetMap(const CallICFGNode *cs, ThreadJoinEdge *edge)
map call instruction to its PTACallGraphEdge map

◆ addForksite()

bool SVF::ThreadCallGraph::addForksite ( const CallICFGNode cs)
inline

Add fork sites which directly or indirectly create a thread.

Definition at line 333 of file ThreadCallGraph.h.

334 {
336 return forksites.insert(cs).second;
337 }
CallSiteSet forksites
all thread fork sites
CallInstToForkEdgesMap callinstToThreadForkEdgesMap
Map a call instruction to its corresponding fork edges.

◆ addHareParForEdgeSetMap()

void SVF::ThreadCallGraph::addHareParForEdgeSetMap ( const CallICFGNode cs,
HareParForEdge edge 
)
inline

map call instruction to its PTACallGraphEdge map

Definition at line 383 of file ThreadCallGraph.h.

384 {
385 if(edge!=nullptr)
386 {
389 }
390 }
CallInstToCallGraphEdgesMap callinstToCallGraphEdgesMap
Map a call instruction to its corresponding call edges.
CallInstToParForEdgesMap callinstToHareParForEdgesMap
Map a call instruction to its corresponding hare_parallel_for edges.

◆ addIndirectForkEdge()

bool ThreadCallGraph::addIndirectForkEdge ( const CallICFGNode cs,
const SVFFunction calleefun 
)

Add indirect fork edge to update call graph

Definition at line 154 of file ThreadCallGraph.cpp.

155{
158
159 CallSiteID csId = addCallSite(cs, callee->getFunction());
160
162 {
163 assert(cs->getCaller() == caller->getFunction() && "callee instruction not inside caller??");
164
166 edge->addInDirectCallSite(cs);
167
168 addEdge(edge);
170 return true;
171 }
172 else
173 return false;
174}

◆ addJoinsite()

bool SVF::ThreadCallGraph::addJoinsite ( const CallICFGNode cs)
inline

Definition at line 338 of file ThreadCallGraph.h.

339 {
341 return joinsites.insert(cs).second;
342 }
CallSiteSet joinsites
all thread fork sites
CallInstToJoinEdgesMap callinstToThreadJoinEdgesMap
Map a call instruction to its corresponding join edges.

◆ addParForSite()

bool SVF::ThreadCallGraph::addParForSite ( const CallICFGNode cs)
inline

Definition at line 343 of file ThreadCallGraph.h.

344 {
346 return parForSites.insert(cs).second;
347 }
CallSiteSet parForSites
all parallel for sites

◆ addThreadForkEdgeSetMap()

void SVF::ThreadCallGraph::addThreadForkEdgeSetMap ( const CallICFGNode cs,
ThreadForkEdge edge 
)
inline

map call instruction to its PTACallGraphEdge map

Definition at line 363 of file ThreadCallGraph.h.

364 {
365 if(edge!=nullptr)
366 {
369 }
370 }

◆ addThreadJoinEdgeSetMap()

void SVF::ThreadCallGraph::addThreadJoinEdgeSetMap ( const CallICFGNode cs,
ThreadJoinEdge edge 
)
inline

map call instruction to its PTACallGraphEdge map

Definition at line 373 of file ThreadCallGraph.h.

374 {
375 if(edge!=nullptr)
376 {
379 }
380 }

◆ classof() [1/2]

static bool SVF::ThreadCallGraph::classof ( const PTACallGraph g)
inlinestatic

Definition at line 190 of file ThreadCallGraph.h.

191 {
192 return g->getKind() == PTACallGraph::ThdCallGraph;
193 }

◆ classof() [2/2]

static bool SVF::ThreadCallGraph::classof ( const ThreadCallGraph )
inlinestatic

ClassOf.

Definition at line 186 of file ThreadCallGraph.h.

187 {
188 return true;
189 }

◆ forksitesBegin()

CallSiteSet::const_iterator SVF::ThreadCallGraph::forksitesBegin ( ) const
inline

Fork sites iterators.

Definition at line 275 of file ThreadCallGraph.h.

276 {
277 return forksites.begin();
278 }

◆ forksitesEnd()

CallSiteSet::const_iterator SVF::ThreadCallGraph::forksitesEnd ( ) const
inline

Definition at line 279 of file ThreadCallGraph.h.

280 {
281 return forksites.end();
282 }

◆ getForkEdgeBegin()

ForkEdgeSet::const_iterator SVF::ThreadCallGraph::getForkEdgeBegin ( const CallICFGNode cs) const
inline

Definition at line 210 of file ThreadCallGraph.h.

211 {
212 CallInstToForkEdgesMap::const_iterator it = callinstToThreadForkEdgesMap.find(cs);
213 assert(it != callinstToThreadForkEdgesMap.end() && "call instruction not found");
214 return it->second.begin();
215 }

◆ getForkEdgeEnd()

ForkEdgeSet::const_iterator SVF::ThreadCallGraph::getForkEdgeEnd ( const CallICFGNode cs) const
inline

Definition at line 216 of file ThreadCallGraph.h.

217 {
218 CallInstToForkEdgesMap::const_iterator it = callinstToThreadForkEdgesMap.find(cs);
219 assert(it != callinstToThreadForkEdgesMap.end() && "call instruction not found");
220 return it->second.end();
221 }

◆ getJoinEdgeBegin()

JoinEdgeSet::const_iterator SVF::ThreadCallGraph::getJoinEdgeBegin ( const CallICFGNode cs) const
inline

Definition at line 230 of file ThreadCallGraph.h.

231 {
232 CallInstToJoinEdgesMap::const_iterator it = callinstToThreadJoinEdgesMap.find(cs);
233 assert(it != callinstToThreadJoinEdgesMap.end() && "call instruction does not have a valid callee");
234 return it->second.begin();
235 }

◆ getJoinEdgeEnd()

JoinEdgeSet::const_iterator SVF::ThreadCallGraph::getJoinEdgeEnd ( const CallICFGNode cs) const
inline

Definition at line 236 of file ThreadCallGraph.h.

237 {
238 CallInstToJoinEdgesMap::const_iterator it = callinstToThreadJoinEdgesMap.find(cs);
239 assert(it != callinstToThreadJoinEdgesMap.end() && "call instruction does not have a valid callee");
240 return it->second.end();
241 }

◆ getJoinSites()

void SVF::ThreadCallGraph::getJoinSites ( const PTACallGraphNode routine,
InstSet csSet 
)
inline

Definition at line 242 of file ThreadCallGraph.h.

243 {
244 for(CallInstToJoinEdgesMap::const_iterator it = callinstToThreadJoinEdgesMap.begin(), eit = callinstToThreadJoinEdgesMap.end(); it!=eit; ++it)
245 {
246 for(JoinEdgeSet::const_iterator jit = it->second.begin(), ejit = it->second.end(); jit!=ejit; ++jit)
247 {
248 if((*jit)->getDstNode() == routine)
249 {
250 csSet.insert(it->first);
251 }
252 }
253 }
254 }

◆ getNumOfForksite()

u32_t SVF::ThreadCallGraph::getNumOfForksite ( ) const
inline

Num of fork/join sites.

Definition at line 311 of file ThreadCallGraph.h.

312 {
313 return forksites.size();
314 }

◆ getNumOfJoinsite()

u32_t SVF::ThreadCallGraph::getNumOfJoinsite ( ) const
inline

Definition at line 315 of file ThreadCallGraph.h.

316 {
317 return joinsites.size();
318 }

◆ getNumOfParForSite()

u32_t SVF::ThreadCallGraph::getNumOfParForSite ( ) const
inline

Definition at line 319 of file ThreadCallGraph.h.

320 {
321 return parForSites.size();
322 }

◆ getThreadAPI()

ThreadAPI * SVF::ThreadCallGraph::getThreadAPI ( ) const
inline

Thread API.

Definition at line 326 of file ThreadCallGraph.h.

327 {
328 return tdAPI;
329 }

◆ hasThreadForkEdge()

bool SVF::ThreadCallGraph::hasThreadForkEdge ( const CallICFGNode cs) const
inline

Get call graph edge via call instruction.

whether this call instruction has a valid call graph edge

Definition at line 205 of file ThreadCallGraph.h.

206 {
207 return callinstToThreadForkEdgesMap.find(cs) !=
209 }

◆ hasThreadJoinEdge() [1/2]

ThreadJoinEdge * SVF::ThreadCallGraph::hasThreadJoinEdge ( const CallICFGNode call,
PTACallGraphNode joinFunNode,
PTACallGraphNode threadRoutineFunNode,
CallSiteID  csId 
) const
inline

has thread join edge

Definition at line 393 of file ThreadCallGraph.h.

394 {
395 ThreadJoinEdge joinEdge(joinFunNode,threadRoutineFunNode, csId);
396 CallInstToJoinEdgesMap::const_iterator it = callinstToThreadJoinEdgesMap.find(call);
398 {
399 JoinEdgeSet::const_iterator jit = it->second.find(&joinEdge);
400 if(jit!=it->second.end())
401 return *jit;
402 }
403 return nullptr;
404 }

◆ hasThreadJoinEdge() [2/2]

bool SVF::ThreadCallGraph::hasThreadJoinEdge ( const CallICFGNode cs) const
inline

Get call graph edge via call instruction.

whether this call instruction has a valid call graph edge

Definition at line 226 of file ThreadCallGraph.h.

227 {
229 }

◆ isForksite()

bool SVF::ThreadCallGraph::isForksite ( const CallICFGNode csInst)
inline

Whether a callsite is a fork or join or hare_parallel_for

Definition at line 259 of file ThreadCallGraph.h.

260 {
261 return forksites.find(csInst) != forksites.end();
262 }

◆ isJoinsite()

bool SVF::ThreadCallGraph::isJoinsite ( const CallICFGNode csInst)
inline

Definition at line 263 of file ThreadCallGraph.h.

264 {
265 return joinsites.find(csInst) != joinsites.end();
266 }

◆ isParForSite()

bool SVF::ThreadCallGraph::isParForSite ( const CallICFGNode csInst)
inline

Definition at line 267 of file ThreadCallGraph.h.

268 {
269 return parForSites.find(csInst) != parForSites.end();
270 }

◆ joinsitesBegin()

CallSiteSet::const_iterator SVF::ThreadCallGraph::joinsitesBegin ( ) const
inline

Join sites iterators.

Definition at line 287 of file ThreadCallGraph.h.

288 {
289 return joinsites.begin();
290 }

◆ joinsitesEnd()

CallSiteSet::const_iterator SVF::ThreadCallGraph::joinsitesEnd ( ) const
inline

Definition at line 291 of file ThreadCallGraph.h.

292 {
293 return joinsites.end();
294 }

◆ parForSitesBegin()

CallSiteSet::const_iterator SVF::ThreadCallGraph::parForSitesBegin ( ) const
inline

hare_parallel_for sites iterators

Definition at line 299 of file ThreadCallGraph.h.

300 {
301 return parForSites.begin();
302 }

◆ parForSitesEnd()

CallSiteSet::const_iterator SVF::ThreadCallGraph::parForSitesEnd ( ) const
inline

Definition at line 303 of file ThreadCallGraph.h.

304 {
305 return parForSites.end();
306 }

◆ updateCallGraph()

void ThreadCallGraph::updateCallGraph ( PointerAnalysis pta)

Update call graph using pointer results.

Definition at line 57 of file ThreadCallGraph.cpp.

58{
59
60 PointerAnalysis::CallEdgeMap::const_iterator iter = pta->getIndCallMap().begin();
61 PointerAnalysis::CallEdgeMap::const_iterator eiter = pta->getIndCallMap().end();
62 for (; iter != eiter; iter++)
63 {
64 const CallICFGNode* cs = iter->first;
66 for (PTACallGraph::FunctionSet::const_iterator func_iter =
67 functions.begin(); func_iter != functions.end(); func_iter++)
68 {
71 }
72 }
73
74 // Fork sites
75 for (CallSiteSet::const_iterator it = forksitesBegin(), eit = forksitesEnd(); it != eit; ++it)
76 {
78 if(SVFUtil::dyn_cast<FunValVar>(forkedval)==nullptr)
79 {
80 SVFIR* pag = pta->getPAG();
81 const NodeBS targets = pta->getPts(forkedval->getId()).toNodeBS();
82 for (NodeBS::iterator ii = targets.begin(), ie = targets.end(); ii != ie; ii++)
83 {
84 if(ObjVar* objPN = SVFUtil::dyn_cast<ObjVar>(pag->getGNode(*ii)))
85 {
86 const MemObj* obj = pag->getObject(objPN);
87 if(obj->isFunction())
88 {
89 const SVFFunction* svfCallee = SVFUtil::cast<CallGraphNode>(obj->getGNode())->getFunction();
91 }
92 }
93 }
94 }
95 }
96}
NodeType * getGNode(NodeID id) const
Get a node.
void addIndirectCallGraphEdge(const CallICFGNode *cs, const SVFFunction *callerFun, const SVFFunction *calleeFun)
Add indirect call edges.
Set< const SVFFunction * > FunctionSet
virtual const PointsTo & getPts(NodeID ptr)=0
Get points-to targets of a pointer. It needs to be implemented in child class.
SVFIR * getPAG() const
CallEdgeMap & getIndCallMap()
Get callees from an indirect callsite.
NodeBS toNodeBS() const
Returns this points-to set as a NodeBS.
Definition PointsTo.cpp:313
const MemObj * getObject(NodeID id) const
Definition SVFIR.h:396
CallSiteSet::const_iterator forksitesEnd() const
bool addIndirectForkEdge(const CallICFGNode *cs, const SVFFunction *callee)
CallSiteSet::const_iterator forksitesBegin() const
Fork sites iterators.

◆ updateJoinEdge()

void ThreadCallGraph::updateJoinEdge ( PointerAnalysis pta)

Update join edge using pointer analysis results.

Update join edge using pointer analysis results

Definition at line 102 of file ThreadCallGraph.cpp.

103{
104
105 for (CallSiteSet::const_iterator it = joinsitesBegin(), eit = joinsitesEnd(); it != eit; ++it)
106 {
108 // find its corresponding fork sites first
110 for (CallSiteSet::const_iterator it = forksitesBegin(), eit = forksitesEnd(); it != eit; ++it)
111 {
113 if (pta->alias(jointhread->getId(), forkthread->getId()))
114 {
115 forkset.insert(*it);
116 }
117 }
118 assert(!forkset.empty() && "Can't find a forksite for this join!!");
120 }
121}
virtual AliasResult alias(const SVFValue *V1, const SVFValue *V2)=0
Interface exposed to users of our pointer analysis, given Value infos.
const ValVar * getForkedThread(const CallICFGNode *inst) const
Return arguments/attributes of pthread_create / hare_parallel_for.
const SVFVar * getJoinedThread(const CallICFGNode *inst) const
Return arguments/attributes of pthread_join.
CallSiteSet::const_iterator joinsitesEnd() const
void addDirectJoinEdge(const CallICFGNode *cs, const CallSiteSet &forksite)
Add thread join edges.
CallSiteSet::const_iterator joinsitesBegin() const
Join sites iterators.

Member Data Documentation

◆ callinstToHareParForEdgesMap

CallInstToParForEdgesMap SVF::ThreadCallGraph::callinstToHareParForEdgesMap
private

Map a call instruction to its corresponding hare_parallel_for edges.

Definition at line 413 of file ThreadCallGraph.h.

◆ callinstToThreadForkEdgesMap

CallInstToForkEdgesMap SVF::ThreadCallGraph::callinstToThreadForkEdgesMap
private

Map a call instruction to its corresponding fork edges.

Definition at line 411 of file ThreadCallGraph.h.

◆ callinstToThreadJoinEdgesMap

CallInstToJoinEdgesMap SVF::ThreadCallGraph::callinstToThreadJoinEdgesMap
private

Map a call instruction to its corresponding join edges.

Definition at line 412 of file ThreadCallGraph.h.

◆ forksites

CallSiteSet SVF::ThreadCallGraph::forksites
private

all thread fork sites

Definition at line 408 of file ThreadCallGraph.h.

◆ joinsites

CallSiteSet SVF::ThreadCallGraph::joinsites
private

all thread fork sites

Definition at line 409 of file ThreadCallGraph.h.

◆ parForSites

CallSiteSet SVF::ThreadCallGraph::parForSites
private

all parallel for sites

Definition at line 410 of file ThreadCallGraph.h.

◆ tdAPI

ThreadAPI* SVF::ThreadCallGraph::tdAPI
private

Thread API.

Definition at line 407 of file ThreadCallGraph.h.


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