47class ForkJoinAnalysis;
69 typedef std::pair<const FunObjVar*,const FunObjVar*>
FuncPair;
126 InstToThreadStmtSetMap::const_iterator it =
instToTSMap.find(inst);
363 CxtStmtToLoopMap::const_iterator it =
cxtJoinInLoop.find(cs);
369 CxtStmtToLoopMap::const_iterator it =
cxtJoinInLoop.find(cs);
void getCallees(const CallICFGNode *cs, FunctionSet &callees)
Get all callees for a callsite.
Set< const FunObjVar * > FunctionSet
bool push(const Data &data)
void addToFullJoin(NodeID tid1, NodeID tid2)
full join and partial join
const SVFVar * getForkedThread(const CallICFGNode *call)
Get forked thread.
void markCxtStmtFlag(const CxtStmt &tgr, const CxtStmt &src)
Transfer function for marking context-sensitive statement.
Map< CxtStmt, LoopBBs > CxtStmtToLoopMap
FIFOWorkList< CxtStmt > CxtStmtWorkList
bool isAliasedForkJoin(const CallICFGNode *forkSite, const CallICFGNode *joinSite)
Whether it is a matched fork join pair.
ValDomain getMarkedFlag(const CxtStmt &cs)
Mark thread flags for cxtStmt.
void addToHPPair(NodeID tid1, NodeID tid2)
SVFLoopAndDomInfo::LoopBBs LoopBBs
void analyzeForkJoinPair()
bool hasJoinLoop(const CallICFGNode *inst)
const CallGraph::FunctionSet & getCallee(const ICFGNode *inst, CallGraph::FunctionSet &callees)
void addSymmetricLoopJoin(const CxtStmt &cs, LoopBBs &lp)
Add inloop join.
void handleRet(const CxtStmt &cts)
Handle return.
NodeBS getDirAndIndJoinedTid(const CxtStmt &cs)
Get directly and indirectly joined threadIDs based on a context-sensitive join site.
ThreadPairSet partialJoin
t1 partially joins t2 along some program path(s)
ThreadPairSet fullJoin
t1 fully joins t2 along all program path
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
ThreadPairSet HPPair
threads happen-in-parallel
CxtStmt popFromCTSWorkList()
bool hasCxtStmtsFromInst(const ICFGNode *inst) const
CxtStmtToLoopMap cxtJoinInLoop
a set of context-sensitive join inside loop
void addToHBPair(NodeID tid1, NodeID tid2)
ThreadCallGraph * getTCG() const
ThreadCallGraph.
void addToPartial(NodeID tid1, NodeID tid2)
Map< const ICFGNode *, CxtStmtSet > InstToCxtStmt
Set< CxtStmt > CxtStmtSet
void collectSCEVInfo()
functions
void clearFlagMap()
Clear flags.
bool pushToCTSWorkList(const CxtStmt &cs)
Worklist operations.
Set< NodePair > ThreadPairSet
bool isHBPair(NodeID tid1, NodeID tid2)
Whether thread t1 happens-before thread t2.
void addDirectlyJoinTID(const CxtStmt &cs, NodeID tid)
maps a context-sensitive join site to a thread id
ValDomain
semilattice Empty==>TDDead==>TDAlive
const SVFVar * getJoinedThread(const CallICFGNode *call)
Get joined thread.
Map< CxtStmt, NodeBS > CxtStmtToTIDMap
LoopBBs & getJoinLoop(const CallICFGNode *inst)
Get loop for join site.
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
CxtStmtToAliveFlagMap cxtStmtToAliveFlagMap
flags for context-sensitive statements
const CxtStmtToLoopMap & getSymmetricLoopJoins() const
All SCEV-symmetric in-loop joins and their loop blocks.
bool isTDFork(const ICFGNode *call)
Whether it is a fork site.
ThreadPairSet HBPair
thread happens-before pair
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt call)
If lhs is a suffix of rhs, including equal.
bool isFullJoin(NodeID tid1, NodeID tid2)
Whether t1 fully joins t2.
CxtStmtToTIDMap dirAndIndJoinMap
maps a context-sensitive join site to directly and indirectly joined thread ids
void handleCall(const CxtStmt &cts, NodeID rootTid)
Handle call.
bool hasJoinInSymmetricLoop(const CxtStmt &cs) const
InstToCxtStmt instToCxtStmt
Map a statement to all its context-sensitive statements.
CxtStmtToTIDMap directJoinMap
maps a context-sensitive join site to directly joined thread ids
bool sameLoopTripCount(const ICFGNode *forkSite, const ICFGNode *joinSite)
Same loop trip count.
bool isTDJoin(const ICFGNode *call)
Whether it is a join site.
void markCxtStmtFlag(const CxtStmt &tgr, ValDomain flag)
Initialize TDAlive and TDDead flags.
CxtStmtWorkList cxtStmtList
context-sensitive statement worklist
Map< CxtStmt, ValDomain > CxtStmtToAliveFlagMap
const LoopBBs & getJoinInSymmetricLoop(const CxtStmt &cs) const
Whether a context-sensitive join satisfies symmetric loop pattern.
ThreadAPI::ForkJoinAliasCache forkJoinAliasCache
void handleIntra(const CxtStmt &cts)
Handle intra.
void handleFork(const CxtStmt &cts, NodeID rootTid)
Handle fork.
NodeBS & getDirectlyJoinedTid(const CxtStmt &cs)
Get directly joined threadIDs based on a context-sensitive join site.
void handleJoin(const CxtStmt &cts, NodeID rootTid)
Handle join.
bool isSameSCEV(const ICFGNode *forkSite, const ICFGNode *joinSite)
Return true if the fork and join have the same SCEV.
const CxtStmtSet & getCxtStmtsFromInst(const ICFGNode *inst) const
Get CxtStmtSet for an instruction.
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
CxtThreadStmtWorkList cxtStmtList
CxtThreadStmt worklist.
bool isRecurFullJoin(NodeID parentTid, NodeID curTid)
Thread curTid can be fully joined by parentTid recursively.
bool isMultiForkedThread(NodeID curTid)
A thread is a multiForked thread if it is in a loop or recursion.
void handleRet(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts)
Handle return.
void rmInterleavingThread(const CxtThreadStmt &tgr, const NodeBS &tids, const ICFGNode *joinsite)
virtual bool mayHappenInParallelCache(const ICFGNode *i1, const ICFGNode *i2)
void analyze(ICFGGraph icfg, CGGraph cg)
BBToSymJoinsMap bbToSymJoins
Map a statement to its thread interleavings.
FuncPairToBool nonCandidateFuncMHPRelMap
NodeBS edgeFlow(const CxtThreadStmt &cts, const ICFGNode *dst)
void printInterleaving()
Print interleaving results.
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
u32_t numOfTotalQueries
Total number of queries.
Set< CxtThreadStmt > CxtThreadStmtSet
void analyzeInterleaving(ICFGGraph icfg, CGGraph cg)
Analyze thread interleaving.
std::pair< const FunObjVar *, const FunObjVar * > FuncPair
SVFLoopAndDomInfo::LoopBBs LoopBBs
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt call)
If lhs is a suffix of rhs, including equal.
void updateSiblingThreads(ICFGGraph icfg, CGGraph cg, NodeID tid)
void handleFork(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts, NodeID rootTid)
Handle fork.
Set< const FunObjVar * > FunSet
void updateAncestorThreads(ICFGGraph icfg, CGGraph cg, NodeID tid)
Update Ancestor and sibling threads.
bool hasInterleavingThreads(const CxtThreadStmt &cts) const
void handleCall(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts, NodeID rootTid)
Handle call.
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
ThreadCallGraph * tcg
TCG.
void addInterleavingThread(const CxtThreadStmt &tgr, NodeID tid)
Add/Remove interleaving thread for statement inst.
const NodeBS & getInterleavingThreads(const CxtThreadStmt &cts)
Get interleaving thread for statement inst.
InstToThreadStmtSetMap instToTSMap
Map an instruction to its ThreadStmtSet.
virtual ~MHP()
Destructor.
void addInterleavingThread(const CxtThreadStmt &tgr, const CxtThreadStmt &src)
bool isHBPair(NodeID tid1, NodeID tid2)
Whether thread t1 happens before t2 based on ForkJoin Analysis.
ThreadCallGraph * getThreadCallGraph() const
Get ThreadCallGraph.
ThreadStmtToThreadInterleav threadStmtToThreadInterLeav
bool isTDFork(const ICFGNode *call)
Whether it is a fork site.
void addInterleavingBits(const CxtThreadStmt &tgr, const NodeBS &bits)
virtual bool executedByTheSameThread(const ICFGNode *i1, const ICFGNode *i2)
Map< const SVFBasicBlock *, std::vector< CxtStmt > > BBToSymJoinsMap
virtual bool mayHappenInParallel(const ICFGNode *i1, const ICFGNode *i2)
Interface to query whether two instructions may happen-in-parallel.
void buildSymJoinKillTables()
const CxtThreadStmtSet & getThreadStmtSet(const ICFGNode *inst) const
Get/has ThreadStmt.
const LoopBBs & getJoinInSymmetricLoop(const CallStrCxt &cxt, const ICFGNode *call) const
Whether a context-sensitive join satisfies symmetric loop pattern.
void handleJoin(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts, NodeID rootTid)
Handle join.
Map< const ICFGNode *, CxtThreadStmtSet > InstToThreadStmtSetMap
ForkJoinAnalysis * fja
ForJoin Analysis.
bool hasJoinInSymmetricLoop(const CallStrCxt &cxt, const ICFGNode *call) const
Whether a context-sensitive join satisfies symmetric loop pattern.
const CallGraph::FunctionSet & getCallee(const CallICFGNode *inst, CallGraph::FunctionSet &callees)
bool hasThreadStmtSet(const ICFGNode *inst) const
SymJoinToLoopMap symJoinLoop
symmetric in-loop join -> its loop's blocks
double interleavingQueriesTime
u32_t numOfMHPQueries
Number of queries are answered as may-happen-in-parallel.
void updateNonCandidateFunInterleaving(ICFGGraph icfg, CGGraph cg)
Map< CxtThreadStmt, NodeBS > ThreadStmtToThreadInterleav
Map< CxtStmt, Set< const SVFBasicBlock * > > SymJoinToLoopMap
bool isMustJoin(const NodeID curTid, const ICFGNode *joinsite)
Whether a join site must join a thread t.
bool isConnectedfromMain(const FunObjVar *fun)
Whether the function is connected from main function in thread call graph.
void handleIntra(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts)
Handle intra.
CxtThreadStmt popFromCTSWorkList()
void handleNonCandidateFun(ICFGGraph icfg, CGGraph cg, const CxtThreadStmt &cts)
Handle non-candidate function.
Map< FuncPair, bool > FuncPairToBool
NodeBS getDirAndIndJoinedTid(const CallStrCxt &cxt, const ICFGNode *call)
Return thread id(s) which are directly or indirectly joined at this join site.
virtual bool mayHappenInParallelInst(const ICFGNode *i1, const ICFGNode *i2)
FIFOWorkList< CxtThreadStmt > CxtThreadStmtWorkList
bool pushToCTSWorkList(const CxtThreadStmt &cs)
WorkList helper functions.
TCT * getTCT() const
Get Thread Creation Tree.
bool isTDJoin(const ICFGNode *call)
Whether it is a join site.
bool isMultiforked() const
TCTNode * getTCTNode(NodeID id) const
Get TCT node.
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt &call)
If lhs is a suffix of rhs, including equal.
bool hasJoinLoop(const CallICFGNode *join) const
ThreadCallGraph * getThreadCallGraph() const
Get TCG.
bool isCandidateFun(const CallGraph::FunctionSet &callees) const
Whether it is a candidate function for indirect call.
std::vector< const ICFGNode * > InstVec
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
LoopBBs & getJoinLoop(const CallICFGNode *join)
Get loop for join site.
virtual void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
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.
llvm::IRBuilder IRBuilder
std::vector< u32_t > CallStrCxt
If fork join the same thread.