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
30#ifndef MHP_H_
31#define MHP_H_
32
33#include "MTA/TCT.h"
34#include "Util/SVFUtil.h"
35
36#include <memory>
37#include <vector>
38
39namespace SVF
40{
41
42class ForkJoinAnalysis;
43class LockAnalysis;
44// Forward declaration for the sliced-graph handle analyze() can run on.
45class SlicedSVFIRView;
46
51class MHP
52{
53
54public:
72
74
75 typedef std::pair<const FunObjVar*,const FunObjVar*> FuncPair;
77
83
85 template<class ICFGGraph, class CGGraph>
86 static std::unique_ptr<MHP> create(
87 TCT* t, ICFGGraph icfg, CGGraph cg,
89
91 virtual ~MHP();
92
98 template<class ICFGGraph, class CGGraph> void analyze(ICFGGraph icfg, CGGraph cg);
99
101 template<class ICFGGraph, class CGGraph> void analyzeInterleaving(ICFGGraph icfg, CGGraph cg);
102
105 {
106 return tcg;
107 }
108
110 inline TCT* getTCT() const
111 {
112 return tct;
113 }
114
116 bool isConnectedfromMain(const FunObjVar* fun);
117
119 virtual bool mayHappenInParallel(const ICFGNode* i1, const ICFGNode* i2);
120 virtual bool mayHappenInParallelCache(const ICFGNode* i1, const ICFGNode* i2);
121 virtual bool mayHappenInParallelInst(const ICFGNode* i1, const ICFGNode* i2);
122 virtual bool executedByTheSameThread(const ICFGNode* i1, const ICFGNode* i2);
123
126 const NodeThreadSummary* getThreadSummary(const ICFGNode* inst) const;
127
129
131 {
133 }
134 inline bool hasInterleavingThreads(const CxtThreadStmt& cts) const
135 {
137 }
139
141
142 inline const CxtThreadStmtSet& getThreadStmtSet(const ICFGNode* inst) const
143 {
144 InstToThreadStmtSetMap::const_iterator it = instToTSMap.find(inst);
145 assert(it!=instToTSMap.end() && "no thread access the instruction?");
146 return it->second;
147 }
148 inline bool hasThreadStmtSet(const ICFGNode* inst) const
149 {
150 return instToTSMap.find(inst)!=instToTSMap.end();
151 }
153
155 void printInterleaving();
156
157protected:
163 explicit MHP(
164 TCT* t,
166
169 template<class ICFGGraph, class CGGraph> void updateNonCandidateFunInterleaving(ICFGGraph icfg, CGGraph cg);
170
173 template<class ICFGGraph, class CGGraph> void buildQuerySummaries(ICFGGraph icfg, CGGraph cg);
175 template<class ICFGGraph, class CGGraph> void handleNonCandidateFun(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts);
176
178 template<class ICFGGraph, class CGGraph> void handleFork(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts, NodeID rootTid);
179
181 template<class ICFGGraph, class CGGraph> void handleJoin(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts, NodeID rootTid);
182
184 template<class ICFGGraph, class CGGraph> void handleCall(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts, NodeID rootTid);
185
187 template<class ICFGGraph, class CGGraph> void handleRet(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts);
188
190 template<class ICFGGraph, class CGGraph> void handleIntra(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt& cts);
191
194
198 NodeBS edgeFlow(const CxtThreadStmt& cts, const ICFGNode* dst);
200
202
204 {
205 if(threadStmtToThreadInterLeav[tgr].test_and_set(tid))
206 {
207 instToTSMap[tgr.getStmt()].insert(tgr);
209 }
210 }
211 inline void addInterleavingThread(const CxtThreadStmt& tgr, const CxtThreadStmt& src)
212 {
214 if(changed)
215 {
216 instToTSMap[tgr.getStmt()].insert(tgr);
218 }
219 }
220 inline void addInterleavingBits(const CxtThreadStmt& tgr, const NodeBS& bits)
221 {
223 if(changed)
224 {
225 instToTSMap[tgr.getStmt()].insert(tgr);
227 }
228 }
229 inline void rmInterleavingThread(const CxtThreadStmt& tgr, const NodeBS& tids, const ICFGNode* joinsite)
230 {
232 for(NodeBS::iterator it = tids.begin(), eit = tids.end(); it!=eit; ++it)
233 {
234 if(isMustJoin(tgr.getTid(),joinsite))
235 joinedTids.set(*it);
236 }
237 if(threadStmtToThreadInterLeav[tgr].intersectWithComplement(joinedTids))
238 {
240 }
241 }
243
245
246 template<class ICFGGraph, class CGGraph> void updateAncestorThreads(ICFGGraph icfg, CGGraph cg, NodeID tid);
247 template<class ICFGGraph, class CGGraph> void updateSiblingThreads(ICFGGraph icfg, CGGraph cg, NodeID tid);
249
252
254 bool isMustJoin(const NodeID curTid, const ICFGNode* joinsite);
255
258 {
260 }
261
263
264
265 inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
266 {
268 if(tct->isCandidateFun(call->getFun()) == false)
269 return;
270 tct->pushCxt(cxt,call,callee);
271 }
273 inline bool matchAndPopCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
274 {
275 return tct->matchAndPopCxt(cxt,call,callee);
276 }
278 inline bool isContextSuffix(const CallStrCxt& lhs, const CallStrCxt call)
279 {
280 return tct->isContextSuffix(lhs,call);
281 }
283
285
286 inline bool pushToCTSWorkList(const CxtThreadStmt& cs)
287 {
288 return cxtStmtList.push(cs);
289 }
291 {
293 return ctp;
294 }
295
297 inline bool isTDFork(const ICFGNode* call)
298 {
299 const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
300 return fork && tcg->getThreadAPI()->isTDFork(fork);
301 }
303 inline bool isTDJoin(const ICFGNode* call)
304 {
305 const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
306 return join && tcg->getThreadAPI()->isTDJoin(join);
307 }
308
310 NodeBS getDirAndIndJoinedTid(const CallStrCxt& cxt, const ICFGNode* call);
311
313 bool hasJoinInSymmetricLoop(const CallStrCxt& cxt, const ICFGNode* call) const;
314
316 const LoopBBs& getJoinInSymmetricLoop(const CallStrCxt& cxt, const ICFGNode* call) const;
317
320
333
334public:
339};
340
345{
346
347public:
350 {
351 Empty, // initial(dummy) state
352 TDAlive, // thread is alive
353 TDDead, // thread is dead
354 };
355
363
366
368 {
370 }
372 void collectSCEVInfo();
373
377 template<class ICFGGraph, class CGGraph>
379
382 {
383 return directJoinMap[cs];
384 }
387
389 inline const LoopBBs& getJoinInSymmetricLoop(const CxtStmt& cs) const
390 {
391 CxtStmtToLoopMap::const_iterator it = cxtJoinInLoop.find(cs);
392 assert(it!=cxtJoinInLoop.end() && "does not have the loop");
393 return it->second;
394 }
395 inline bool hasJoinInSymmetricLoop(const CxtStmt& cs) const
396 {
397 CxtStmtToLoopMap::const_iterator it = cxtJoinInLoop.find(cs);
398 return it!=cxtJoinInLoop.end();
399 }
402 {
403 bool nonhp = HBPair.find(std::make_pair(tid1,tid2))!=HBPair.end();
404 bool hp = HPPair.find(std::make_pair(tid1,tid2))!=HPPair.end();
405 return nonhp && !hp;
406 }
409 {
410 bool full = fullJoin.find(std::make_pair(tid1,tid2))!=fullJoin.end();
411 bool partial = partialJoin.find(std::make_pair(tid1,tid2))!=partialJoin.end();
412 return full && !partial;
413 }
414
416 inline LoopBBs& getJoinLoop(const CallICFGNode* inst)
417 {
418 return tct->getJoinLoop(inst);
419 }
420 inline bool hasJoinLoop(const CallICFGNode* inst)
421 {
422 return tct->hasJoinLoop(inst);
423 }
426 {
427 return cxtJoinInLoop;
428 }
429private:
430
432 template<class ICFGGraph, class CGGraph>
433 void handleFork(ICFGGraph icfg, CGGraph cg,
434 const CxtStmt& cts, NodeID rootTid);
435
437 template<class ICFGGraph, class CGGraph>
438 void handleJoin(ICFGGraph icfg, CGGraph cg,
439 const CxtStmt& cts, NodeID rootTid);
440
442 template<class ICFGGraph, class CGGraph>
443 void handleCall(ICFGGraph icfg, CGGraph cg,
444 const CxtStmt& cts);
445
447 template<class ICFGGraph, class CGGraph>
448 void handleRet(ICFGGraph icfg, CGGraph cg, const CxtStmt& cts);
449
451 template<class ICFGGraph>
452 void handleIntra(ICFGGraph icfg, const CxtStmt& cts);
453
455 bool isSameSCEV(const ICFGNode* forkSite, const ICFGNode* joinSite);
456
459
464
465
467 {
468 CxtStmtToAliveFlagMap::const_iterator it = cxtStmtToAliveFlagMap.find(cs);
469 if(it==cxtStmtToAliveFlagMap.end())
470 {
472 return Empty;
473 }
474 else
475 return it->second;
476 }
479 {
483 {
484 instToCxtStmt[tgr.getStmt()].insert(tgr);
486 }
487
488 }
490 void markCxtStmtFlag(const CxtStmt& tgr, const CxtStmt& src)
491 {
494 if(flag_tgr == Empty)
495 {
497 }
498 else if(flag_tgr == TDDead)
499 {
500 if(flag_src==TDAlive)
502 }
503 else
504 {
506 }
508 {
509 instToCxtStmt[tgr.getStmt()].insert(tgr);
511 }
512 }
514 inline void clearFlagMap()
515 {
516 cxtStmtToAliveFlagMap.clear();
518 }
520
522
523 inline bool pushToCTSWorkList(const CxtStmt& cs)
524 {
525 return cxtStmtList.push(cs);
526 }
528 {
530 return ctp;
531 }
533
535
536
537 inline void pushCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
538 {
540 if(tct->isCandidateFun(call->getFun()) == false)
541 return;
542 tct->pushCxt(cxt,call,callee);
543 }
545 inline bool matchAndPopCxt(CallStrCxt& cxt, const CallICFGNode* call, const FunObjVar* callee)
546 {
547 return tct->matchAndPopCxt(cxt,call,callee);
548 }
550 inline bool isContextSuffix(const CallStrCxt& lhs, const CallStrCxt call)
551 {
552 return tct->isContextSuffix(lhs,call);
553 }
555
557 inline bool isTDFork(const ICFGNode* call)
558 {
559 const CallICFGNode* fork = SVFUtil::dyn_cast<CallICFGNode>(call);
560 return fork && getTCG()->getThreadAPI()->isTDFork(fork);
561 }
563 inline bool isTDJoin(const ICFGNode* call)
564 {
565 const CallICFGNode* join = SVFUtil::dyn_cast<CallICFGNode>(call);
566 return join && getTCG()->getThreadAPI()->isTDJoin(join);
567 }
569 inline const SVFVar* getForkedThread(const CallICFGNode* call)
570 {
571 return getTCG()->getThreadAPI()->getForkedThread(call);
572 }
574 inline const SVFVar* getJoinedThread(const CallICFGNode* call)
575 {
576 return getTCG()->getThreadAPI()->getJoinedThread(call);
577 }
579 inline ThreadCallGraph* getTCG() const
580 {
581 return tct->getThreadCallGraph();
582 }
584 inline void addDirectlyJoinTID(const CxtStmt& cs, NodeID tid)
585 {
586 directJoinMap[cs].set(tid);
587 }
588
591
593 {
594 HPPair.insert(std::make_pair(tid1,tid2));
595 HPPair.insert(std::make_pair(tid2,tid1));
596 }
598 {
599 HBPair.insert(std::make_pair(tid1,tid2));
600 }
602
604
606 {
607 fullJoin.insert(std::make_pair(tid1,tid2));
608 }
610 {
611 partialJoin.insert(std::make_pair(tid1,tid2));
612 }
614
616 inline const CxtStmtSet& getCxtStmtsFromInst(const ICFGNode* inst) const
617 {
618 InstToCxtStmt::const_iterator it = instToCxtStmt.find(inst);
619 assert(it!=instToCxtStmt.end() && "no CxtStmt for the instruction?");
620 return it->second;
621 }
622 inline bool hasCxtStmtsFromInst(const ICFGNode* inst) const
623 {
624 return instToCxtStmt.find(inst)!=instToCxtStmt.end();
625 }
626
628 inline void addSymmetricLoopJoin(const CxtStmt& cs, LoopBBs& lp)
629 {
630 cxtJoinInLoop[cs] = lp;
631 }
643};
644
645template<class ICFGGraph, class CGGraph>
646std::unique_ptr<MHP> MHP::create(
648{
649 std::unique_ptr<MHP> mhp(new MHP(t, representation));
650 mhp->fja->analyzeForkJoinPair(icfg, cg);
651 mhp->buildSymJoinKillTables();
652 return mhp;
653}
654
655} // End namespace SVF
656
657#endif /* MHP_H_ */
bool push(const Data &data)
Definition WorkList.h:180
void addToFullJoin(NodeID tid1, NodeID tid2)
full join and partial join
Definition MHP.h:605
const SVFVar * getForkedThread(const CallICFGNode *call)
Get forked thread.
Definition MHP.h:569
void markCxtStmtFlag(const CxtStmt &tgr, const CxtStmt &src)
Transfer function for marking context-sensitive statement.
Definition MHP.h:490
Map< CxtStmt, LoopBBs > CxtStmtToLoopMap
Definition MHP.h:361
void handleIntra(ICFGGraph icfg, const CxtStmt &cts)
Handle intra.
Definition MHP.cpp:1283
FIFOWorkList< CxtStmt > CxtStmtWorkList
Definition MHP.h:362
bool isAliasedForkJoin(const CallICFGNode *forkSite, const CallICFGNode *joinSite)
Whether it is a matched fork join pair.
Definition MHP.cpp:1431
ValDomain getMarkedFlag(const CxtStmt &cs)
Mark thread flags for cxtStmt.
Definition MHP.h:466
void addToHPPair(NodeID tid1, NodeID tid2)
Definition MHP.h:592
SVFLoopAndDomInfo::LoopBBs LoopBBs
Definition MHP.h:356
bool hasJoinLoop(const CallICFGNode *inst)
Definition MHP.h:420
void addSymmetricLoopJoin(const CxtStmt &cs, LoopBBs &lp)
Add inloop join.
Definition MHP.h:628
NodeBS getDirAndIndJoinedTid(const CxtStmt &cs)
Get directly and indirectly joined threadIDs based on a context-sensitive join site.
Definition MHP.cpp:1306
ThreadPairSet partialJoin
t1 partially joins t2 along some program path(s)
Definition MHP.h:641
ThreadPairSet fullJoin
t1 fully joins t2 along all program path
Definition MHP.h:640
ForkJoinAnalysis(TCT *t)
Definition MHP.h:367
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
Definition MHP.h:545
void analyzeForkJoinPair(ICFGGraph icfg, CGGraph cg)
Definition MHP.cpp:962
ThreadPairSet HPPair
threads happen-in-parallel
Definition MHP.h:639
CxtStmt popFromCTSWorkList()
Definition MHP.h:527
TCT::InstVec InstVec
Definition MHP.h:357
bool hasCxtStmtsFromInst(const ICFGNode *inst) const
Definition MHP.h:622
CxtStmtToLoopMap cxtJoinInLoop
a set of context-sensitive join inside loop
Definition MHP.h:637
void addToHBPair(NodeID tid1, NodeID tid2)
Definition MHP.h:597
ThreadCallGraph * getTCG() const
ThreadCallGraph.
Definition MHP.h:579
void addToPartial(NodeID tid1, NodeID tid2)
Definition MHP.h:609
Map< const ICFGNode *, CxtStmtSet > InstToCxtStmt
Definition MHP.h:365
Set< CxtStmt > CxtStmtSet
Definition MHP.h:364
void collectSCEVInfo()
functions
Definition MHP.cpp:907
void clearFlagMap()
Clear flags.
Definition MHP.h:514
bool pushToCTSWorkList(const CxtStmt &cs)
Worklist operations.
Definition MHP.h:523
Set< NodePair > ThreadPairSet
Definition MHP.h:360
bool isHBPair(NodeID tid1, NodeID tid2)
Whether thread t1 happens-before thread t2.
Definition MHP.h:401
void addDirectlyJoinTID(const CxtStmt &cs, NodeID tid)
maps a context-sensitive join site to a thread id
Definition MHP.h:584
ValDomain
semilattice Empty==>TDDead==>TDAlive
Definition MHP.h:350
const SVFVar * getJoinedThread(const CallICFGNode *call)
Get joined thread.
Definition MHP.h:574
Map< CxtStmt, NodeBS > CxtStmtToTIDMap
Definition MHP.h:359
LoopBBs & getJoinLoop(const CallICFGNode *inst)
Get loop for join site.
Definition MHP.h:416
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
Definition MHP.h:537
void handleRet(ICFGGraph icfg, CGGraph cg, const CxtStmt &cts)
Handle return.
Definition MHP.cpp:1199
CxtStmtToAliveFlagMap cxtStmtToAliveFlagMap
flags for context-sensitive statements
Definition MHP.h:633
void handleFork(ICFGGraph icfg, CGGraph cg, const CxtStmt &cts, NodeID rootTid)
Handle fork.
Definition MHP.cpp:1054
const CxtStmtToLoopMap & getSymmetricLoopJoins() const
All SCEV-symmetric in-loop joins and their loop blocks.
Definition MHP.h:425
bool isTDFork(const ICFGNode *call)
Whether it is a fork site.
Definition MHP.h:557
ThreadPairSet HBPair
thread happens-before pair
Definition MHP.h:638
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt call)
If lhs is a suffix of rhs, including equal.
Definition MHP.h:550
bool isFullJoin(NodeID tid1, NodeID tid2)
Whether t1 fully joins t2.
Definition MHP.h:408
CxtStmtToTIDMap dirAndIndJoinMap
maps a context-sensitive join site to directly and indirectly joined thread ids
Definition MHP.h:636
bool hasJoinInSymmetricLoop(const CxtStmt &cs) const
Definition MHP.h:395
InstToCxtStmt instToCxtStmt
Map a statement to all its context-sensitive statements.
Definition MHP.h:642
CxtStmtToTIDMap directJoinMap
maps a context-sensitive join site to directly joined thread ids
Definition MHP.h:635
bool sameLoopTripCount(const ICFGNode *forkSite, const ICFGNode *joinSite)
Same loop trip count.
Definition MHP.cpp:1405
bool isTDJoin(const ICFGNode *call)
Whether it is a join site.
Definition MHP.h:563
void markCxtStmtFlag(const CxtStmt &tgr, ValDomain flag)
Initialize TDAlive and TDDead flags.
Definition MHP.h:478
CxtStmtWorkList cxtStmtList
context-sensitive statement worklist
Definition MHP.h:634
Map< CxtStmt, ValDomain > CxtStmtToAliveFlagMap
Definition MHP.h:358
const LoopBBs & getJoinInSymmetricLoop(const CxtStmt &cs) const
Whether a context-sensitive join satisfies symmetric loop pattern.
Definition MHP.h:389
ThreadAPI::ForkJoinAliasCache forkJoinAliasCache
Definition MHP.h:462
NodeBS & getDirectlyJoinedTid(const CxtStmt &cs)
Get directly joined threadIDs based on a context-sensitive join site.
Definition MHP.h:381
bool isSameSCEV(const ICFGNode *forkSite, const ICFGNode *joinSite)
Return true if the fork and join have the same SCEV.
Definition MHP.cpp:1381
void handleJoin(ICFGGraph icfg, CGGraph cg, const CxtStmt &cts, NodeID rootTid)
Handle join.
Definition MHP.cpp:1086
void handleCall(ICFGGraph icfg, CGGraph cg, const CxtStmt &cts)
Handle call.
Definition MHP.cpp:1169
const CxtStmtSet & getCxtStmtsFromInst(const ICFGNode *inst) const
Get CxtStmtSet for an instruction.
Definition MHP.h:616
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
Definition ICFGNode.h:75
Definition MHP.h:52
CxtThreadStmtWorkList cxtStmtList
CxtThreadStmt worklist.
Definition MHP.h:324
bool isRecurFullJoin(NodeID parentTid, NodeID curTid)
Thread curTid can be fully joined by parentTid recursively.
Definition MHP.cpp:684
bool isMultiForkedThread(NodeID curTid)
A thread is a multiForked thread if it is in a loop or recursion.
Definition MHP.h:257
Set< CxtStmt > LockSpan
Definition MHP.h:73
void handleRet(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts)
Handle return.
Definition MHP.cpp:507
void rmInterleavingThread(const CxtThreadStmt &tgr, const NodeBS &tids, const ICFGNode *joinsite)
Definition MHP.h:229
virtual bool mayHappenInParallelCache(const ICFGNode *i1, const ICFGNode *i2)
Definition MHP.cpp:832
void analyze(ICFGGraph icfg, CGGraph cg)
Definition MHP.cpp:115
TCT * tct
TCT.
Definition MHP.h:322
Map< const ICFGNode *, NodeThreadSummary > InstToThreadSummaryMap
Definition MHP.h:70
BBToSymJoinsMap bbToSymJoins
Map a statement to its thread interleavings.
Definition MHP.h:326
FuncPairToBool nonCandidateFuncMHPRelMap
Definition MHP.h:332
NodeBS edgeFlow(const CxtThreadStmt &cts, const ICFGNode *dst)
Definition MHP.cpp:77
void printInterleaving()
Print interleaving results.
Definition MHP.cpp:887
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
Definition MHP.h:273
u32_t numOfTotalQueries
Total number of queries.
Definition MHP.h:335
Set< CxtThreadStmt > CxtThreadStmtSet
Definition MHP.h:57
void analyzeInterleaving(ICFGGraph icfg, CGGraph cg)
Analyze thread interleaving.
Definition MHP.cpp:129
std::pair< const FunObjVar *, const FunObjVar * > FuncPair
Definition MHP.h:75
SVFLoopAndDomInfo::LoopBBs LoopBBs
Definition MHP.h:71
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt call)
If lhs is a suffix of rhs, including equal.
Definition MHP.h:278
void updateSiblingThreads(ICFGGraph icfg, CGGraph cg, NodeID tid)
Definition MHP.cpp:654
void handleFork(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts, NodeID rootTid)
Handle fork.
Definition MHP.cpp:341
Set< const FunObjVar * > FunSet
Definition MHP.h:55
void updateAncestorThreads(ICFGGraph icfg, CGGraph cg, NodeID tid)
Update Ancestor and sibling threads.
Definition MHP.cpp:610
bool hasInterleavingThreads(const CxtThreadStmt &cts) const
Definition MHP.h:134
void handleCall(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts, NodeID rootTid)
Handle call.
Definition MHP.cpp:438
StateRepresentation
Definition MHP.h:79
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
Definition MHP.h:265
ThreadCallGraph * tcg
TCG.
Definition MHP.h:321
void addInterleavingThread(const CxtThreadStmt &tgr, NodeID tid)
Add/Remove interleaving thread for statement inst.
Definition MHP.h:203
const NodeBS & getInterleavingThreads(const CxtThreadStmt &cts)
Get interleaving thread for statement inst.
Definition MHP.h:130
InstToThreadStmtSetMap instToTSMap
Map an instruction to its ThreadStmtSet.
Definition MHP.h:328
virtual ~MHP()
Destructor.
Definition MHP.cpp:105
void addInterleavingThread(const CxtThreadStmt &tgr, const CxtThreadStmt &src)
Definition MHP.h:211
bool isHBPair(NodeID tid1, NodeID tid2)
Whether thread t1 happens before t2 based on ForkJoin Analysis.
Definition MHP.cpp:754
ThreadCallGraph * getThreadCallGraph() const
Get ThreadCallGraph.
Definition MHP.h:104
ThreadStmtToThreadInterleav threadStmtToThreadInterLeav
Definition MHP.h:325
bool isTDFork(const ICFGNode *call)
Whether it is a fork site.
Definition MHP.h:297
void addInterleavingBits(const CxtThreadStmt &tgr, const NodeBS &bits)
Definition MHP.h:220
virtual bool executedByTheSameThread(const ICFGNode *i1, const ICFGNode *i2)
Definition MHP.cpp:866
Map< const SVFBasicBlock *, std::vector< CxtStmt > > BBToSymJoinsMap
Definition MHP.h:195
InstToThreadSummaryMap instToThreadSummary
Exact per-node/per-tid query compression.
Definition MHP.h:329
virtual bool mayHappenInParallel(const ICFGNode *i1, const ICFGNode *i2)
Interface to query whether two instructions may happen-in-parallel.
Definition MHP.cpp:854
void buildSymJoinKillTables()
Definition MHP.cpp:60
const CxtThreadStmtSet & getThreadStmtSet(const ICFGNode *inst) const
Get/has ThreadStmt.
Definition MHP.h:142
const LoopBBs & getJoinInSymmetricLoop(const CallStrCxt &cxt, const ICFGNode *call) const
Whether a context-sensitive join satisfies symmetric loop pattern.
Definition MHP.cpp:745
void handleJoin(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts, NodeID rootTid)
Handle join.
Definition MHP.cpp:374
Map< const ICFGNode *, CxtThreadStmtSet > InstToThreadStmtSetMap
Definition MHP.h:59
ForkJoinAnalysis * fja
ForJoin Analysis.
Definition MHP.h:323
const NodeThreadSummary * getThreadSummary(const ICFGNode *inst) const
Definition MHP.cpp:257
bool hasJoinInSymmetricLoop(const CallStrCxt &cxt, const ICFGNode *call) const
Whether a context-sensitive join satisfies symmetric loop pattern.
Definition MHP.cpp:738
void buildQuerySummaries(ICFGGraph icfg, CGGraph cg)
Definition MHP.cpp:201
bool hasThreadStmtSet(const ICFGNode *inst) const
Definition MHP.h:148
SymJoinToLoopMap symJoinLoop
symmetric in-loop join -> its loop's blocks
Definition MHP.h:327
StateRepresentation stateRepresentation
Definition MHP.h:331
static std::unique_ptr< MHP > create(TCT *t, ICFGGraph icfg, CGGraph cg, StateRepresentation representation=StateRepresentation::MaterializedContexts)
Construct MHP and initialize its graph-dependent ForkJoinAnalysis.
Definition MHP.h:646
double interleavingQueriesTime
Definition MHP.h:338
u32_t numOfMHPQueries
Number of queries are answered as may-happen-in-parallel.
Definition MHP.h:336
void updateNonCandidateFunInterleaving(ICFGGraph icfg, CGGraph cg)
Definition MHP.cpp:275
Map< CxtThreadStmt, NodeBS > ThreadStmtToThreadInterleav
Definition MHP.h:58
Map< CxtStmt, Set< const SVFBasicBlock * > > SymJoinToLoopMap
Definition MHP.h:196
bool isMustJoin(const NodeID curTid, const ICFGNode *joinsite)
Whether a join site must join a thread t.
Definition MHP.cpp:719
double interleavingTime
Definition MHP.h:337
Map< const ICFGNode *, const ICFGNode * > querySummaryOwner
Non-candidate node -> entry summary.
Definition MHP.h:330
bool isConnectedfromMain(const FunObjVar *fun)
Whether the function is connected from main function in thread call graph.
Definition MHP.cpp:759
void handleIntra(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts)
Handle intra.
Definition MHP.cpp:585
CxtThreadStmt popFromCTSWorkList()
Definition MHP.h:290
void handleNonCandidateFun(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts)
Handle non-candidate function.
Definition MHP.cpp:316
Map< FuncPair, bool > FuncPairToBool
Definition MHP.h:76
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:729
virtual bool mayHappenInParallelInst(const ICFGNode *i1, const ICFGNode *i2)
Definition MHP.cpp:794
FIFOWorkList< CxtThreadStmt > CxtThreadStmtWorkList
Definition MHP.h:56
bool pushToCTSWorkList(const CxtThreadStmt &cs)
WorkList helper functions.
Definition MHP.h:286
TCT * getTCT() const
Get Thread Creation Tree.
Definition MHP.h:110
bool isTDJoin(const ICFGNode *call)
Whether it is a join site.
Definition MHP.h:303
void set(unsigned Idx)
iterator begin() const
bool isMultiforked() const
Definition TCT.h:122
TCTNode * getTCTNode(NodeID id) const
Get TCT node.
Definition TCT.h:209
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt &call)
If lhs is a suffix of rhs, including equal.
Definition TCT.cpp:531
bool hasJoinLoop(const CallICFGNode *join) const
Definition TCT.h:404
ThreadCallGraph * getThreadCallGraph() const
Get TCG.
Definition TCT.h:199
bool isCandidateFun(const CallGraph::FunctionSet &callees) const
Whether it is a candidate function for indirect call.
Definition TCT.h:294
std::vector< const ICFGNode * > InstVec
Definition TCT.h:174
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
Definition TCT.cpp:503
LoopBBs & getJoinLoop(const CallICFGNode *join)
Get loop for join site.
Definition TCT.h:396
virtual void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
Definition TCT.cpp:483
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
Map< NodeID, NodeBS > interleavingByTid
Definition MHP.h:68
If fork join the same thread.
Definition ThreadAPI.h:158