Static Value-Flow Analysis
Loading...
Searching...
No Matches
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 * May-happen-in-parallel analysis. One implementation runs on the whole program
30 * or a slice: analyze() is templated on the ICFG and CallGraph it traverses
31 * (whole graphs or their sliced views), as used by "Multi-Stage On-Demand Program Slicing for
32 * Modular Analysis of Multi-Threaded Programs" (ISSTA 2026).
33 */
34
35#ifndef MHP_H_
36#define MHP_H_
37
38#include "MTA/TCT.h"
39#include "Util/SVFUtil.h"
40
41#include <memory>
42#include <vector>
43
44namespace SVF
45{
46
47class ForkJoinAnalysis;
48class LockAnalysis;
49// Forward declaration for the sliced-graph handle analyze() can run on.
50class SlicedSVFIRView;
51
56class MHP
57{
58
59public:
66
68
69 typedef std::pair<const FunObjVar*,const FunObjVar*> FuncPair;
71
73 MHP(TCT* t);
74
76 virtual ~MHP();
77
83 template<class ICFGGraph, class CGGraph> void analyze(ICFGGraph icfg, CGGraph cg);
84
86 template<class ICFGGraph, class CGGraph> void analyzeInterleaving(ICFGGraph icfg, CGGraph cg);
87
90 {
91 return tcg;
92 }
93
95 inline TCT* getTCT() const
96 {
97 return tct;
98 }
99
101 bool isConnectedfromMain(const FunObjVar* fun);
102
103// LockSpan getSpanfromCxtLock(NodeID l);
105 virtual bool mayHappenInParallel(const ICFGNode* i1, const ICFGNode* i2);
106 virtual bool mayHappenInParallelCache(const ICFGNode* i1, const ICFGNode* i2);
107 virtual bool mayHappenInParallelInst(const ICFGNode* i1, const ICFGNode* i2);
108 virtual bool executedByTheSameThread(const ICFGNode* i1, const ICFGNode* i2);
109
111
113 {
115 }
116 inline bool hasInterleavingThreads(const CxtThreadStmt& cts) const
117 {
119 }
121
123
124 inline const CxtThreadStmtSet& getThreadStmtSet(const ICFGNode* inst) const
125 {
126 InstToThreadStmtSetMap::const_iterator it = instToTSMap.find(inst);
127 assert(it!=instToTSMap.end() && "no thread access the instruction?");
128 return it->second;
129 }
130 inline bool hasThreadStmtSet(const ICFGNode* inst) const
131 {
132 return instToTSMap.find(inst)!=instToTSMap.end();
133 }
135
137 void printInterleaving();
138
139protected:
140
142 {
143 tcg->getCallees(inst, callees);
144 return callees;
145 }
148 template<class ICFGGraph, class CGGraph> void updateNonCandidateFunInterleaving(ICFGGraph icfg, CGGraph cg);
149
151 template<class ICFGGraph, class CGGraph> void handleNonCandidateFun(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts);
152
154 template<class ICFGGraph, class CGGraph> void handleFork(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts, NodeID rootTid);
155
157 template<class ICFGGraph, class CGGraph> void handleJoin(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts, NodeID rootTid);
158
160 template<class ICFGGraph, class CGGraph> void handleCall(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts, NodeID rootTid);
161
163 template<class ICFGGraph, class CGGraph> void handleRet(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts);
164
166 template<class ICFGGraph, class CGGraph> void handleIntra(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts);
167
170
174 NodeBS edgeFlow(const CxtThreadStmt& cts, const ICFGNode* dst);
176
178
180 {
181 if(threadStmtToThreadInterLeav[tgr].test_and_set(tid))
182 {
183 instToTSMap[tgr.getStmt()].insert(tgr);
185 }
186 }
187 inline void addInterleavingThread(const CxtThreadStmt& tgr, const CxtThreadStmt& src)
188 {
190 if(changed)
191 {
192 instToTSMap[tgr.getStmt()].insert(tgr);
194 }
195 }
196 inline void addInterleavingBits(const CxtThreadStmt& tgr, const NodeBS& bits)
197 {
199 if(changed)
200 {
201 instToTSMap[tgr.getStmt()].insert(tgr);
203 }
204 }
206 {
208 for(NodeBS::iterator it = tids.begin(), eit = tids.end(); it!=eit; ++it)
209 {
210 if(isMustJoin(tgr.getTid(),joinsite))
211 joinedTids.set(*it);
212 }
213 if(threadStmtToThreadInterLeav[tgr].intersectWithComplement(joinedTids))
214 {
216 }
217 }
219
221
222 template<class ICFGGraph, class CGGraph> void updateAncestorThreads(ICFGGraph icfg, CGGraph cg, NodeID tid);
223 template<class ICFGGraph, class CGGraph> void updateSiblingThreads(ICFGGraph icfg, CGGraph cg, NodeID tid);
225
228
230 bool isMustJoin(const NodeID curTid, const ICFGNode* joinsite);
231
234 {
236 }
237
239
240
241 inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
242 {
244 if(tct->isCandidateFun(call->getFun()) == false)
245 return;
246 tct->pushCxt(cxt,call,callee);
247 }
249 inline bool matchAndPopCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
250 {
251 return tct->matchAndPopCxt(cxt,call,callee);
252 }
254 inline bool isContextSuffix(const CallStrCxt& lhs, const CallStrCxt call)
255 {
256 return tct->isContextSuffix(lhs,call);
257 }
259
261
262 inline bool pushToCTSWorkList(const CxtThreadStmt& cs)
263 {
264 return cxtStmtList.push(cs);
265 }
267 {
269 return ctp;
270 }
271
273 inline bool isTDFork(const ICFGNode* call)
274 {
275 const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
276 return fork && tcg->getThreadAPI()->isTDFork(fork);
277 }
279 inline bool isTDJoin(const ICFGNode* call)
280 {
281 const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
282 return join && tcg->getThreadAPI()->isTDJoin(join);
283 }
284
286 NodeBS getDirAndIndJoinedTid(const CallStrCxt& cxt, const ICFGNode* call);
287
289 bool hasJoinInSymmetricLoop(const CallStrCxt& cxt, const ICFGNode* call) const;
290
292 const LoopBBs& getJoinInSymmetricLoop(const CallStrCxt& cxt, const ICFGNode* call) const;
293
296
306
307public:
312};
313
318{
319
320public:
323 {
324 Empty, // initial(dummy) state
325 TDAlive, // thread is alive
326 TDDead, // thread is dead
327 };
328
336
339
341 {
343 }
345 void collectSCEVInfo();
346
350 void analyzeForkJoinPair();
351
354 {
355 return directJoinMap[cs];
356 }
359
361 inline const LoopBBs& getJoinInSymmetricLoop(const CxtStmt& cs) const
362 {
363 CxtStmtToLoopMap::const_iterator it = cxtJoinInLoop.find(cs);
364 assert(it!=cxtJoinInLoop.end() && "does not have the loop");
365 return it->second;
366 }
367 inline bool hasJoinInSymmetricLoop(const CxtStmt& cs) const
368 {
369 CxtStmtToLoopMap::const_iterator it = cxtJoinInLoop.find(cs);
370 return it!=cxtJoinInLoop.end();
371 }
374 {
375 bool nonhp = HBPair.find(std::make_pair(tid1,tid2))!=HBPair.end();
376 bool hp = HPPair.find(std::make_pair(tid1,tid2))!=HPPair.end();
377 return nonhp && !hp;
378 }
381 {
382 bool full = fullJoin.find(std::make_pair(tid1,tid2))!=fullJoin.end();
383 bool partial = partialJoin.find(std::make_pair(tid1,tid2))!=partialJoin.end();
384 return full && !partial;
385 }
386
388 inline LoopBBs& getJoinLoop(const CallICFGNode* inst)
389 {
390 return tct->getJoinLoop(inst);
391 }
392 inline bool hasJoinLoop(const CallICFGNode* inst)
393 {
394 return tct->hasJoinLoop(inst);
395 }
398 {
399 return cxtJoinInLoop;
400 }
401private:
402
404 void handleFork(const CxtStmt& cts,NodeID rootTid);
405
407 void handleJoin(const CxtStmt& cts,NodeID rootTid);
408
410 void handleCall(const CxtStmt& cts,NodeID rootTid);
411
413 void handleRet(const CxtStmt& cts);
414
416 void handleIntra(const CxtStmt& cts);
417
419 bool isSameSCEV(const ICFGNode* forkSite, const ICFGNode* joinSite);
420
423
428
429
431 {
432 CxtStmtToAliveFlagMap::const_iterator it = cxtStmtToAliveFlagMap.find(cs);
433 if(it==cxtStmtToAliveFlagMap.end())
434 {
436 return Empty;
437 }
438 else
439 return it->second;
440 }
443 {
447 {
448 instToCxtStmt[tgr.getStmt()].insert(tgr);
450 }
451
452 }
454 void markCxtStmtFlag(const CxtStmt& tgr, const CxtStmt& src)
455 {
458 if(flag_tgr == Empty)
459 {
461 }
462 else if(flag_tgr == TDDead)
463 {
464 if(flag_src==TDAlive)
466 }
467 else
468 {
470 }
472 {
473 instToCxtStmt[tgr.getStmt()].insert(tgr);
475 }
476 }
478 inline void clearFlagMap()
479 {
480 cxtStmtToAliveFlagMap.clear();
482 }
484
486
487 inline bool pushToCTSWorkList(const CxtStmt& cs)
488 {
489 return cxtStmtList.push(cs);
490 }
492 {
494 return ctp;
495 }
497
499
500
501 inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
502 {
504 if(tct->isCandidateFun(call->getFun()) == false)
505 return;
506 tct->pushCxt(cxt,call,callee);
507 }
509 inline bool matchAndPopCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
510 {
511 return tct->matchAndPopCxt(cxt,call,callee);
512 }
514 inline bool isContextSuffix(const CallStrCxt& lhs, const CallStrCxt call)
515 {
516 return tct->isContextSuffix(lhs,call);
517 }
519
521 inline bool isTDFork(const ICFGNode* call)
522 {
523 const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
524 return fork && getTCG()->getThreadAPI()->isTDFork(fork);
525 }
527 inline bool isTDJoin(const ICFGNode* call)
528 {
529 const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
530 return join && getTCG()->getThreadAPI()->isTDJoin(join);
531 }
533 inline const SVFVar* getForkedThread(const CallICFGNode* call)
534 {
535 return getTCG()->getThreadAPI()->getForkedThread(call);
536 }
538 inline const SVFVar* getJoinedThread(const CallICFGNode* call)
539 {
540 return getTCG()->getThreadAPI()->getJoinedThread(call);
541 }
543 {
544 getTCG()->getCallees(SVFUtil::cast<CallICFGNode>(inst), callees);
545 return callees;
546 }
548 inline ThreadCallGraph* getTCG() const
549 {
550 return tct->getThreadCallGraph();
551 }
553 inline void addDirectlyJoinTID(const CxtStmt& cs, NodeID tid)
554 {
555 directJoinMap[cs].set(tid);
556 }
557
560
562 {
563 HPPair.insert(std::make_pair(tid1,tid2));
564 HPPair.insert(std::make_pair(tid2,tid1));
565 }
567 {
568 HBPair.insert(std::make_pair(tid1,tid2));
569 }
571
573
575 {
576 fullJoin.insert(std::make_pair(tid1,tid2));
577 }
579 {
580 partialJoin.insert(std::make_pair(tid1,tid2));
581 }
583
585 inline const CxtStmtSet& getCxtStmtsFromInst(const ICFGNode* inst) const
586 {
587 InstToCxtStmt::const_iterator it = instToCxtStmt.find(inst);
588 assert(it!=instToCxtStmt.end() && "no CxtStmt for the instruction?");
589 return it->second;
590 }
591 inline bool hasCxtStmtsFromInst(const ICFGNode* inst) const
592 {
593 return instToCxtStmt.find(inst)!=instToCxtStmt.end();
594 }
595
597 inline void addSymmetricLoopJoin(const CxtStmt& cs, LoopBBs& lp)
598 {
599 cxtJoinInLoop[cs] = lp;
600 }
612};
613
614} // End namespace SVF
615
616#endif /* MHP_H_ */
void getCallees(const CallICFGNode *cs, FunctionSet &callees)
Get all callees for a callsite.
Definition CallGraph.h:426
Set< const FunObjVar * > FunctionSet
Definition CallGraph.h:247
bool push(const Data &data)
Definition WorkList.h:180
void addToFullJoin(NodeID tid1, NodeID tid2)
full join and partial join
Definition MHP.h:574
const SVFVar * getForkedThread(const CallICFGNode *call)
Get forked thread.
Definition MHP.h:533
void markCxtStmtFlag(const CxtStmt &tgr, const CxtStmt &src)
Transfer function for marking context-sensitive statement.
Definition MHP.h:454
Map< CxtStmt, LoopBBs > CxtStmtToLoopMap
Definition MHP.h:334
FIFOWorkList< CxtStmt > CxtStmtWorkList
Definition MHP.h:335
bool isAliasedForkJoin(const CallICFGNode *forkSite, const CallICFGNode *joinSite)
Whether it is a matched fork join pair.
Definition MHP.cpp:1296
ValDomain getMarkedFlag(const CxtStmt &cs)
Mark thread flags for cxtStmt.
Definition MHP.h:430
void addToHPPair(NodeID tid1, NodeID tid2)
Definition MHP.h:561
SVFLoopAndDomInfo::LoopBBs LoopBBs
Definition MHP.h:329
void analyzeForkJoinPair()
Definition MHP.cpp:870
bool hasJoinLoop(const CallICFGNode *inst)
Definition MHP.h:392
const CallGraph::FunctionSet & getCallee(const ICFGNode *inst, CallGraph::FunctionSet &callees)
Definition MHP.h:542
void addSymmetricLoopJoin(const CxtStmt &cs, LoopBBs &lp)
Add inloop join.
Definition MHP.h:597
void handleRet(const CxtStmt &cts)
Handle return.
Definition MHP.cpp:1077
NodeBS getDirAndIndJoinedTid(const CxtStmt &cs)
Get directly and indirectly joined threadIDs based on a context-sensitive join site.
Definition MHP.cpp:1171
ThreadPairSet partialJoin
t1 partially joins t2 along some program path(s)
Definition MHP.h:610
ThreadPairSet fullJoin
t1 fully joins t2 along all program path
Definition MHP.h:609
ForkJoinAnalysis(TCT *t)
Definition MHP.h:340
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
Definition MHP.h:509
ThreadPairSet HPPair
threads happen-in-parallel
Definition MHP.h:608
CxtStmt popFromCTSWorkList()
Definition MHP.h:491
TCT::InstVec InstVec
Definition MHP.h:330
bool hasCxtStmtsFromInst(const ICFGNode *inst) const
Definition MHP.h:591
CxtStmtToLoopMap cxtJoinInLoop
a set of context-sensitive join inside loop
Definition MHP.h:606
void addToHBPair(NodeID tid1, NodeID tid2)
Definition MHP.h:566
ThreadCallGraph * getTCG() const
ThreadCallGraph.
Definition MHP.h:548
void addToPartial(NodeID tid1, NodeID tid2)
Definition MHP.h:578
Map< const ICFGNode *, CxtStmtSet > InstToCxtStmt
Definition MHP.h:338
Set< CxtStmt > CxtStmtSet
Definition MHP.h:337
void collectSCEVInfo()
functions
Definition MHP.cpp:816
void clearFlagMap()
Clear flags.
Definition MHP.h:478
bool pushToCTSWorkList(const CxtStmt &cs)
Worklist operations.
Definition MHP.h:487
Set< NodePair > ThreadPairSet
Definition MHP.h:333
bool isHBPair(NodeID tid1, NodeID tid2)
Whether thread t1 happens-before thread t2.
Definition MHP.h:373
void addDirectlyJoinTID(const CxtStmt &cs, NodeID tid)
maps a context-sensitive join site to a thread id
Definition MHP.h:553
ValDomain
semilattice Empty==>TDDead==>TDAlive
Definition MHP.h:323
const SVFVar * getJoinedThread(const CallICFGNode *call)
Get joined thread.
Definition MHP.h:538
Map< CxtStmt, NodeBS > CxtStmtToTIDMap
Definition MHP.h:332
LoopBBs & getJoinLoop(const CallICFGNode *inst)
Get loop for join site.
Definition MHP.h:388
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
Definition MHP.h:501
CxtStmtToAliveFlagMap cxtStmtToAliveFlagMap
flags for context-sensitive statements
Definition MHP.h:602
const CxtStmtToLoopMap & getSymmetricLoopJoins() const
All SCEV-symmetric in-loop joins and their loop blocks.
Definition MHP.h:397
bool isTDFork(const ICFGNode *call)
Whether it is a fork site.
Definition MHP.h:521
ThreadPairSet HBPair
thread happens-before pair
Definition MHP.h:607
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt call)
If lhs is a suffix of rhs, including equal.
Definition MHP.h:514
bool isFullJoin(NodeID tid1, NodeID tid2)
Whether t1 fully joins t2.
Definition MHP.h:380
CxtStmtToTIDMap dirAndIndJoinMap
maps a context-sensitive join site to directly and indirectly joined thread ids
Definition MHP.h:605
void handleCall(const CxtStmt &cts, NodeID rootTid)
Handle call.
Definition MHP.cpp:1052
bool hasJoinInSymmetricLoop(const CxtStmt &cs) const
Definition MHP.h:367
InstToCxtStmt instToCxtStmt
Map a statement to all its context-sensitive statements.
Definition MHP.h:611
CxtStmtToTIDMap directJoinMap
maps a context-sensitive join site to directly joined thread ids
Definition MHP.h:604
bool sameLoopTripCount(const ICFGNode *forkSite, const ICFGNode *joinSite)
Same loop trip count.
Definition MHP.cpp:1270
bool isTDJoin(const ICFGNode *call)
Whether it is a join site.
Definition MHP.h:527
void markCxtStmtFlag(const CxtStmt &tgr, ValDomain flag)
Initialize TDAlive and TDDead flags.
Definition MHP.h:442
CxtStmtWorkList cxtStmtList
context-sensitive statement worklist
Definition MHP.h:603
Map< CxtStmt, ValDomain > CxtStmtToAliveFlagMap
Definition MHP.h:331
const LoopBBs & getJoinInSymmetricLoop(const CxtStmt &cs) const
Whether a context-sensitive join satisfies symmetric loop pattern.
Definition MHP.h:361
ThreadAPI::ForkJoinAliasCache forkJoinAliasCache
Definition MHP.h:426
void handleIntra(const CxtStmt &cts)
Handle intra.
Definition MHP.cpp:1150
void handleFork(const CxtStmt &cts, NodeID rootTid)
Handle fork.
Definition MHP.cpp:956
NodeBS & getDirectlyJoinedTid(const CxtStmt &cs)
Get directly joined threadIDs based on a context-sensitive join site.
Definition MHP.h:353
void handleJoin(const CxtStmt &cts, NodeID rootTid)
Handle join.
Definition MHP.cpp:983
bool isSameSCEV(const ICFGNode *forkSite, const ICFGNode *joinSite)
Return true if the fork and join have the same SCEV.
Definition MHP.cpp:1246
const CxtStmtSet & getCxtStmtsFromInst(const ICFGNode *inst) const
Get CxtStmtSet for an instruction.
Definition MHP.h:585
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
Definition ICFGNode.h:75
Definition MHP.h:57
CxtThreadStmtWorkList cxtStmtList
CxtThreadStmt worklist.
Definition MHP.h:300
bool isRecurFullJoin(NodeID parentTid, NodeID curTid)
Thread curTid can be fully joined by parentTid recursively.
Definition MHP.cpp:595
bool isMultiForkedThread(NodeID curTid)
A thread is a multiForked thread if it is in a loop or recursion.
Definition MHP.h:233
Set< CxtStmt > LockSpan
Definition MHP.h:67
void handleRet(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts)
Handle return.
Definition MHP.cpp:418
void rmInterleavingThread(const CxtThreadStmt &tgr, const NodeBS &tids, const ICFGNode *joinsite)
Definition MHP.h:205
virtual bool mayHappenInParallelCache(const ICFGNode *i1, const ICFGNode *i2)
Definition MHP.cpp:741
void analyze(ICFGGraph icfg, CGGraph cg)
Definition MHP.cpp:120
TCT * tct
TCT.
Definition MHP.h:298
BBToSymJoinsMap bbToSymJoins
Map a statement to its thread interleavings.
Definition MHP.h:302
FuncPairToBool nonCandidateFuncMHPRelMap
Definition MHP.h:305
NodeBS edgeFlow(const CxtThreadStmt &cts, const ICFGNode *dst)
Definition MHP.cpp:82
void printInterleaving()
Print interleaving results.
Definition MHP.cpp:796
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
Definition MHP.h:249
u32_t numOfTotalQueries
Total number of queries.
Definition MHP.h:308
Set< CxtThreadStmt > CxtThreadStmtSet
Definition MHP.h:62
void analyzeInterleaving(ICFGGraph icfg, CGGraph cg)
Analyze thread interleaving.
Definition MHP.cpp:134
std::pair< const FunObjVar *, const FunObjVar * > FuncPair
Definition MHP.h:69
SVFLoopAndDomInfo::LoopBBs LoopBBs
Definition MHP.h:65
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt call)
If lhs is a suffix of rhs, including equal.
Definition MHP.h:254
void updateSiblingThreads(ICFGGraph icfg, CGGraph cg, NodeID tid)
Definition MHP.cpp:565
void handleFork(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts, NodeID rootTid)
Handle fork.
Definition MHP.cpp:263
Set< const FunObjVar * > FunSet
Definition MHP.h:60
void updateAncestorThreads(ICFGGraph icfg, CGGraph cg, NodeID tid)
Update Ancestor and sibling threads.
Definition MHP.cpp:521
bool hasInterleavingThreads(const CxtThreadStmt &cts) const
Definition MHP.h:116
void handleCall(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts, NodeID rootTid)
Handle call.
Definition MHP.cpp:358
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
Definition MHP.h:241
ThreadCallGraph * tcg
TCG.
Definition MHP.h:297
void addInterleavingThread(const CxtThreadStmt &tgr, NodeID tid)
Add/Remove interleaving thread for statement inst.
Definition MHP.h:179
const NodeBS & getInterleavingThreads(const CxtThreadStmt &cts)
Get interleaving thread for statement inst.
Definition MHP.h:112
InstToThreadStmtSetMap instToTSMap
Map an instruction to its ThreadStmtSet.
Definition MHP.h:304
virtual ~MHP()
Destructor.
Definition MHP.cpp:110
void addInterleavingThread(const CxtThreadStmt &tgr, const CxtThreadStmt &src)
Definition MHP.h:187
bool isHBPair(NodeID tid1, NodeID tid2)
Whether thread t1 happens before t2 based on ForkJoin Analysis.
Definition MHP.cpp:665
ThreadCallGraph * getThreadCallGraph() const
Get ThreadCallGraph.
Definition MHP.h:89
ThreadStmtToThreadInterleav threadStmtToThreadInterLeav
Definition MHP.h:301
bool isTDFork(const ICFGNode *call)
Whether it is a fork site.
Definition MHP.h:273
void addInterleavingBits(const CxtThreadStmt &tgr, const NodeBS &bits)
Definition MHP.h:196
virtual bool executedByTheSameThread(const ICFGNode *i1, const ICFGNode *i2)
Definition MHP.cpp:775
Map< const SVFBasicBlock *, std::vector< CxtStmt > > BBToSymJoinsMap
Definition MHP.h:171
virtual bool mayHappenInParallel(const ICFGNode *i1, const ICFGNode *i2)
Interface to query whether two instructions may happen-in-parallel.
Definition MHP.cpp:763
void buildSymJoinKillTables()
Definition MHP.cpp:65
const CxtThreadStmtSet & getThreadStmtSet(const ICFGNode *inst) const
Get/has ThreadStmt.
Definition MHP.h:124
const LoopBBs & getJoinInSymmetricLoop(const CallStrCxt &cxt, const ICFGNode *call) const
Whether a context-sensitive join satisfies symmetric loop pattern.
Definition MHP.cpp:656
void handleJoin(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts, NodeID rootTid)
Handle join.
Definition MHP.cpp:294
Map< const ICFGNode *, CxtThreadStmtSet > InstToThreadStmtSetMap
Definition MHP.h:64
ForkJoinAnalysis * fja
ForJoin Analysis.
Definition MHP.h:299
bool hasJoinInSymmetricLoop(const CallStrCxt &cxt, const ICFGNode *call) const
Whether a context-sensitive join satisfies symmetric loop pattern.
Definition MHP.cpp:649
const CallGraph::FunctionSet & getCallee(const CallICFGNode *inst, CallGraph::FunctionSet &callees)
Definition MHP.h:141
bool hasThreadStmtSet(const ICFGNode *inst) const
Definition MHP.h:130
SymJoinToLoopMap symJoinLoop
symmetric in-loop join -> its loop's blocks
Definition MHP.h:303
double interleavingQueriesTime
Definition MHP.h:311
u32_t numOfMHPQueries
Number of queries are answered as may-happen-in-parallel.
Definition MHP.h:309
void updateNonCandidateFunInterleaving(ICFGGraph icfg, CGGraph cg)
Definition MHP.cpp:202
Map< CxtThreadStmt, NodeBS > ThreadStmtToThreadInterleav
Definition MHP.h:63
Map< CxtStmt, Set< const SVFBasicBlock * > > SymJoinToLoopMap
Definition MHP.h:172
bool isMustJoin(const NodeID curTid, const ICFGNode *joinsite)
Whether a join site must join a thread t.
Definition MHP.cpp:630
double interleavingTime
Definition MHP.h:310
bool isConnectedfromMain(const FunObjVar *fun)
Whether the function is connected from main function in thread call graph.
Definition MHP.cpp:670
void handleIntra(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts)
Handle intra.
Definition MHP.cpp:496
CxtThreadStmt popFromCTSWorkList()
Definition MHP.h:266
void handleNonCandidateFun(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts)
Handle non-candidate function.
Definition MHP.cpp:240
Map< FuncPair, bool > FuncPairToBool
Definition MHP.h:70
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:640
virtual bool mayHappenInParallelInst(const ICFGNode *i1, const ICFGNode *i2)
Definition MHP.cpp:705
FIFOWorkList< CxtThreadStmt > CxtThreadStmtWorkList
Definition MHP.h:61
bool pushToCTSWorkList(const CxtThreadStmt &cs)
WorkList helper functions.
Definition MHP.h:262
TCT * getTCT() const
Get Thread Creation Tree.
Definition MHP.h:95
bool isTDJoin(const ICFGNode *call)
Whether it is a join site.
Definition MHP.h:279
void set(unsigned Idx)
bool isMultiforked() const
Definition TCT.h:121
TCTNode * getTCTNode(NodeID id) const
Get TCT node.
Definition TCT.h:203
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt &call)
If lhs is a suffix of rhs, including equal.
Definition TCT.cpp:521
bool hasJoinLoop(const CallICFGNode *join) const
Definition TCT.h:398
ThreadCallGraph * getThreadCallGraph() const
Get TCG.
Definition TCT.h:193
bool isCandidateFun(const CallGraph::FunctionSet &callees) const
Whether it is a candidate function for indirect call.
Definition TCT.h:288
std::vector< const ICFGNode * > InstVec
Definition TCT.h:173
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
Definition TCT.cpp:493
LoopBBs & getJoinLoop(const CallICFGNode *join)
Get loop for join site.
Definition TCT.h:390
virtual void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
Definition TCT.cpp:473
bool isTDFork(const CallICFGNode *inst) const
Return true if this call create a new thread.
const ValVar * getForkedThread(const CallICFGNode *inst) const
Return arguments/attributes of pthread_create / hare_parallel_for.
bool isTDJoin(const CallICFGNode *inst) const
Return true if this call wait for a worker thread.
const SVFVar * getJoinedThread(const CallICFGNode *inst) const
Return arguments/attributes of pthread_join.
ThreadAPI * getThreadAPI() const
Thread API.
for isBitcode
Definition BasicTypes.h:70
u32_t NodeID
Definition GeneralType.h:76
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
std::vector< u32_t > CallStrCxt
Definition GeneralType.h:96
unsigned u32_t
Definition GeneralType.h:67
If fork join the same thread.
Definition ThreadAPI.h:158