30#ifndef TCTNodeDetector_H_
31#define TCTNodeDetector_H_
112 return ctx.isInloop();
116 return ctx.isIncycle();
168 if (lhs ==
nullptr || rhs ==
nullptr)
169 return lhs ==
nullptr && rhs !=
nullptr;
287 CxtThreadToNodeMap::const_iterator it =
ctpToNodeMap.find(ct);
288 assert(it!=
ctpToNodeMap.end() &&
"TCT node not found??");
296 for(CallGraph::FunctionSet::const_iterator cit = callees.begin(),
297 ecit = callees.end(); cit!=ecit; cit++)
327 assert(node->
getInEdges().size()>=1 &&
"does not have a parent thread");
331 parentTds.
set(edge->getSrcID());
344 worklist.
push(parentTid);
346 while(!worklist.
empty())
353 worklist.
push(parentTid);
398 assert(
tcg->getThreadAPI()->isTDJoin(join) &&
"not a join site");
406 assert(
tcg->getThreadAPI()->isTDJoin(join) &&
"not a join site");
440 assert(
tcg->getThreadAPI()->isTDJoin(join) &&
"not a join site");
447 void dump(
const std::string& filename);
490 virtual void build();
531 CxtThreadToNodeMap::const_iterator it =
ctpToNodeMap.find(ct);
537 it->second->setMultiforked(
true);
590 return dummyForkSite;
NodeID getId() const
Get the memory object id.
Set< const FunObjVar * > FunctionSet
const CallStrCxt & getContext() const
Return current context.
NodeID getTid() const
Return current thread id.
const ICFGNode * getThread() const
Return forksite.
void setInloop(bool in)
inloop, incycle attributes
bool push(const Data &data)
bool hasLoopInfo(const SVFBasicBlock *bb) const
GEdgeKind getEdgeKind() const
void addGNode(NodeID id, NodeType *node)
NodeType * getGNode(NodeID id) const
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.
bool test_and_set(unsigned Idx)
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
static std::unique_ptr< TCT > create(PointerAnalysis *p)
Construct and build a TCT with the command-line context bound.
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.
TCT(PointerAnalysis *p, u32_t contextLimit)
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)
LLVM_NODISCARD bool isa(const Y &Val)
bool isExtCall(const FunObjVar *fun)
std::ostream & outs()
Overwrite llvm::outs().
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
GenericEdge< TCTNode > GenericTCTEdgeTy
GenericNode< TCTNode, TCTEdge > GenericTCTNodeTy
std::set< Key, Compare, Allocator > OrderedSet
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
GenericGraph< TCTNode, TCTEdge > GenericThreadCreateTreeTy
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
std::vector< u32_t > CallStrCxt
bool operator()(const FunObjVar *lhs, const FunObjVar *rhs) const