Static Value-Flow Analysis
TCT.h
Go to the documentation of this file.
1 //===- TCT.h -- Thread creation tree-------------//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-> <Yulei Sui>
6 //
7 
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
17 
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //===----------------------------------------------------------------------===//
22 
23 /*
24  * TCT.h
25  *
26  * Created on: Jun 24, 2015
27  * Author: Yulei Sui, Peng Di
28  */
29 
30 #ifndef TCTNodeDetector_H_
31 #define TCTNodeDetector_H_
32 
33 #include "Graphs/SCC.h"
34 #include "Graphs/ThreadCallGraph.h"
35 #include "Util/CxtStmt.h"
36 #include "Util/SVFUtil.h"
37 #include <set>
38 #include <vector>
39 
40 namespace SVF
41 {
42 
43 class TCTNode;
44 
45 
46 /*
47  * Thread creation edge represents a spawning relation between two context sensitive threads
48  */
51 {
52 public:
53  enum CEDGEK
54  {
56  };
58  TCTEdge(TCTNode* s, TCTNode* d, CEDGEK kind) :
59  GenericTCTEdgeTy(s, d, kind)
60  {
61  }
63  virtual ~TCTEdge()
64  {
65  }
67 
68  static inline bool classof(const TCTEdge*)
69  {
70  return true;
71  }
72  static inline bool classof(const GenericTCTEdgeTy *edge)
73  {
74  return edge->getEdgeKind() == TCTEdge::ThreadCreateEdge;
75  }
78 
79 };
80 
81 /*
82  * Each node represents a context-sensitive thread
83  */
86 {
87 
88 public:
90  TCTNode(NodeID i, const CxtThread& cctx) :
92  {
93  }
94 
95  void dump()
96  {
97  SVFUtil::outs() << "---\ntid: " << this->getId() << " inloop:" << ctx.isInloop() << " incycle:" << ctx.isIncycle() << " multiforked:"<< isMultiforked();
98  }
99 
101  inline const CxtThread& getCxtThread() const
102  {
103  return ctx;
104  }
105 
107 
108  inline bool isInloop() const
109  {
110  return ctx.isInloop();
111  }
112  inline bool isIncycle() const
113  {
114  return ctx.isIncycle();
115  }
116  inline void setMultiforked(bool value)
117  {
118  multiforked = value;
119  }
120  inline bool isMultiforked() const
121  {
122  return multiforked;
123  }
125 
127 
128  static inline bool classof(const TCTNode *)
129  {
130  return true;
131  }
132 
133  static inline bool classof(const GenericTCTNodeTy *node)
134  {
135  return node->getNodeKind() == TCTNodeKd;
136  }
137  static inline bool classof(const SVFBaseNode*node)
138  {
139  return node->getNodeKind() == TCTNodeKd;
140  }
142 
143 
144 private:
145  const CxtThread ctx;
147 };
148 
154 {
155 
156 public:
159  typedef ThreadCreateEdgeSet::iterator TCTNodeIter;
161  typedef std::vector<const ICFGNode*> InstVec;
171 
174  {
175  tcg = SVFUtil::cast<ThreadCallGraph>(pta->getCallGraph());
177  //tcg->updateJoinEdge(pta);
179  tcgSCC->find();
180  build();
181  }
182 
184  virtual ~TCT()
185  {
186  destroy();
187  }
188 
191  {
192  return pta->getModule();
193  }
194 
197  {
198  return tcg;
199  }
201  inline PointerAnalysis* getPTA() const
202  {
203  return pta;
204  }
206  inline TCTNode* getTCTNode(NodeID id) const
207  {
208  return getGNode(id);
209  }
211  TCTEdge* hasGraphEdge(TCTNode* src, TCTNode* dst, TCTEdge::CEDGEK kind) const;
214 
216 
217  inline ThreadCreateEdgeSet::const_iterator getChildrenBegin(const TCTNode* node) const
218  {
219  return node->OutEdgeBegin();
220  }
221  inline ThreadCreateEdgeSet::const_iterator getChildrenEnd(const TCTNode* node) const
222  {
223  return node->OutEdgeEnd();
224  }
225  inline ThreadCreateEdgeSet::const_iterator getParentsBegin(const TCTNode* node) const
226  {
227  return node->InEdgeBegin();
228  }
229  inline ThreadCreateEdgeSet::const_iterator getParentsEnd(const TCTNode* node) const
230  {
231  return node->InEdgeEnd();
232  }
234 
236  inline const FunSet& getMakredProcs() const
237  {
238  return candidateFuncSet;
239  }
240 
242  inline const FunSet& getEntryProcs() const
243  {
244  return entryFuncSet;
245  }
246 
248 
249  inline u32_t getTCTNodeNum() const
250  {
251  return TCTNodeNum;
252  }
253  inline u32_t getTCTEdgeNum() const
254  {
255  return TCTEdgeNum;
256  }
257  inline u32_t getMaxCxtSize() const
258  {
259  return MaxCxtSize;
260  }
262 
264  inline bool isExtCall(const ICFGNode* inst)
265  {
266  if(const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst))
267  return SVFUtil::isExtCall(call);
268  return false;
269  }
271  inline bool isCallSite(const ICFGNode* inst)
272  {
273  return SVFUtil::isa<CallICFGNode>(inst);
274  }
275 
277 
278  inline bool hasTCTNode(const CxtThread& ct) const
279  {
280  return ctpToNodeMap.find(ct)!=ctpToNodeMap.end();
281  }
282  inline TCTNode* getTCTNode(const CxtThread& ct) const
283  {
284  CxtThreadToNodeMap::const_iterator it = ctpToNodeMap.find(ct);
285  assert(it!=ctpToNodeMap.end() && "TCT node not found??");
286  return it->second;
287  }
289 
291  inline bool isCandidateFun(const PTACallGraph::FunctionSet& callees) const
292  {
293  for(PTACallGraph::FunctionSet::const_iterator cit = callees.begin(),
294  ecit = callees.end(); cit!=ecit; cit++)
295  {
296  if(candidateFuncSet.find((*cit))!=candidateFuncSet.end())
297  return true;
298  }
299  return false;
300  }
301  inline bool isCandidateFun(const SVFFunction* fun) const
302  {
303  return candidateFuncSet.find(fun)!=candidateFuncSet.end();
304  }
306  inline bool inSameCallGraphSCC(const PTACallGraphNode* src,const PTACallGraphNode* dst)
307  {
308  return (tcgSCC->repNode(src->getId()) == tcgSCC->repNode(dst->getId()));
309  }
310 
312 
313  inline bool hasParentThread(NodeID tid) const
315  {
316  const TCTNode* node = getTCTNode(tid);
317  return node->getInEdges().size()==1;
318  }
320  inline NodeID getParentThread(NodeID tid) const
321  {
322  const TCTNode* node = getTCTNode(tid);
323  assert(node->getInEdges().size()<=1 && "should have at most one parent thread");
324  assert(node->getInEdges().size()==1 && "does not have a parent thread");
325  const TCTEdge* edge = *(node->getInEdges().begin());
326  return edge->getSrcID();
327  }
329  const NodeBS getAncestorThread(NodeID tid) const
330  {
331  NodeBS tds;
332  if(hasParentThread(tid) == false)
333  return tds;
334 
335  FIFOWorkList<NodeID> worklist;
336  worklist.push(getParentThread(tid));
337 
338  while(!worklist.empty())
339  {
340  NodeID t = worklist.pop();
341  if(tds.test_and_set(t))
342  {
343  if(hasParentThread(t))
344  worklist.push(getParentThread(t));
345  }
346  }
347  return tds;
348  }
350  inline const NodeBS getSiblingThread(NodeID tid) const
351  {
352  NodeBS tds;
353  if(hasParentThread(tid) == false)
354  return tds;
355 
356  const TCTNode* node = getTCTNode(getParentThread(tid));
357  for(ThreadCreateEdgeSet::const_iterator it = getChildrenBegin(node), eit = getChildrenEnd(node); it!=eit; ++it)
358  {
359  NodeID child = (*it)->getDstNode()->getId();
360  if(child!=tid)
361  tds.set(child);
362  }
363 
364  return tds;
365  }
367 
369  const CallStrCxt& getCxtOfCxtThread(const CxtThread& ct) const
370  {
371  CxtThreadToForkCxt::const_iterator it = ctToForkCxtMap.find(ct);
372  assert(it!=ctToForkCxtMap.end() && "Cxt Thread not found!!");
373  return it->second;
374  }
375 
378  {
379  CxtThreadToFun::const_iterator it = ctToRoutineFunMap.find(ct);
380  assert(it!=ctToRoutineFunMap.end() && "Cxt Thread not found!!");
381  return it->second;
382  }
383 
385  inline LoopBBs& getJoinLoop(const CallICFGNode* join)
386  {
387  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
388  InstToLoopMap::iterator it = joinSiteToLoopMap.find(join);
389  assert(it!=joinSiteToLoopMap.end() && "loop not found");
390  return it->second;
391  }
392 
393  inline bool hasJoinLoop(const CallICFGNode* join) const
394  {
395  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
396  InstToLoopMap::const_iterator it = joinSiteToLoopMap.find(join);
397  return it!=joinSiteToLoopMap.end();
398  }
399 
400  bool hasLoop(const SVFBasicBlock* bb) const
401  {
402  const SVFFunction* fun = bb->getFunction();
403  return fun->hasLoopInfo(bb);
404  }
405  bool hasLoop(const ICFGNode* inst) const
406  {
407  return hasLoop(inst->getBB());
408  }
410  bool isJoinMustExecutedInLoop(const LoopBBs& lp,const ICFGNode* join);
412  const LoopBBs& getLoop(const ICFGNode* inst);
414  const LoopBBs& getLoop(const SVFBasicBlock* bb);
415 
417  void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee);
419  bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee);
420 
421  inline void pushCxt(CallStrCxt& cxt, CallSiteID csId)
422  {
423  cxt.push_back(csId);
424  if (cxt.size() > MaxCxtSize)
425  MaxCxtSize = cxt.size();
426  }
428  inline bool isJoinSiteInRecursion(const CallICFGNode* join) const
429  {
430  assert(tcg->getThreadAPI()->isTDJoin(join) && "not a join site");
431  return inRecurJoinSites.find(join)!=inRecurJoinSites.end();
432  }
434  void dumpCxt(CallStrCxt& cxt);
435 
437  void dump(const std::string& filename);
438 
440  void print() const;
441 
442 private:
448 
450  inline TCTNode* addTCTNode(const CxtThread& ct)
451  {
452  assert(ctpToNodeMap.find(ct)==ctpToNodeMap.end() && "Already has this node!!");
453  NodeID id = TCTNodeNum;
454  TCTNode* node = new TCTNode(id, ct);
455  addGNode(id, node);
456  TCTNodeNum++;
457  ctpToNodeMap[ct] = node;
458  return node;
459  }
461  inline bool addTCTEdge(TCTNode* src, TCTNode* dst)
462  {
463  if (!hasGraphEdge(src, dst, TCTEdge::ThreadCreateEdge))
464  {
465  TCTEdge* edge = new TCTEdge(src, dst, TCTEdge::ThreadCreateEdge);
466  dst->addIncomingEdge(edge);
467  src->addOutgoingEdge(edge);
468  TCTEdgeNum++;
469  return true;
470  }
471  return false;
472  }
473 
475  void build();
476 
478 
479  void markRelProcs();
480  void markRelProcs(const SVFFunction* fun);
482 
485 
489 
491 
492  void collectLoopInfoForJoin();
495  bool isLoopHeaderOfJoinLoop(const SVFBasicBlock* bb);
497  bool isLoopExitOfJoinLoop(const SVFBasicBlock* bb);
499 
501 
502  bool isInLoopInstruction(const ICFGNode* inst);
505  bool isInRecursion(const ICFGNode* inst) const;
507 
509  void handleCallRelation(CxtThreadProc& ctp, const PTACallGraphEdge* cgEdge, const CallICFGNode* call);
510 
512 
513  inline TCTNode* getOrCreateTCTNode(const CallStrCxt& cxt, const ICFGNode* fork,const CallStrCxt& oldCxt, const SVFFunction* routine)
514  {
515  CxtThread ct(cxt,fork);
516  CxtThreadToNodeMap::const_iterator it = ctpToNodeMap.find(ct);
517  if(it!=ctpToNodeMap.end())
518  {
519  return it->second;
520  }
521 
522  addCxtOfCxtThread(oldCxt,ct);
523  addStartRoutineOfCxtThread(routine,ct);
524 
526  return addTCTNode(ct);
527  }
529 
532  {
534  if(ct.getThread() != nullptr)
535  {
536  const ICFGNode* svfInst = ct.getThread();
537  ct.setInloop(isInLoopInstruction(svfInst));
538  ct.setIncycle(isInRecursion(svfInst));
539  }
541  else
542  {
543  ct.setInloop(false);
544  ct.setIncycle(false);
545  }
546  }
547 
549  void addCxtOfCxtThread(const CallStrCxt& cxt, const CxtThread& ct)
550  {
551  ctToForkCxtMap[ct] = cxt;
552  }
555  {
556  ctToRoutineFunMap[ct] = fun;
557  }
558 
560 
561  inline bool pushToCTPWorkList(const CxtThreadProc& ctp)
562  {
563  if(isVisitedCTPs(ctp)==false)
564  {
565  visitedCTPs.insert(ctp);
566  return ctpList.push(ctp);
567  }
568  return false;
569  }
571  {
572  CxtThreadProc ctp = ctpList.pop();
573  return ctp;
574  }
575  inline bool isVisitedCTPs(const CxtThreadProc& ctp) const
576  {
577  return visitedCTPs.find(ctp)!=visitedCTPs.end();
578  }
580  inline void destroy()
582  {
583  if(tcgSCC)
584  delete tcgSCC;
585  tcgSCC=nullptr;
586  }
587 
598 };
599 
600 } // End namespace SVF
601 
602 namespace SVF
603 {
604 /* !
605  * GenericGraphTraits specializations for constraint graph so that they can be treated as
606  * graphs by the generic graph algorithms.
607  * Provide graph traits for traversing from a constraint node using standard graph traversals.
608  */
609 template<> struct GenericGraphTraits<SVF::TCTNode*> : public GenericGraphTraits<SVF::GenericNode<SVF::TCTNode,SVF::TCTEdge>* >
610 {
611 };
612 
614 template<>
615 struct GenericGraphTraits<Inverse<SVF::TCTNode *> > : public GenericGraphTraits<Inverse<SVF::GenericNode<SVF::TCTNode,SVF::TCTEdge>* > >
616 {
617 };
618 
619 template<> struct GenericGraphTraits<SVF::TCT*> : public GenericGraphTraits<SVF::GenericGraph<SVF::TCTNode,SVF::TCTEdge>* >
620 {
622 };
623 
624 } // End namespace llvm
625 
626 #endif /* TCTNodeDetector_H_ */
cJSON * p
Definition: cJSON.cpp:2559
#define false
Definition: cJSON.cpp:70
cJSON * child
Definition: cJSON.cpp:2723
const char *const string
Definition: cJSON.h:172
bool isInloop() const
Definition: CxtStmt.h:264
bool isIncycle() const
Definition: CxtStmt.h:272
const ICFGNode * getThread() const
Return forksite.
Definition: CxtStmt.h:211
void setInloop(bool in)
inloop, incycle attributes
Definition: CxtStmt.h:260
void setIncycle(bool in)
Definition: CxtStmt.h:268
bool push(const Data &data)
Definition: WorkList.h:165
bool empty() const
Definition: WorkList.h:146
GEdgeKind getEdgeKind() const
Definition: GenericGraph.h:89
NodeID getSrcID() const
get methods of the components
Definition: GenericGraph.h:81
void addGNode(NodeID id, NodeType *node)
Add a Node.
Definition: GenericGraph.h:646
NodeType * getGNode(NodeID id) const
Get a node.
Definition: GenericGraph.h:653
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
Definition: GenericGraph.h:402
iterator OutEdgeEnd()
Definition: GenericGraph.h:458
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
Definition: GenericGraph.h:527
iterator OutEdgeBegin()
iterators
Definition: GenericGraph.h:454
iterator InEdgeBegin()
Definition: GenericGraph.h:462
bool addOutgoingEdge(EdgeType *outEdge)
Definition: GenericGraph.h:531
const GEdgeSetTy & getInEdges() const
Definition: GenericGraph.h:434
iterator InEdgeEnd()
Definition: GenericGraph.h:466
virtual const SVFBasicBlock * getBB() const
Return the basic block of this ICFGNode.
Definition: ICFGNode.h:82
Set< const SVFFunction * > FunctionSet
Definition: PTACallGraph.h:251
CallGraphSCC * getCallGraphSCC() const
Return call graph SCC.
PTACallGraph * getCallGraph() const
Return call graph.
SVFModule * getModule() const
Module.
void find(void)
Definition: SCC.h:308
NodeID repNode(NodeID n) const
get the rep node if not found return itself
Definition: SCC.h:139
GNodeK getNodeKind() const
Get node kind.
Definition: GenericGraph.h:266
NodeID getId() const
Get ID.
Definition: GenericGraph.h:260
const SVFFunction * getFunction() const
Definition: SVFValue.h:589
bool hasLoopInfo(const SVFBasicBlock *bb) const
Definition: SVFValue.h:470
bool test_and_set(unsigned Idx)
void set(unsigned Idx)
static bool classof(const GenericTCTEdgeTy *edge)
Definition: TCT.h:72
@ ThreadCreateEdge
Definition: TCT.h:55
TCTEdge(TCTNode *s, TCTNode *d, CEDGEK kind)
Constructor.
Definition: TCT.h:58
static bool classof(const TCTEdge *)
Classof.
Definition: TCT.h:68
virtual ~TCTEdge()
Destructor.
Definition: TCT.h:63
GenericNode< TCTNode, TCTEdge >::GEdgeSetTy ThreadCreateEdgeSet
Definition: TCT.h:77
void setMultiforked(bool value)
Definition: TCT.h:116
static bool classof(const SVFBaseNode *node)
Definition: TCT.h:137
const CxtThread & getCxtThread() const
Get CxtThread.
Definition: TCT.h:101
bool multiforked
Definition: TCT.h:146
bool isIncycle() const
Definition: TCT.h:112
bool isInloop() const
inloop, incycle attributes
Definition: TCT.h:108
void dump()
Definition: TCT.h:95
bool isMultiforked() const
Definition: TCT.h:120
const CxtThread ctx
Definition: TCT.h:145
static bool classof(const TCTNode *)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition: TCT.h:128
static bool classof(const GenericTCTNodeTy *node)
Definition: TCT.h:133
TCTNode(NodeID i, const CxtThread &cctx)
Constructor.
Definition: TCT.h:90
Definition: TCT.h:154
bool pushToCTPWorkList(const CxtThreadProc &ctp)
WorkList helper functions.
Definition: TCT.h:561
bool isCandidateFun(const SVFFunction *fun) const
Definition: TCT.h:301
bool isInRecursion(const ICFGNode *inst) const
Whether an instruction is in a recursion.
Definition: TCT.cpp:90
Set< CxtThreadProc > CxtThreadProcSet
Definition: TCT.h:169
CxtThreadToNodeMap ctpToNodeMap
Record all visited ctps.
Definition: TCT.h:593
Map< CxtThread, const SVFFunction * > CxtThreadToFun
Definition: TCT.h:166
Set< const ICFGNode * > InstSet
Definition: TCT.h:162
void setMultiForkedAttrs(CxtThread &ct)
Set multi-forked thread attributes.
Definition: TCT.h:531
FunSet entryFuncSet
Definition: TCT.h:588
ThreadCallGraph * getThreadCallGraph() const
Get TCG.
Definition: TCT.h:196
bool isJoinSiteInRecursion(const CallICFGNode *join) const
Whether a join site is in recursion.
Definition: TCT.h:428
FIFOWorkList< CxtThreadProc > CxtThreadProcVec
Definition: TCT.h:168
void collectLoopInfoForJoin()
Handle join site in loop.
Definition: TCT.cpp:314
void addCxtOfCxtThread(const CallStrCxt &cxt, const CxtThread &ct)
Add context for a thread at its spawning site (fork site)
Definition: TCT.h:549
bool isCallSite(const ICFGNode *inst)
Whether it is a callsite.
Definition: TCT.h:271
ThreadCallGraphSCC * tcgSCC
Procedures we care about during call graph traversing when creating TCT.
Definition: TCT.h:590
void collectEntryFunInCallGraph()
Get entry functions that are neither called by other functions nor extern functions.
Definition: TCT.cpp:186
Map< CxtThread, CallStrCxt > CxtThreadToForkCxt
Definition: TCT.h:165
CxtThreadToFun ctToRoutineFunMap
Map a CxtThread to the context at its spawning site (fork site).
Definition: TCT.h:595
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Push calling context.
Definition: TCT.cpp:444
CxtThreadProcSet visitedCTPs
CxtThreadProc List.
Definition: TCT.h:592
const LoopBBs & getLoop(const ICFGNode *inst)
Get loop for an instruction.
TCTNode * getOrCreateTCTNode(const CallStrCxt &cxt, const ICFGNode *fork, const CallStrCxt &oldCxt, const SVFFunction *routine)
Get or create a tct node based on CxtThread.
Definition: TCT.h:513
bool hasJoinLoop(const CallICFGNode *join) const
Definition: TCT.h:393
u32_t getMaxCxtSize() const
Definition: TCT.h:257
TCTNode * addTCTNode(const CxtThread &ct)
Add TCT node.
Definition: TCT.h:450
Set< const SVFFunction * > FunSet
Definition: TCT.h:160
ThreadCreateEdgeSet::const_iterator getChildrenBegin(const TCTNode *node) const
Get children and parent nodes.
Definition: TCT.h:217
NodeID getParentThread(NodeID tid) const
Get parent thread.
Definition: TCT.h:320
u32_t TCTNodeNum
Definition: TCT.h:445
const FunSet & getMakredProcs() const
Get marked candidate functions.
Definition: TCT.h:236
void addStartRoutineOfCxtThread(const SVFFunction *fun, const CxtThread &ct)
Add start routine function of a cxt thread.
Definition: TCT.h:554
bool hasLoop(const ICFGNode *inst) const
Definition: TCT.h:405
PointerAnalysis * getPTA() const
Get PTA.
Definition: TCT.h:201
InstToLoopMap joinSiteToLoopMap
Map a CxtThread to its start routine function.
Definition: TCT.h:596
bool hasTCTNode(const CxtThread &ct) const
Find/Get TCT node.
Definition: TCT.h:278
ThreadCreateEdgeSet::const_iterator getParentsEnd(const TCTNode *node) const
Definition: TCT.h:229
LoopBBs & getJoinLoop(const CallICFGNode *join)
Get loop for join site.
Definition: TCT.h:385
const NodeBS getSiblingThread(NodeID tid) const
Get sibling threads.
Definition: TCT.h:350
bool hasParentThread(NodeID tid) const
Get parent and sibling threads.
Definition: TCT.h:314
bool isVisitedCTPs(const CxtThreadProc &ctp) const
Definition: TCT.h:575
const FunSet & getEntryProcs() const
Get marked candidate functions.
Definition: TCT.h:242
u32_t getTCTEdgeNum() const
Definition: TCT.h:253
ThreadCreateEdgeSet::iterator TCTNodeIter
Definition: TCT.h:159
void dump(const std::string &filename)
Dump the graph.
Definition: TCT.cpp:513
SCCDetection< PTACallGraph * > ThreadCallGraphSCC
Definition: TCT.h:170
FunSet candidateFuncSet
Procedures that are neither called by other functions nor extern functions.
Definition: TCT.h:589
bool hasLoop(const SVFBasicBlock *bb) const
Definition: TCT.h:400
TCTEdge * getGraphEdge(TCTNode *src, TCTNode *dst, TCTEdge::CEDGEK kind)
Get call graph edge via nodes.
Definition: TCT.cpp:551
TCTNode * getTCTNode(NodeID id) const
Get TCT node.
Definition: TCT.h:206
TCTEdge::ThreadCreateEdgeSet ThreadCreateEdgeSet
Definition: TCT.h:158
CxtThreadProcVec ctpList
Thread call graph SCC.
Definition: TCT.h:591
std::vector< const ICFGNode * > InstVec
Definition: TCT.h:161
u32_t TCTEdgeNum
Definition: TCT.h:446
bool isInLoopInstruction(const ICFGNode *inst)
Multi-forked threads.
Definition: TCT.cpp:45
bool isJoinMustExecutedInLoop(const LoopBBs &lp, const ICFGNode *join)
Return true if a join instruction must be executed inside a loop.
Definition: TCT.cpp:290
void markRelProcs()
Mark relevant procedures that are backward reachable from any fork/join site.
Definition: TCT.cpp:132
Set< const ICFGNode * > inRecurJoinSites
Fork or Join sites in recursions.
Definition: TCT.h:597
TCT(PointerAnalysis *p)
Constructor.
Definition: TCT.h:173
void handleCallRelation(CxtThreadProc &ctp, const PTACallGraphEdge *cgEdge, const CallICFGNode *call)
Handle call relations.
Definition: TCT.cpp:244
bool inSameCallGraphSCC(const PTACallGraphNode *src, const PTACallGraphNode *dst)
Whether two functions in the same callgraph scc.
Definition: TCT.h:306
PointerAnalysis * pta
Definition: TCT.h:444
void destroy()
Clean up memory.
Definition: TCT.h:581
bool matchCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Match context.
Definition: TCT.cpp:465
bool isCandidateFun(const PTACallGraph::FunctionSet &callees) const
Whether it is a candidate function for indirect call.
Definition: TCT.h:291
void dumpCxt(CallStrCxt &cxt)
Dump calling context.
Definition: TCT.cpp:495
bool addTCTEdge(TCTNode *src, TCTNode *dst)
Add TCT edge.
Definition: TCT.h:461
void pushCxt(CallStrCxt &cxt, CallSiteID csId)
Definition: TCT.h:421
u32_t MaxCxtSize
Definition: TCT.h:447
SVFModule * getSVFModule() const
Get SVFFModule.
Definition: TCT.h:190
TCTNode * getTCTNode(const CxtThread &ct) const
Definition: TCT.h:282
const CallStrCxt & getCxtOfCxtThread(const CxtThread &ct) const
get the context of a thread at its spawning site (fork site)
Definition: TCT.h:369
bool isLoopHeaderOfJoinLoop(const SVFBasicBlock *bb)
Whether a given bb is a loop head of a inloop join site.
Definition: TCT.cpp:339
void build()
Build TCT.
Definition: TCT.cpp:383
void print() const
Print TCT information.
Definition: TCT.cpp:522
ThreadCallGraph * tcg
Definition: TCT.h:443
Map< const ICFGNode *, LoopBBs > InstToLoopMap
Definition: TCT.h:167
void collectMultiForkedThreads()
Definition: TCT.cpp:206
CxtThreadProc popFromCTPWorkList()
Definition: TCT.h:570
TCTEdge * hasGraphEdge(TCTNode *src, TCTNode *dst, TCTEdge::CEDGEK kind) const
Whether we have already created this call graph edge.
Definition: TCT.cpp:534
const SVFFunction * getStartRoutineOfCxtThread(const CxtThread &ct) const
get the start routine function of a thread
Definition: TCT.h:377
bool isLoopExitOfJoinLoop(const SVFBasicBlock *bb)
Whether a given bb is an exit of a inloop join site.
Definition: TCT.cpp:353
CxtThreadToForkCxt ctToForkCxtMap
Map a ctp to its graph node.
Definition: TCT.h:594
SVFLoopAndDomInfo::LoopBBs LoopBBs
Definition: TCT.h:157
const NodeBS getAncestorThread(NodeID tid) const
Get all ancestor threads.
Definition: TCT.h:329
bool isExtCall(const ICFGNode *inst)
Whether it is calling an external function.
Definition: TCT.h:264
virtual ~TCT()
Destructor.
Definition: TCT.h:184
u32_t getTCTNodeNum() const
Get Statistics.
Definition: TCT.h:249
ThreadCreateEdgeSet::const_iterator getChildrenEnd(const TCTNode *node) const
Definition: TCT.h:221
ThreadCreateEdgeSet::const_iterator getParentsBegin(const TCTNode *node) const
Definition: TCT.h:225
Set< const PTACallGraphNode * > PTACGNodeSet
Definition: TCT.h:163
Map< CxtThread, TCTNode * > CxtThreadToNodeMap
Definition: TCT.h:164
bool isTDJoin(const CallICFGNode *inst) const
Return true if this call wait for a worker thread.
Definition: ThreadAPI.cpp:138
ThreadAPI * getThreadAPI() const
Thread API.
void updateCallGraph(PointerAnalysis *pta)
Update call graph using pointer results.
bool isExtCall(const SVFFunction *fun)
Definition: SVFUtil.h:278
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50
for isBitcode
Definition: BasicTypes.h:68
unsigned CallSiteID
Definition: GeneralType.h:58
GenericEdge< TCTNode > GenericTCTEdgeTy
Definition: TCT.h:43
GenericNode< TCTNode, TCTEdge > GenericTCTNodeTy
Definition: TCT.h:84
u32_t NodeID
Definition: GeneralType.h:55
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: GeneralType.h:101
GenericGraph< TCTNode, TCTEdge > GenericThreadCreateTreeTy
Definition: TCT.h:152
std::vector< u32_t > CallStrCxt
Definition: GeneralType.h:122
unsigned u32_t
Definition: GeneralType.h:46
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96