30#ifndef TCTNodeDetector_H_
31#define TCTNodeDetector_H_
167 if (
lhs ==
nullptr ||
rhs ==
nullptr)
168 return lhs ==
nullptr &&
rhs !=
nullptr;
169 return lhs->getId() <
rhs->getId();
263 if(
const CallICFGNode* call = SVFUtil::dyn_cast<CallICFGNode>(inst))
270 return SVFUtil::isa<CallICFGNode>(inst);
290 for(CallGraph::FunctionSet::const_iterator
cit =
callees.begin(),
340 while(!worklist.
empty())
343 if(
tds.test_and_set(t))
479 virtual void build();
546 it->second->setMultiforked(
true);
566 if(
ct.getThread() !=
nullptr &&
577 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.
IDToNodeMapTy IDToNodeMap
node map
NodeType * getGNode(NodeID id) const
Get a node.
void destroy()
Release memory.
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.
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.
OrderedSet< const FunObjVar *, FunObjVarIdCmp > FunSet
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
virtual void collectLoopInfoForJoin()
Handle join site in loop.
bool isCallSite(const ICFGNode *inst)
Whether it is a callsite.
ThreadCallGraphSCC * tcgSCC
Procedures we care about during call graph traversing when creating TCT.
virtual 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.
ICFGNode * createDummyForkSite()
Create and get a new dummy fork site for starter routines.
Map< CxtThread, const FunObjVar * > CxtThreadToFun
ThreadCallGraph * getThreadCallGraph() const
Get TCG.
DummyForkSiteSet dummyForkSites
set of dummy fork sites for starter routines
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
virtual ~TCT()
Destructor.
ThreadCreateEdgeSet::iterator TCTNodeIter
NodeID dummyForkICFGNodeID
unique ID generator for dummy
bool addCxtOfCxtThread(NodeID pTid, const CallStrCxt &cxt, const CxtThread &ct)
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.
virtual void markRelProcs()
Mark relevant procedures that are backward reachable from any fork/join site.
Set< const ICFGNode * > inRecurJoinSites
Fork or Join sites in recursions.
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.
virtual void build()
Build TCT.
void print() const
Print TCT information.
virtual 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
CxtThreadProc popFromCTPWorkList()
TCTEdge * hasGraphEdge(TCTNode *src, TCTNode *dst, TCTEdge::CEDGEK kind) const
Whether we have already created this call graph edge.
Set< const ICFGNode * > DummyForkSiteSet
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.
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
virtual 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.
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
bool operator()(const FunObjVar *lhs, const FunObjVar *rhs) const