Static Value-Flow Analysis
MHP.h
Go to the documentation of this file.
1 //===- MHP.h -- May-happen-in-parallel analysis-------------//
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  * MHP.h
25  *
26  * Created on: Jan 21, 2014
27  * Author: Yulei Sui, Peng Di
28  */
29 
30 #ifndef MHP_H_
31 #define MHP_H_
32 
33 #include "MTA/TCT.h"
34 #include "Util/SVFUtil.h"
35 namespace SVF
36 {
37 
38 class ForkJoinAnalysis;
39 class LockAnalysis;
40 
45 class MHP
46 {
47 
48 public:
55 
57 
58  typedef std::pair<const SVFFunction*,const SVFFunction*> FuncPair;
60 
62  MHP(TCT* t);
63 
65  virtual ~MHP();
66 
68  void analyze();
69 
71  void analyzeInterleaving();
72 
75  {
76  return tcg;
77  }
78 
80  inline TCT* getTCT() const
81  {
82  return tct;
83  }
84 
86  bool isConnectedfromMain(const SVFFunction* fun);
87 
88 // LockSpan getSpanfromCxtLock(NodeID l);
90  virtual bool mayHappenInParallel(const ICFGNode* i1, const ICFGNode* i2);
91  virtual bool mayHappenInParallelCache(const ICFGNode* i1, const ICFGNode* i2);
92  virtual bool mayHappenInParallelInst(const ICFGNode* i1, const ICFGNode* i2);
93  virtual bool executedByTheSameThread(const ICFGNode* i1, const ICFGNode* i2);
94 
96 
97  inline const NodeBS& getInterleavingThreads(const CxtThreadStmt& cts)
98  {
99  return threadStmtToTheadInterLeav[cts];
100  }
101  inline bool hasInterleavingThreads(const CxtThreadStmt& cts) const
102  {
104  }
106 
108 
109  inline const CxtThreadStmtSet& getThreadStmtSet(const ICFGNode* inst) const
110  {
111  InstToThreadStmtSetMap::const_iterator it = instToTSMap.find(inst);
112  assert(it!=instToTSMap.end() && "no thread access the instruction?");
113  return it->second;
114  }
115  inline bool hasThreadStmtSet(const ICFGNode* inst) const
116  {
117  return instToTSMap.find(inst)!=instToTSMap.end();
118  }
120 
122  void printInterleaving();
123 
124 private:
125 
127  {
128  tcg->getCallees(inst, callees);
129  return callees;
130  }
134 
136  void handleNonCandidateFun(const CxtThreadStmt& cts);
137 
139  void handleFork(const CxtThreadStmt& cts, NodeID rootTid);
140 
142  void handleJoin(const CxtThreadStmt& cts, NodeID rootTid);
143 
145  void handleCall(const CxtThreadStmt& cts, NodeID rootTid);
146 
148  void handleRet(const CxtThreadStmt& cts);
149 
151  void handleIntra(const CxtThreadStmt& cts);
152 
154 
155  inline void addInterleavingThread(const CxtThreadStmt& tgr, NodeID tid)
156  {
157  if(threadStmtToTheadInterLeav[tgr].test_and_set(tid))
158  {
159  instToTSMap[tgr.getStmt()].insert(tgr);
160  pushToCTSWorkList(tgr);
161  }
162  }
163  inline void addInterleavingThread(const CxtThreadStmt& tgr, const CxtThreadStmt& src)
164  {
165  bool changed = threadStmtToTheadInterLeav[tgr] |= threadStmtToTheadInterLeav[src];
166  if(changed)
167  {
168  instToTSMap[tgr.getStmt()].insert(tgr);
169  pushToCTSWorkList(tgr);
170  }
171  }
172  inline void rmInterleavingThread(const CxtThreadStmt& tgr, const NodeBS& tids, const ICFGNode* joinsite)
173  {
174  NodeBS joinedTids;
175  for(NodeBS::iterator it = tids.begin(), eit = tids.end(); it!=eit; ++it)
176  {
177  if(isMustJoin(tgr.getTid(),joinsite))
178  joinedTids.set(*it);
179  }
180  if(threadStmtToTheadInterLeav[tgr].intersectWithComplement(joinedTids))
181  {
182  pushToCTSWorkList(tgr);
183  }
184  }
186 
188 
189  void updateAncestorThreads(NodeID tid);
190  void updateSiblingThreads(NodeID tid);
192 
194  bool isRecurFullJoin(NodeID parentTid, NodeID curTid);
195 
197  bool isMustJoin(const NodeID curTid, const ICFGNode* joinsite);
198 
200  inline bool isMultiForkedThread(NodeID curTid)
201  {
202  return tct->getTCTNode(curTid)->isMultiforked();
203  }
205  inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
206  {
207  tct->pushCxt(cxt,call,callee);
208  }
210  inline bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
211  {
212  return tct->matchCxt(cxt,call,callee);
213  }
214 
216 
217  inline bool pushToCTSWorkList(const CxtThreadStmt& cs)
218  {
219  return cxtStmtList.push(cs);
220  }
222  {
223  CxtThreadStmt ctp = cxtStmtList.pop();
224  return ctp;
225  }
226 
228  inline bool isTDFork(const ICFGNode* call)
229  {
230  const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
231  return fork && tcg->getThreadAPI()->isTDFork(fork);
232  }
234  inline bool isTDJoin(const ICFGNode* call)
235  {
236  const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
237  return join && tcg->getThreadAPI()->isTDJoin(join);
238  }
239 
241  NodeBS getDirAndIndJoinedTid(const CallStrCxt& cxt, const ICFGNode* call);
242 
244  bool hasJoinInSymmetricLoop(const CallStrCxt& cxt, const ICFGNode* call) const;
245 
247  const LoopBBs& getJoinInSymmetricLoop(const CallStrCxt& cxt, const ICFGNode* call) const;
248 
250  bool isHBPair(NodeID tid1, NodeID tid2);
251 
253  TCT* tct;
259 
260 
261 public:
266 };
267 
268 
269 
274 {
275 
276 public:
279  {
280  Empty, // initial(dummy) state
281  TDAlive, // thread is alive
282  TDDead, // thread is dead
283  };
284 
292 
294  {
295  collectSCEVInfo();
296  }
298  void collectSCEVInfo();
299 
303  void analyzeForkJoinPair();
304 
307  {
308  return directJoinMap[cs];
309  }
312 
314  inline const LoopBBs& getJoinInSymmetricLoop(const CxtStmt& cs) const
315  {
316  CxtStmtToLoopMap::const_iterator it = cxtJoinInLoop.find(cs);
317  assert(it!=cxtJoinInLoop.end() && "does not have the loop");
318  return it->second;
319  }
320  inline bool hasJoinInSymmetricLoop(const CxtStmt& cs) const
321  {
322  CxtStmtToLoopMap::const_iterator it = cxtJoinInLoop.find(cs);
323  return it!=cxtJoinInLoop.end();
324  }
326  inline bool isHBPair(NodeID tid1, NodeID tid2)
327  {
328  bool nonhp = HBPair.find(std::make_pair(tid1,tid2))!=HBPair.end();
329  bool hp = HPPair.find(std::make_pair(tid1,tid2))!=HPPair.end();
330  return nonhp && !hp;
331  }
333  inline bool isFullJoin(NodeID tid1, NodeID tid2)
334  {
335  bool full = fullJoin.find(std::make_pair(tid1,tid2))!=fullJoin.end();
336  bool partial = partialJoin.find(std::make_pair(tid1,tid2))!=partialJoin.end();
337  return full && !partial;
338  }
339 
342  {
343  NodeID parentTid = tct->getParentThread(tid);
344  const CxtThread& parentct = tct->getTCTNode(parentTid)->getCxtThread();
345  const SVFFunction* parentRoutine = tct->getStartRoutineOfCxtThread(parentct);
346  return parentRoutine->getExitBB()->back();
347  }
348 
350  inline LoopBBs& getJoinLoop(const CallICFGNode* inst)
351  {
352  return tct->getJoinLoop(inst);
353  }
354  inline bool hasJoinLoop(const CallICFGNode* inst)
355  {
356  return tct->hasJoinLoop(inst);
357  }
358 private:
359 
361  void handleFork(const CxtStmt& cts,NodeID rootTid);
362 
364  void handleJoin(const CxtStmt& cts,NodeID rootTid);
365 
367  void handleCall(const CxtStmt& cts,NodeID rootTid);
368 
370  void handleRet(const CxtStmt& cts);
371 
373  void handleIntra(const CxtStmt& cts);
374 
376  bool isSameSCEV(const ICFGNode* forkSite, const ICFGNode* joinSite);
377 
379  bool sameLoopTripCount(const ICFGNode* forkSite, const ICFGNode* joinSite);
380 
382  bool isAliasedForkJoin(const CallICFGNode* forkSite, const CallICFGNode* joinSite)
383  {
384  return tct->getPTA()->alias(getForkedThread(forkSite)->getId(), getJoinedThread(joinSite)->getId()) && isSameSCEV(forkSite,joinSite);
385  }
387 
388  inline ValDomain getMarkedFlag(const CxtStmt& cs)
390  {
391  CxtStmtToAliveFlagMap::const_iterator it = cxtStmtToAliveFlagMap.find(cs);
392  if(it==cxtStmtToAliveFlagMap.end())
393  {
395  return Empty;
396  }
397  else
398  return it->second;
399  }
401  void markCxtStmtFlag(const CxtStmt& tgr, ValDomain flag)
402  {
403  ValDomain flag_tgr = getMarkedFlag(tgr);
404  cxtStmtToAliveFlagMap[tgr] = flag;
405  if(flag_tgr!=getMarkedFlag(tgr))
406  pushToCTSWorkList(tgr);
407  }
409  void markCxtStmtFlag(const CxtStmt& tgr, const CxtStmt& src)
410  {
411  ValDomain flag_tgr = getMarkedFlag(tgr);
412  ValDomain flag_src = getMarkedFlag(src);
413  if(flag_tgr == Empty)
414  {
415  cxtStmtToAliveFlagMap[tgr] = flag_src;
416  }
417  else if(flag_tgr == TDDead)
418  {
419  if(flag_src==TDAlive)
421  }
422  else
423  {
425  }
426  if(flag_tgr!=getMarkedFlag(tgr))
427  {
428  pushToCTSWorkList(tgr);
429  }
430  }
432  inline void clearFlagMap()
433  {
434  cxtStmtToAliveFlagMap.clear();
435  cxtStmtList.clear();
436  }
438 
440 
441  inline bool pushToCTSWorkList(const CxtStmt& cs)
442  {
443  return cxtStmtList.push(cs);
444  }
446  {
447  CxtStmt ctp = cxtStmtList.pop();
448  return ctp;
449  }
451 
453  inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
454  {
455  tct->pushCxt(cxt,call,callee);
456  }
458  inline bool matchCxt(CallStrCxt& cxt, const CallICFGNode* call, const SVFFunction* callee)
459  {
460  return tct->matchCxt(cxt,call,callee);
461  }
462 
464  inline bool isTDFork(const ICFGNode* call)
465  {
466  const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
467  return fork && getTCG()->getThreadAPI()->isTDFork(fork);
468  }
470  inline bool isTDJoin(const ICFGNode* call)
471  {
472  const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
473  return join && getTCG()->getThreadAPI()->isTDJoin(join);
474  }
476  inline const SVFVar* getForkedThread(const CallICFGNode* call)
477  {
478  return getTCG()->getThreadAPI()->getForkedThread(call);
479  }
481  inline const SVFVar* getJoinedThread(const CallICFGNode* call)
482  {
483  return getTCG()->getThreadAPI()->getJoinedThread(call);
484  }
486  {
487  getTCG()->getCallees(SVFUtil::cast<CallICFGNode>(inst), callees);
488  return callees;
489  }
491  inline ThreadCallGraph* getTCG() const
492  {
493  return tct->getThreadCallGraph();
494  }
496  inline void addDirectlyJoinTID(const CxtStmt& cs, NodeID tid)
497  {
498  directJoinMap[cs].set(tid);
499  }
500 
503 
504  inline void addToHPPair(NodeID tid1, NodeID tid2)
505  {
506  HPPair.insert(std::make_pair(tid1,tid2));
507  HPPair.insert(std::make_pair(tid2,tid1));
508  }
509  inline void addToHBPair(NodeID tid1, NodeID tid2)
510  {
511  HBPair.insert(std::make_pair(tid1,tid2));
512  }
514 
516 
517  inline void addToFullJoin(NodeID tid1, NodeID tid2)
518  {
519  fullJoin.insert(std::make_pair(tid1,tid2));
520  }
521  inline void addToPartial(NodeID tid1, NodeID tid2)
522  {
523  partialJoin.insert(std::make_pair(tid1,tid2));
524  }
526 
528  inline void addSymmetricLoopJoin(const CxtStmt& cs, LoopBBs& lp)
529  {
530  cxtJoinInLoop[cs] = lp;
531  }
542 };
543 
544 } // End namespace SVF
545 
546 #endif /* MHP_H_ */
const ICFGNode * getStmt() const
Return current statement.
Definition: CxtStmt.h:63
NodeID getTid() const
Return current context.
Definition: CxtStmt.h:140
bool push(const Data &data)
Definition: WorkList.h:165
void addToFullJoin(NodeID tid1, NodeID tid2)
full join and partial join
Definition: MHP.h:517
void markCxtStmtFlag(const CxtStmt &tgr, const CxtStmt &src)
Transfer function for marking context-sensitive statement.
Definition: MHP.h:409
Map< CxtStmt, LoopBBs > CxtStmtToLoopMap
Definition: MHP.h:290
FIFOWorkList< CxtStmt > CxtStmtWorkList
Definition: MHP.h:291
ValDomain getMarkedFlag(const CxtStmt &cs)
Mark thread flags for cxtStmt.
Definition: MHP.h:389
void addToHPPair(NodeID tid1, NodeID tid2)
Definition: MHP.h:504
SVFLoopAndDomInfo::LoopBBs LoopBBs
Definition: MHP.h:285
void analyzeForkJoinPair()
Definition: MHP.cpp:721
const SVFVar * getJoinedThread(const CallICFGNode *call)
Get joined thread.
Definition: MHP.h:481
const SVFVar * getForkedThread(const CallICFGNode *call)
Get forked thread.
Definition: MHP.h:476
bool hasJoinLoop(const CallICFGNode *inst)
Definition: MHP.h:354
void addSymmetricLoopJoin(const CxtStmt &cs, LoopBBs &lp)
Add inloop join.
Definition: MHP.h:528
void handleRet(const CxtStmt &cts)
Handle return.
Definition: MHP.cpp:902
NodeBS getDirAndIndJoinedTid(const CxtStmt &cs)
Get directly and indirectly joined threadIDs based on a context-sensitive join site.
Definition: MHP.cpp:974
ThreadPairSet partialJoin
t1 partially joins t2 along some program path(s)
Definition: MHP.h:541
bool matchCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Match context.
Definition: MHP.h:458
ThreadPairSet fullJoin
t1 fully joins t2 along all program path
Definition: MHP.h:540
ForkJoinAnalysis(TCT *t)
Definition: MHP.h:293
LoopBBs & getJoinLoop(const CallICFGNode *inst)
Get loop for join site.
Definition: MHP.h:350
ThreadPairSet HPPair
threads happen-in-parallel
Definition: MHP.h:539
CxtStmt popFromCTSWorkList()
Definition: MHP.h:445
TCT::InstVec InstVec
Definition: MHP.h:286
CxtStmtToLoopMap cxtJoinInLoop
a set of context-sensitive join inside loop
Definition: MHP.h:537
void addToHBPair(NodeID tid1, NodeID tid2)
Definition: MHP.h:509
const ICFGNode * getExitInstOfParentRoutineFun(NodeID tid) const
Get exit instruction of the start routine function of tid's parent thread.
Definition: MHP.h:341
void addToPartial(NodeID tid1, NodeID tid2)
Definition: MHP.h:521
void collectSCEVInfo()
functions
Definition: MHP.cpp:667
void clearFlagMap()
Clear flags.
Definition: MHP.h:432
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Push calling context.
Definition: MHP.h:453
bool pushToCTSWorkList(const CxtStmt &cs)
Worklist operations.
Definition: MHP.h:441
Set< NodePair > ThreadPairSet
Definition: MHP.h:289
NodeBS & getDirectlyJoinedTid(const CxtStmt &cs)
Get directly joined threadIDs based on a context-sensitive join site.
Definition: MHP.h:306
bool isHBPair(NodeID tid1, NodeID tid2)
Whether thread t1 happens-before thread t2.
Definition: MHP.h:326
void addDirectlyJoinTID(const CxtStmt &cs, NodeID tid)
maps a context-sensitive join site to a thread id
Definition: MHP.h:496
ThreadCallGraph * getTCG() const
ThreadCallGraph.
Definition: MHP.h:491
const LoopBBs & getJoinInSymmetricLoop(const CxtStmt &cs) const
Whether a context-sensitive join satisfies symmetric loop pattern.
Definition: MHP.h:314
ValDomain
semilattice Empty==>TDDead==>TDAlive
Definition: MHP.h:279
Map< CxtStmt, NodeBS > CxtStmtToTIDMap
Definition: MHP.h:288
CxtStmtToAliveFlagMap cxtStmtToAliveFlagMap
flags for context-sensitive statements
Definition: MHP.h:533
bool isTDFork(const ICFGNode *call)
Whether it is a fork site.
Definition: MHP.h:464
ThreadPairSet HBPair
thread happens-before pair
Definition: MHP.h:538
bool isFullJoin(NodeID tid1, NodeID tid2)
Whether t1 fully joins t2.
Definition: MHP.h:333
CxtStmtToTIDMap dirAndIndJoinMap
maps a context-sensitive join site to directly and indirectly joined thread ids
Definition: MHP.h:536
void handleCall(const CxtStmt &cts, NodeID rootTid)
Handle call.
Definition: MHP.cpp:877
bool hasJoinInSymmetricLoop(const CxtStmt &cs) const
Definition: MHP.h:320
CxtStmtToTIDMap directJoinMap
maps a context-sensitive join site to directly joined thread ids
Definition: MHP.h:535
bool sameLoopTripCount(const ICFGNode *forkSite, const ICFGNode *joinSite)
Same loop trip count.
Definition: MHP.cpp:1073
bool isTDJoin(const ICFGNode *call)
Whether it is a join site.
Definition: MHP.h:470
void markCxtStmtFlag(const CxtStmt &tgr, ValDomain flag)
Initialize TDAlive and TDDead flags.
Definition: MHP.h:401
CxtStmtWorkList cxtStmtList
context-sensitive statement worklist
Definition: MHP.h:534
Map< CxtStmt, ValDomain > CxtStmtToAliveFlagMap
Definition: MHP.h:287
bool isAliasedForkJoin(const CallICFGNode *forkSite, const CallICFGNode *joinSite)
Whether it is a matched fork join pair.
Definition: MHP.h:382
void handleIntra(const CxtStmt &cts)
Handle intra.
Definition: MHP.cpp:953
void handleFork(const CxtStmt &cts, NodeID rootTid)
Handle fork.
Definition: MHP.cpp:785
const PTACallGraph::FunctionSet & getCallee(const ICFGNode *inst, PTACallGraph::FunctionSet &callees)
Definition: MHP.h:485
void handleJoin(const CxtStmt &cts, NodeID rootTid)
Handle join.
Definition: MHP.cpp:812
bool isSameSCEV(const ICFGNode *forkSite, const ICFGNode *joinSite)
Return true if the fork and join have the same SCEV.
Definition: MHP.cpp:1049
Definition: MHP.h:46
void analyze()
Start analysis here.
Definition: MHP.cpp:62
CxtThreadStmtWorkList cxtStmtList
CxtThreadStmt worklist.
Definition: MHP.h:255
TCT * getTCT() const
Get Thread Creation Tree.
Definition: MHP.h:80
bool isRecurFullJoin(NodeID parentTid, NodeID curTid)
Thread curTid can be fully joined by parentTid recursively.
Definition: MHP.cpp:446
bool isMultiForkedThread(NodeID curTid)
A thread is a multiForked thread if it is in a loop or recursion.
Definition: MHP.h:200
Set< CxtStmt > LockSpan
Definition: MHP.h:56
void rmInterleavingThread(const CxtThreadStmt &tgr, const NodeBS &tids, const ICFGNode *joinsite)
Definition: MHP.h:172
virtual bool mayHappenInParallelCache(const ICFGNode *i1, const ICFGNode *i2)
Definition: MHP.cpp:592
TCT * tct
TCT.
Definition: MHP.h:253
FuncPairToBool nonCandidateFuncMHPRelMap
Definition: MHP.h:258
ThreadCallGraph * getThreadCallGraph() const
Get ThreadCallGraph.
Definition: MHP.h:74
void printInterleaving()
Print interleaving results.
Definition: MHP.cpp:647
void updateSiblingThreads(NodeID tid)
Definition: MHP.cpp:418
const CxtThreadStmtSet & getThreadStmtSet(const ICFGNode *inst) const
Get/has ThreadStmt.
Definition: MHP.h:109
u32_t numOfTotalQueries
Total number of queries.
Definition: MHP.h:262
Set< CxtThreadStmt > CxtThreadStmtSet
Definition: MHP.h:51
void handleNonCandidateFun(const CxtThreadStmt &cts)
Handle non-candidate function.
Definition: MHP.cpp:181
SVFLoopAndDomInfo::LoopBBs LoopBBs
Definition: MHP.h:54
void handleJoin(const CxtThreadStmt &cts, NodeID rootTid)
Handle join.
Definition: MHP.cpp:233
bool hasInterleavingThreads(const CxtThreadStmt &cts) const
Definition: MHP.h:101
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Push calling context.
Definition: MHP.h:205
ThreadCallGraph * tcg
TCG.
Definition: MHP.h:252
void addInterleavingThread(const CxtThreadStmt &tgr, NodeID tid)
Add/Remove interleaving thread for statement inst.
Definition: MHP.h:155
const NodeBS & getInterleavingThreads(const CxtThreadStmt &cts)
Get interleaving thread for statement inst.
Definition: MHP.h:97
InstToThreadStmtSetMap instToTSMap
Map a statement to its thread interleavings.
Definition: MHP.h:257
virtual ~MHP()
Destructor.
Definition: MHP.cpp:54
void addInterleavingThread(const CxtThreadStmt &tgr, const CxtThreadStmt &src)
Definition: MHP.h:163
bool isHBPair(NodeID tid1, NodeID tid2)
Whether thread t1 happens before t2 based on ForkJoin Analysis.
Definition: MHP.cpp:516
bool isTDFork(const ICFGNode *call)
Whether it is a fork site.
Definition: MHP.h:228
void handleRet(const CxtThreadStmt &cts)
Handle return.
Definition: MHP.cpp:319
virtual bool executedByTheSameThread(const ICFGNode *i1, const ICFGNode *i2)
Definition: MHP.cpp:626
bool matchCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Match context.
Definition: MHP.h:210
virtual bool mayHappenInParallel(const ICFGNode *i1, const ICFGNode *i2)
Interface to query whether two instructions may happen-in-parallel.
Definition: MHP.cpp:614
void handleFork(const CxtThreadStmt &cts, NodeID rootTid)
Handle fork.
Definition: MHP.cpp:203
const LoopBBs & getJoinInSymmetricLoop(const CallStrCxt &cxt, const ICFGNode *call) const
Whether a context-sensitive join satisfies symmetric loop pattern.
Definition: MHP.cpp:507
Set< const SVFFunction * > FunSet
Definition: MHP.h:49
bool isConnectedfromMain(const SVFFunction *fun)
Whether the function is connected from main function in thread call graph.
Definition: MHP.cpp:521
Map< const ICFGNode *, CxtThreadStmtSet > InstToThreadStmtSetMap
Definition: MHP.h:53
ForkJoinAnalysis * fja
ForJoin Analysis.
Definition: MHP.h:254
bool hasJoinInSymmetricLoop(const CallStrCxt &cxt, const ICFGNode *call) const
Whether a context-sensitive join satisfies symmetric loop pattern.
Definition: MHP.cpp:500
bool hasThreadStmtSet(const ICFGNode *inst) const
Definition: MHP.h:115
double interleavingQueriesTime
Definition: MHP.h:265
u32_t numOfMHPQueries
Number of queries are answered as may-happen-in-parallel.
Definition: MHP.h:263
void updateNonCandidateFunInterleaving()
Definition: MHP.cpp:144
MHP(TCT *t)
Constructor.
Definition: MHP.cpp:44
Map< CxtThreadStmt, NodeBS > ThreadStmtToThreadInterleav
Definition: MHP.h:52
bool isMustJoin(const NodeID curTid, const ICFGNode *joinsite)
Whether a join site must join a thread t.
Definition: MHP.cpp:481
double interleavingTime
Definition: MHP.h:264
std::pair< const SVFFunction *, const SVFFunction * > FuncPair
Definition: MHP.h:58
CxtThreadStmt popFromCTSWorkList()
Definition: MHP.h:221
void analyzeInterleaving()
Analyze thread interleaving.
Definition: MHP.cpp:75
Map< FuncPair, bool > FuncPairToBool
Definition: MHP.h:59
NodeBS getDirAndIndJoinedTid(const CallStrCxt &cxt, const ICFGNode *call)
Return thread id(s) which are directly or indirectly joined at this join site.
Definition: MHP.cpp:491
void updateAncestorThreads(NodeID tid)
Update Ancestor and sibling threads.
Definition: MHP.cpp:382
virtual bool mayHappenInParallelInst(const ICFGNode *i1, const ICFGNode *i2)
Definition: MHP.cpp:556
FIFOWorkList< CxtThreadStmt > CxtThreadStmtWorkList
Definition: MHP.h:50
bool pushToCTSWorkList(const CxtThreadStmt &cs)
WorkList helper functions.
Definition: MHP.h:217
void handleIntra(const CxtThreadStmt &cts)
Handle intra.
Definition: MHP.cpp:366
void handleCall(const CxtThreadStmt &cts, NodeID rootTid)
Handle call.
Definition: MHP.cpp:290
ThreadStmtToThreadInterleav threadStmtToTheadInterLeav
Definition: MHP.h:256
bool isTDJoin(const ICFGNode *call)
Whether it is a join site.
Definition: MHP.h:234
const PTACallGraph::FunctionSet & getCallee(const CallICFGNode *inst, PTACallGraph::FunctionSet &callees)
Definition: MHP.h:126
void getCallees(const CallICFGNode *cs, FunctionSet &callees)
Get all callees for a callsite.
Definition: PTACallGraph.h:408
Set< const SVFFunction * > FunctionSet
Definition: PTACallGraph.h:251
virtual AliasResult alias(const SVFValue *V1, const SVFValue *V2)=0
Interface exposed to users of our pointer analysis, given Value infos.
const ICFGNode * back() const
Definition: SVFValue.h:600
const SVFBasicBlock * getExitBB() const
Definition: SVFValue.cpp:186
iterator end() const
void set(unsigned Idx)
iterator begin() const
const CxtThread & getCxtThread() const
Get CxtThread.
Definition: TCT.h:101
bool isMultiforked() const
Definition: TCT.h:120
Definition: TCT.h:154
ThreadCallGraph * getThreadCallGraph() const
Get TCG.
Definition: TCT.h:196
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Push calling context.
Definition: TCT.cpp:444
bool hasJoinLoop(const CallICFGNode *join) const
Definition: TCT.h:393
NodeID getParentThread(NodeID tid) const
Get parent thread.
Definition: TCT.h:320
PointerAnalysis * getPTA() const
Get PTA.
Definition: TCT.h:201
LoopBBs & getJoinLoop(const CallICFGNode *join)
Get loop for join site.
Definition: TCT.h:385
TCTNode * getTCTNode(NodeID id) const
Get TCT node.
Definition: TCT.h:206
std::vector< const ICFGNode * > InstVec
Definition: TCT.h:161
bool matchCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Match context.
Definition: TCT.cpp:465
const SVFFunction * getStartRoutineOfCxtThread(const CxtThread &ct) const
get the start routine function of a thread
Definition: TCT.h:377
bool isTDFork(const CallICFGNode *inst) const
Return true if this call create a new thread.
Definition: ThreadAPI.cpp:133
bool isTDJoin(const CallICFGNode *inst) const
Return true if this call wait for a worker thread.
Definition: ThreadAPI.cpp:138
const SVFVar * getJoinedThread(const CallICFGNode *inst) const
Return arguments/attributes of pthread_join.
Definition: ThreadAPI.cpp:207
const SVFVar * getForkedThread(const CallICFGNode *inst) const
Return arguments/attributes of pthread_create / hare_parallel_for.
Definition: ThreadAPI.cpp:164
ThreadAPI * getThreadAPI() const
Thread API.
for isBitcode
Definition: BasicTypes.h:68
u32_t NodeID
Definition: GeneralType.h:55
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: GeneralType.h:101
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