30#ifndef TCTNodeDetector_H_
31#define TCTNodeDetector_H_
266 if(
const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst))
273 return SVFUtil::isa<CallICFGNode>(inst);
293 for(PTACallGraph::FunctionSet::const_iterator
cit =
callees.begin(),
323 assert(node->
getInEdges().size()<=1 &&
"should have at most one parent thread");
338 while(!worklist.
empty())
341 if(
tds.test_and_set(t))
534 if(
ct.getThread() !=
nullptr)
544 ct.setIncycle(
false);
bool push(const Data &data)
NodeID getSrcID() const
get methods of the components
void addGNode(NodeID id, NodeType *node)
Add a Node.
NodeType * getGNode(NodeID id) const
Get a node.
OrderedSet< EdgeType *, typename EdgeType::equalGEdge > GEdgeSetTy
Edge kind.
const GEdgeSetTy & getInEdges() const
bool addIncomingEdge(EdgeType *inEdge)
Add incoming and outgoing edges.
iterator OutEdgeBegin()
iterators
bool addOutgoingEdge(EdgeType *outEdge)
virtual const SVFBasicBlock * getBB() const
Return the basic block of this ICFGNode.
Set< const SVFFunction * > FunctionSet
PTACallGraph * getCallGraph() const
Return call graph.
SVFModule * getModule() const
Module.
CallGraphSCC * getCallGraphSCC() const
Return call graph SCC.
GNodeK getNodeKind() const
Get node kind.
NodeID getId() const
Get ID.
const SVFFunction * getFunction() const
bool hasLoopInfo(const SVFBasicBlock *bb) const
static bool classof(const GenericTCTEdgeTy *edge)
GenericNode< TCTNode, TCTEdge >::GEdgeSetTy ThreadCreateEdgeSet
TCTEdge(TCTNode *s, TCTNode *d, CEDGEK kind)
Constructor.
static bool classof(const TCTEdge *)
Classof.
virtual ~TCTEdge()
Destructor.
const CxtThread & getCxtThread() const
Get CxtThread.
void setMultiforked(bool value)
static bool classof(const SVFBaseNode *node)
bool isInloop() const
inloop, incycle attributes
bool isMultiforked() const
static bool classof(const TCTNode *)
Methods for support type inquiry through isa, cast, and dyn_cast:
static bool classof(const GenericTCTNodeTy *node)
TCTNode(NodeID i, const CxtThread &cctx)
Constructor.
bool pushToCTPWorkList(const CxtThreadProc &ctp)
WorkList helper functions.
bool isCandidateFun(const SVFFunction *fun) const
const FunSet & getMakredProcs() const
Get marked candidate functions.
bool isInRecursion(const ICFGNode *inst) const
Whether an instruction is in a recursion.
TCTNode * getTCTNode(NodeID id) const
Get TCT node.
Set< CxtThreadProc > CxtThreadProcSet
CxtThreadToNodeMap ctpToNodeMap
Record all visited ctps.
Map< CxtThread, const SVFFunction * > CxtThreadToFun
Set< const ICFGNode * > InstSet
void setMultiForkedAttrs(CxtThread &ct)
Set multi-forked thread attributes.
bool isJoinSiteInRecursion(const CallICFGNode *join) const
Whether a join site is in recursion.
const SVFFunction * getStartRoutineOfCxtThread(const CxtThread &ct) const
get the start routine function of a thread
FIFOWorkList< CxtThreadProc > CxtThreadProcVec
void collectLoopInfoForJoin()
Handle join site in loop.
void addCxtOfCxtThread(const CallStrCxt &cxt, const CxtThread &ct)
Add context for a thread at its spawning site (fork site)
bool isCallSite(const ICFGNode *inst)
Whether it is a callsite.
ThreadCallGraphSCC * tcgSCC
Procedures we care about during call graph traversing when creating TCT.
void collectEntryFunInCallGraph()
Get entry functions that are neither called by other functions nor extern functions.
Map< CxtThread, CallStrCxt > CxtThreadToForkCxt
CxtThreadToFun ctToRoutineFunMap
Map a CxtThread to the context at its spawning site (fork site).
PointerAnalysis * getPTA() const
Get PTA.
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Push calling context.
CxtThreadProcSet visitedCTPs
CxtThreadProc List.
bool hasJoinLoop(const CallICFGNode *join) const
u32_t getMaxCxtSize() const
Set< const SVFFunction * > FunSet
ThreadCreateEdgeSet::const_iterator getChildrenBegin(const TCTNode *node) const
Get children and parent nodes.
NodeID getParentThread(NodeID tid) const
Get parent thread.
ThreadCallGraph * getThreadCallGraph() const
Get TCG.
void addStartRoutineOfCxtThread(const SVFFunction *fun, const CxtThread &ct)
Add start routine function of a cxt thread.
bool hasLoop(const ICFGNode *inst) const
InstToLoopMap joinSiteToLoopMap
Map a CxtThread to its start routine function.
bool hasTCTNode(const CxtThread &ct) const
Find/Get TCT node.
ThreadCreateEdgeSet::const_iterator getParentsEnd(const TCTNode *node) const
const NodeBS getSiblingThread(NodeID tid) const
Get sibling threads.
bool hasParentThread(NodeID tid) const
Get parent and sibling threads.
bool isVisitedCTPs(const CxtThreadProc &ctp) const
u32_t getTCTEdgeNum() const
ThreadCreateEdgeSet::iterator TCTNodeIter
void dump(const std::string &filename)
Dump the graph.
SCCDetection< PTACallGraph * > ThreadCallGraphSCC
FunSet candidateFuncSet
Procedures that are neither called by other functions nor extern functions.
SVFModule * getSVFModule() const
Get SVFFModule.
bool hasLoop(const SVFBasicBlock *bb) const
TCTEdge * getGraphEdge(TCTNode *src, TCTNode *dst, TCTEdge::CEDGEK kind)
Get call graph edge via nodes.
TCTEdge::ThreadCreateEdgeSet ThreadCreateEdgeSet
TCTNode * addTCTNode(const CxtThread &ct)
Add TCT node.
CxtThreadProcVec ctpList
Thread call graph SCC.
std::vector< const ICFGNode * > InstVec
bool isInLoopInstruction(const ICFGNode *inst)
Multi-forked threads.
bool isJoinMustExecutedInLoop(const LoopBBs &lp, const ICFGNode *join)
Return true if a join instruction must be executed inside a loop.
void markRelProcs()
Mark relevant procedures that are backward reachable from any fork/join site.
const CallStrCxt & getCxtOfCxtThread(const CxtThread &ct) const
get the context of a thread at its spawning site (fork site)
Set< const ICFGNode * > inRecurJoinSites
Fork or Join sites in recursions.
TCT(PointerAnalysis *p)
Constructor.
void handleCallRelation(CxtThreadProc &ctp, const PTACallGraphEdge *cgEdge, const CallICFGNode *call)
Handle call relations.
LoopBBs & getJoinLoop(const CallICFGNode *join)
Get loop for join site.
bool inSameCallGraphSCC(const PTACallGraphNode *src, const PTACallGraphNode *dst)
Whether two functions in the same callgraph scc.
TCTNode * getOrCreateTCTNode(const CallStrCxt &cxt, const ICFGNode *fork, const CallStrCxt &oldCxt, const SVFFunction *routine)
Get or create a tct node based on CxtThread.
TCTNode * getTCTNode(const CxtThread &ct) const
void destroy()
Clean up memory.
bool matchCxt(CallStrCxt &cxt, const CallICFGNode *call, const SVFFunction *callee)
Match context.
bool isCandidateFun(const PTACallGraph::FunctionSet &callees) const
Whether it is a candidate function for indirect call.
void dumpCxt(CallStrCxt &cxt)
Dump calling context.
bool addTCTEdge(TCTNode *src, TCTNode *dst)
Add TCT edge.
void pushCxt(CallStrCxt &cxt, CallSiteID csId)
const FunSet & getEntryProcs() const
Get marked candidate functions.
bool isLoopHeaderOfJoinLoop(const SVFBasicBlock *bb)
Whether a given bb is a loop head of a inloop join site.
void print() const
Print TCT information.
Map< const ICFGNode *, LoopBBs > InstToLoopMap
void collectMultiForkedThreads()
CxtThreadProc popFromCTPWorkList()
TCTEdge * hasGraphEdge(TCTNode *src, TCTNode *dst, TCTEdge::CEDGEK kind) const
Whether we have already created this call graph edge.
bool isLoopExitOfJoinLoop(const SVFBasicBlock *bb)
Whether a given bb is an exit of a inloop join site.
CxtThreadToForkCxt ctToForkCxtMap
Map a ctp to its graph node.
SVFLoopAndDomInfo::LoopBBs LoopBBs
const NodeBS getAncestorThread(NodeID tid) const
Get all ancestor threads.
bool isExtCall(const ICFGNode *inst)
Whether it is calling an external function.
virtual ~TCT()
Destructor.
u32_t getTCTNodeNum() const
Get Statistics.
const LoopBBs & getLoop(const ICFGNode *inst)
Get loop for an instruction.
ThreadCreateEdgeSet::const_iterator getChildrenEnd(const TCTNode *node) const
ThreadCreateEdgeSet::const_iterator getParentsBegin(const TCTNode *node) const
Set< const PTACallGraphNode * > PTACGNodeSet
Map< CxtThread, TCTNode * > CxtThreadToNodeMap
bool isTDJoin(const CallICFGNode *inst) const
Return true if this call wait for a worker thread.
ThreadAPI * getThreadAPI() const
Thread API.
void updateCallGraph(PointerAnalysis *pta)
Update call graph using pointer results.
bool isExtCall(const SVFFunction *fun)
std::ostream & outs()
Overwrite llvm::outs()
GenericEdge< TCTNode > GenericTCTEdgeTy
GenericNode< TCTNode, TCTEdge > GenericTCTNodeTy
GenericGraph< TCTNode, TCTEdge > GenericThreadCreateTreeTy
llvm::IRBuilder IRBuilder
std::vector< u32_t > CallStrCxt