30#ifndef TCTNodeDetector_H_
31#define TCTNodeDetector_H_
177 assert(
tcg !=
nullptr &&
"TCT::TCT: call graph is not a ThreadCallGraph!");
260 if(
const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst))
267 return SVFUtil::isa<CallICFGNode>(inst);
287 for(CallGraph::FunctionSet::const_iterator
cit =
callees.begin(),
337 while(!worklist.
empty())
340 if(
tds.test_and_set(t))
535 if(
ct.getThread() !=
nullptr)
545 ct.setIncycle(
false);
Set< const FunObjVar * > FunctionSet
bool push(const Data &data)
bool hasLoopInfo(const SVFBasicBlock *bb) const
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.
CallGraph * getCallGraph() const
Return call graph.
CallGraphSCC * getCallGraphSCC() const
Return call graph SCC.
const FunObjVar * getFunction() const
NodeID getId() const
Get ID.
GNodeK getNodeKind() const
Get node kind.
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 thread creation context, <fork site, call string context>
void setMultiforked(bool value)
bool multiforked
Thread creation context, <fork site, call string context>
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 SVFValue *node)
static bool classof(const GenericTCTNodeTy *node)
TCTNode(NodeID i, const CxtThread &cctx)
Constructor.
bool pushToCTPWorkList(const CxtThreadProc &ctp)
WorkList helper functions.
const FunSet & getMakredProcs() const
Get marked candidate functions.
const NodeBS getAncestorThreads(NodeID tid) const
Get all ancestor threads.
bool isInRecursion(const ICFGNode *inst) const
Whether an instruction is in a recursion.
CxtThreadToForkCxtSet ctToForkCxtsMap
Map a ctp to its graph node.
TCTNode * getTCTNode(NodeID id) const
Get TCT node.
Set< CxtThreadProc > CxtThreadProcSet
CxtThreadToNodeMap ctpToNodeMap
Record all visited ctps.
bool isContextSuffix(const CallStrCxt &lhs, const CallStrCxt &call)
If lhs is a suffix of rhs, including equal.
bool isCandidateFun(const FunObjVar *fun) const
Set< const ICFGNode * > InstSet
void setMultiForkedAttrs(CxtThread &ct)
Set multi-forked thread attributes.
TCTNode * getOrCreateTCTNode(const CallStrCxt &cxt, const ICFGNode *fork, const CxtThreadProc &forkSiteCtp, const FunObjVar *routine)
Get or create a tct node based on CxtThread.
bool isJoinSiteInRecursion(const CallICFGNode *join) const
Whether a join site is in recursion.
FIFOWorkList< CxtThreadProc > CxtThreadProcVec
void collectLoopInfoForJoin()
Handle join site in loop.
bool isCallSite(const ICFGNode *inst)
Whether it is a callsite.
void addCxtOfCxtThread(NodeID pTid, const CallStrCxt &cxt, const CxtThread &ct)
Add context for a thread at its spawning site (fork site)
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.
NodeBS getParentThreads(NodeID tid) const
Get parent threads.
CxtThreadToFun ctToRoutineFunMap
Map a CxtThread to the context at its spawning site (fork site).
PointerAnalysis * getPTA() const
Get PTA.
CxtThreadProcSet visitedCTPs
CxtThreadProc List.
bool hasJoinLoop(const CallICFGNode *join) const
u32_t getMaxCxtSize() const
Set< const CallGraphNode * > PTACGNodeSet
ThreadCreateEdgeSet::const_iterator getChildrenBegin(const TCTNode *node) const
Get children and parent nodes.
Map< CxtThread, const FunObjVar * > CxtThreadToFun
ThreadCallGraph * getThreadCallGraph() const
Get TCG.
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.
FunSet candidateFuncSet
Procedures that are neither called by other functions nor extern functions.
void addStartRoutineOfCxtThread(const FunObjVar *fun, const CxtThread &ct)
Add start routine function of a cxt thread.
bool inSameCallGraphSCC(const CallGraphNode *src, const CallGraphNode *dst)
Whether two functions in the same callgraph scc.
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.
bool isCandidateFun(const CallGraph::FunctionSet &callees) const
Whether it is a candidate function for indirect call.
CxtThreadProcVec ctpList
Thread call graph SCC.
std::vector< const ICFGNode * > InstVec
SCCDetection< CallGraph * > ThreadCallGraphSCC
bool matchAndPopCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Match context.
Map< CxtThread, CallStrCxtSet > CxtThreadToForkCxtSet
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.
Set< const ICFGNode * > inRecurJoinSites
Fork or Join sites in recursions.
TCT(PointerAnalysis *p)
Constructor.
LoopBBs & getJoinLoop(const CallICFGNode *join)
Get loop for join site.
TCTNode * getTCTNode(const CxtThread &ct) const
void dumpCxt(CallStrCxt &cxt)
Dump calling context.
bool addTCTEdge(TCTNode *src, TCTNode *dst)
Add TCT edge.
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.
void handleCallRelation(CxtThreadProc &ctp, const CallGraphEdge *cgEdge, const CallICFGNode *call)
Handle call relations.
Map< const ICFGNode *, LoopBBs > InstToLoopMap
void collectMultiForkedThreads()
Set< std::pair< NodeID, CallStrCxt > > CallStrCxtSet
Set< const FunObjVar * > FunSet
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.
SVFLoopAndDomInfo::LoopBBs LoopBBs
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
void pushCxt(CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
Context helper functions.
Map< CxtThread, TCTNode * > CxtThreadToNodeMap
const FunObjVar * getStartRoutineOfCxtThread(const CxtThread &ct) const
get the start routine function of a thread
const CallStrCxtSet & getCxtOfCxtThread(const CxtThread &ct) const
get the contexts of a thread at its spawning sites (fork sites)
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 FunObjVar *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