Static Value-Flow Analysis
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
SVF::SlicedTCT Class Reference

#include <MTASlicer.h>

Inheritance diagram for SVF::SlicedTCT:
SVF::TCT SVF::GenericGraph< NodeTy, EdgeTy >

Public Member Functions

 SlicedTCT (PointerAnalysis *p, const SlicedSVFIRView *slicedView, u32_t maxContextLen=0)
 
 ~SlicedTCT () override=default
 
void pushCxt (CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee) override
 Override pushCxt to use the custom maxContextLen.
 
- Public Member Functions inherited from SVF::TCT
 TCT (PointerAnalysis *p)
 Constructor.
 
virtual ~TCT ()
 Destructor.
 
ThreadCallGraphgetThreadCallGraph () const
 Get TCG.
 
PointerAnalysisgetPTA () const
 Get PTA.
 
TCTNodegetTCTNode (NodeID id) const
 Get TCT node.
 
TCTEdgehasGraphEdge (TCTNode *src, TCTNode *dst, TCTEdge::CEDGEK kind) const
 Whether we have already created this call graph edge.
 
TCTEdgegetGraphEdge (TCTNode *src, TCTNode *dst, TCTEdge::CEDGEK kind)
 Get call graph edge via nodes.
 
ThreadCreateEdgeSet::const_iterator getChildrenBegin (const TCTNode *node) const
 Get children and parent nodes.
 
ThreadCreateEdgeSet::const_iterator getChildrenEnd (const TCTNode *node) const
 
ThreadCreateEdgeSet::const_iterator getParentsBegin (const TCTNode *node) const
 
ThreadCreateEdgeSet::const_iterator getParentsEnd (const TCTNode *node) const
 
const FunSetgetMakredProcs () const
 Get marked candidate functions.
 
const FunSetgetEntryProcs () const
 Get marked candidate functions.
 
u32_t getTCTNodeNum () const
 Get Statistics.
 
u32_t getTCTEdgeNum () const
 
u32_t getMaxCxtSize () const
 
bool isExtCall (const ICFGNode *inst)
 Whether it is calling an external function.
 
bool isCallSite (const ICFGNode *inst)
 Whether it is a callsite.
 
bool hasTCTNode (const CxtThread &ct) const
 Find/Get TCT node.
 
TCTNodegetTCTNode (const CxtThread &ct) const
 
bool isCandidateFun (const CallGraph::FunctionSet &callees) const
 Whether it is a candidate function for indirect call.
 
bool isCandidateFun (const FunObjVar *fun) const
 
bool inSameCallGraphSCC (const CallGraphNode *src, const CallGraphNode *dst)
 Whether two functions in the same callgraph scc.
 
bool hasParentThread (NodeID tid) const
 Get parent and sibling threads.
 
NodeBS getParentThreads (NodeID tid) const
 Get parent threads.
 
const NodeBS getAncestorThreads (NodeID tid) const
 Get all ancestor threads.
 
const NodeBS getSiblingThread (NodeID tid) const
 Get sibling threads.
 
const CallStrCxtSetgetCxtOfCxtThread (const CxtThread &ct) const
 get the contexts of a thread at its spawning sites (fork sites)
 
const FunObjVargetStartRoutineOfCxtThread (const CxtThread &ct) const
 get the start routine function of a thread
 
LoopBBsgetJoinLoop (const CallICFGNode *join)
 Get loop for join site.
 
bool hasJoinLoop (const CallICFGNode *join) const
 
bool hasLoop (const SVFBasicBlock *bb) const
 
bool hasLoop (const ICFGNode *inst) const
 
bool isJoinMustExecutedInLoop (const LoopBBs &lp, const ICFGNode *join)
 Return true if a join instruction must be executed inside a loop.
 
const LoopBBsgetLoop (const ICFGNode *inst)
 Get loop for an instruction.
 
const LoopBBsgetLoop (const SVFBasicBlock *bb)
 Get loop for fork/join site.
 
bool matchAndPopCxt (CallStrCxt &cxt, const CallICFGNode *call, const FunObjVar *callee)
 Match context.
 
bool isContextSuffix (const CallStrCxt &lhs, const CallStrCxt &call)
 If lhs is a suffix of rhs, including equal.
 
bool isJoinSiteInRecursion (const CallICFGNode *join) const
 Whether a join site is in recursion.
 
void dumpCxt (CallStrCxt &cxt)
 Dump calling context.
 
void dump (const std::string &filename)
 Dump the graph.
 
void print () const
 Print TCT information.
 
- Public Member Functions inherited from SVF::GenericGraph< NodeTy, EdgeTy >
 GenericGraph ()
 Constructor.
 
virtual ~GenericGraph ()
 Destructor.
 
void destroy ()
 Release memory.
 
iterator begin ()
 Iterators.
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
void addGNode (NodeID id, NodeType *node)
 Add a Node.
 
NodeTypegetGNode (NodeID id) const
 Get a node.
 
bool hasGNode (NodeID id) const
 Has a node.
 
void removeGNode (NodeType *node)
 Delete a node.
 
u32_t getTotalNodeNum () const
 Get total number of node/edge.
 
u32_t getTotalEdgeNum () const
 
void incNodeNum ()
 Increase number of node/edge.
 
void incEdgeNum ()
 

Protected Member Functions

void build () override
 Build TCT.
 
void markRelProcs () override
 Mark relevant procedures that are backward reachable from any fork/join site.
 
void markRelProcs (const FunObjVar *fun) override
 
void collectLoopInfoForJoin () override
 Handle join site in loop.
 
void handleCallRelation (CxtThreadProc &ctp, const CallGraphEdge *cgEdge, const CallICFGNode *cs) override
 Handle call relations.
 
- Protected Member Functions inherited from SVF::TCT
TCTNodeaddTCTNode (const CxtThread &ct)
 Add TCT node.
 
bool addTCTEdge (TCTNode *src, TCTNode *dst)
 Add TCT edge.
 
void reset ()
 
void collectMultiForkedThreads ()
 
bool isLoopHeaderOfJoinLoop (const SVFBasicBlock *bb)
 Whether a given bb is a loop head of a inloop join site.
 
bool isLoopExitOfJoinLoop (const SVFBasicBlock *bb)
 Whether a given bb is an exit of a inloop join site.
 
bool isInLoopInstruction (const ICFGNode *inst)
 Multi-forked threads.
 
bool isInRecursion (const ICFGNode *inst) const
 Whether an instruction is in a recursion.
 
TCTNodegetOrCreateTCTNode (const CallStrCxt &cxt, const ICFGNode *fork, const CxtThreadProc &forkSiteCtp, const FunObjVar *routine)
 Get or create a tct node based on CxtThread.
 
void setMultiForkedAttrs (CxtThread &ct)
 Set multi-forked thread attributes.
 
bool addCxtOfCxtThread (NodeID pTid, const CallStrCxt &cxt, const CxtThread &ct)
 
void addStartRoutineOfCxtThread (const FunObjVar *fun, const CxtThread &ct)
 Add start routine function of a cxt thread.
 
ICFGNodecreateDummyForkSite ()
 Create and get a new dummy fork site for starter routines.
 
bool pushToCTPWorkList (const CxtThreadProc &ctp)
 WorkList helper functions.
 
CxtThreadProc popFromCTPWorkList ()
 
bool isVisitedCTPs (const CxtThreadProc &ctp) const
 

Private Member Functions

void collectEntryFunInCallGraph () override
 Get entry functions that are neither called by other functions nor extern functions.
 
bool isKeptNode (const CallGraphNode *node) const
 
bool isKeptEdge (const CallGraphEdge *edge) const
 
void getKeptForkSites (std::vector< const ICFGNode * > &out) const
 
void getKeptJoinSites (std::vector< const ICFGNode * > &out) const
 

Private Attributes

const SlicedThreadCallGraphViewtcgView
 
u32_t maxContextLen
 

Additional Inherited Members

- Public Types inherited from SVF::TCT
typedef SVFLoopAndDomInfo::LoopBBs LoopBBs
 
typedef TCTEdge::ThreadCreateEdgeSet ThreadCreateEdgeSet
 
typedef ThreadCreateEdgeSet::iterator TCTNodeIter
 
typedef OrderedSet< const FunObjVar *, FunObjVarIdCmpFunSet
 
typedef std::vector< const ICFGNode * > InstVec
 
typedef Set< const ICFGNode * > InstSet
 
typedef Set< const CallGraphNode * > PTACGNodeSet
 
typedef Map< CxtThread, TCTNode * > CxtThreadToNodeMap
 
typedef Set< std::pair< NodeID, CallStrCxt > > CallStrCxtSet
 
typedef Map< CxtThread, CallStrCxtSetCxtThreadToForkCxtSet
 
typedef Map< CxtThread, const FunObjVar * > CxtThreadToFun
 
typedef Map< const ICFGNode *, LoopBBsInstToLoopMap
 
typedef FIFOWorkList< CxtThreadProcCxtThreadProcVec
 
typedef Set< CxtThreadProcCxtThreadProcSet
 
typedef SCCDetection< CallGraph * > ThreadCallGraphSCC
 
typedef Set< const ICFGNode * > DummyForkSiteSet
 
- Public Types inherited from SVF::GenericGraph< NodeTy, EdgeTy >
typedef NodeTy NodeType
 
typedef EdgeTy EdgeType
 
typedef OrderedMap< NodeID, NodeType * > IDToNodeMapTy
 NodeID to GenericNode map.
 
typedef IDToNodeMapTy::iterator iterator
 Node Iterators.
 
typedef IDToNodeMapTy::const_iterator const_iterator
 
- Public Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
u32_t edgeNum
 total num of node
 
u32_t nodeNum
 total num of edge
 
- Protected Attributes inherited from SVF::TCT
ThreadCallGraphtcg
 
PointerAnalysispta
 
u32_t TCTNodeNum
 
u32_t TCTEdgeNum
 
u32_t MaxCxtSize
 
FunSet entryFuncSet
 
FunSet candidateFuncSet
 Procedures that are neither called by other functions nor extern functions.
 
ThreadCallGraphSCCtcgSCC
 Procedures we care about during call graph traversing when creating TCT.
 
CxtThreadProcVec ctpList
 Thread call graph SCC.
 
CxtThreadProcSet visitedCTPs
 CxtThreadProc List.
 
CxtThreadToNodeMap ctpToNodeMap
 Record all visited ctps.
 
CxtThreadToForkCxtSet ctToForkCxtsMap
 Map a ctp to its graph node.
 
CxtThreadToFun ctToRoutineFunMap
 Map a CxtThread to the context at its spawning site (fork site).
 
InstToLoopMap joinSiteToLoopMap
 Map a CxtThread to its start routine function.
 
Set< const ICFGNode * > inRecurJoinSites
 Fork or Join sites in recursions.
 
DummyForkSiteSet dummyForkSites
 set of dummy fork sites for starter routines
 
NodeID dummyForkICFGNodeID = UINT32_MAX
 unique ID generator for dummy
 
- Protected Attributes inherited from SVF::GenericGraph< NodeTy, EdgeTy >
IDToNodeMapTy IDToNodeMap
 node map
 

Detailed Description

Definition at line 80 of file MTASlicer.h.

Constructor & Destructor Documentation

◆ SlicedTCT()

SVF::SlicedTCT::SlicedTCT ( PointerAnalysis p,
const SlicedSVFIRView slicedView,
u32_t  maxContextLen = 0 
)
Parameters
pPointerAnalysis (the shared Andersen pre-analysis)
slicedViewSlicedSVFIRView containing a SlicedThreadCallGraphView
maxContextLenMax context length (0 = use Options::MaxContextLen())

Definition at line 66 of file MTASlicer.cpp.

67 : TCT(p),
68 tcgView(slicedView != nullptr && slicedView->getThreadCallGraph() != nullptr ? slicedView->getThreadCallGraph() : nullptr),
70{
71 // Base class TCT(p) constructor called build() before tcgView was initialized.
72 // Now that tcgView is initialized, rebuild using sliced view.
73 if (tcgView != nullptr)
74 {
75 build();
76 }
77}
cJSON * p
Definition cJSON.cpp:2559
const SlicedThreadCallGraphView * tcgView
Definition MTASlicer.h:103
u32_t maxContextLen
Definition MTASlicer.h:104
void build() override
Build TCT.
Definition MTASlicer.cpp:79
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~SlicedTCT()

SVF::SlicedTCT::~SlicedTCT ( )
overridedefault

Member Function Documentation

◆ build()

void SVF::SlicedTCT::build ( )
overrideprotectedvirtual

Build TCT.

Start building TCT

Reimplemented from SVF::TCT.

Definition at line 79 of file MTASlicer.cpp.

80{
81 if (tcgView == nullptr)
82 {
83 TCT::build();
84 return;
85 }
86
87 // The base TCT(p) constructor already built the whole-program TCT. Reset it to
88 // a clean graph so the slice rebuilds from scratch (addGNode reissues ids from
89 // 0; stale nodes left behind would later fail the MHP getCxtOfCxtThread lookup).
90 reset();
91
92 // Call base class build() which will call our overridden methods
93 // (markRelProcs, collectLoopInfoForJoin, collectEntryFunInCallGraph)
94 // that filter using sliced view, then build the TCT tree
95 TCT::build();
96}
virtual void build()
Build TCT.
Definition TCT.cpp:409
void reset()
Definition TCT.h:483

◆ collectEntryFunInCallGraph()

void SVF::SlicedTCT::collectEntryFunInCallGraph ( )
overrideprivatevirtual

Get entry functions that are neither called by other functions nor extern functions.

Get entry function, i.e., functions without callers, e.g., main function

Reimplemented from SVF::TCT.

Definition at line 203 of file MTASlicer.cpp.

204{
205 if (tcgView == nullptr)
206 {
208 return;
209 }
210
211 // Use sliced CallGraph view to collect entry functions
212 // Only collect functions that are kept in sliced view
214
215 for (const CallGraphNode* node : keptNodes)
216 {
217 const FunObjVar* fun = node->getFunction();
218 if (SVFUtil::isExtCall(fun))
219 continue;
220
221 // Check if this node has no incoming edges in the sliced view
222 std::vector<const CallGraphEdge*> inEdges;
224 if (inEdges.empty())
225 {
226 entryFuncSet.insert(fun);
227 }
228 }
229
230 assert(!getEntryProcs().empty() && "Can't find any function in module!");
231}
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
const OrderedSet< const CallGraphNode * > & getKeptNodes() const
Get all kept nodes.
void getInEdgesOf(const CallGraphNode *node, std::vector< const CallGraphEdge * > &out) const
Get in edges of a node (only returns kept edges and source nodes)
FunSet entryFuncSet
Definition TCT.h:624
virtual void collectEntryFunInCallGraph()
Get entry functions that are neither called by other functions nor extern functions.
Definition TCT.cpp:209
const FunSet & getEntryProcs() const
Get marked candidate functions.
Definition TCT.h:239
bool isExtCall(const FunObjVar *fun)
Definition SVFUtil.cpp:441

◆ collectLoopInfoForJoin()

void SVF::SlicedTCT::collectLoopInfoForJoin ( )
overrideprotectedvirtual

Handle join site in loop.

collect loop info for join sites

Collect loop info for join sites the in-loop join site must be joined if the loop is executed

Reimplemented from SVF::TCT.

Definition at line 170 of file MTASlicer.cpp.

171{
172 if (tcgView == nullptr)
173 {
175 return;
176 }
177
178 // Get kept join sites from sliced view
179 std::vector<const ICFGNode*> keptJoinSites;
181
182 for(const ICFGNode* join : keptJoinSites)
183 {
184 const FunObjVar* svffun = join->getFun();
185 const SVFBasicBlock* svfbb = join->getBB();
186
187 if(svffun->hasLoopInfo(svfbb))
188 {
189 const LoopBBs& lp = svffun->getLoopInfo(svfbb);
190 if(!lp.empty() && isJoinMustExecutedInLoop(lp,join))
191 {
193 }
194 }
195
197 {
198 inRecurJoinSites.insert(join);
199 }
200 }
201}
void getKeptJoinSites(std::vector< const ICFGNode * > &out) const
bool isInRecursion(const ICFGNode *inst) const
Whether an instruction is in a recursion.
Definition TCT.cpp:113
virtual void collectLoopInfoForJoin()
Handle join site in loop.
Definition TCT.cpp:340
InstToLoopMap joinSiteToLoopMap
Map a CxtThread to its start routine function.
Definition TCT.h:632
bool isJoinMustExecutedInLoop(const LoopBBs &lp, const ICFGNode *join)
Return true if a join instruction must be executed inside a loop.
Definition TCT.cpp:316
Set< const ICFGNode * > inRecurJoinSites
Fork or Join sites in recursions.
Definition TCT.h:633
SVFLoopAndDomInfo::LoopBBs LoopBBs
Definition TCT.h:158

◆ getKeptForkSites()

void SVF::SlicedTCT::getKeptForkSites ( std::vector< const ICFGNode * > &  out) const
private

Definition at line 280 of file MTASlicer.cpp.

281{
282 out.clear();
283 if (tcgView == nullptr)
284 {
285 // Fall back to original
286 for (ThreadCallGraph::CallSiteSet::const_iterator it = tcg->forksitesBegin(), eit = tcg->forksitesEnd(); it != eit; ++it)
287 {
288 out.push_back(*it);
289 }
290 return;
291 }
292
293 // Get all fork sites from original ThreadCallGraph, but filter by:
294 // 1. The function containing the fork site is kept
295 // 2. There exists a kept fork edge from this fork site
296 for (ThreadCallGraph::CallSiteSet::const_iterator it = tcg->forksitesBegin(), eit = tcg->forksitesEnd(); it != eit; ++it)
297 {
298 const ICFGNode* forkSite = *it;
299 const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(forkSite);
300 if (callNode == nullptr)
301 continue;
302
303 // Check if the function containing the fork site is kept
304 const FunObjVar* fun = forkSite->getFun();
305 CallGraphNode* cgNode = tcg->getCallGraphNode(fun);
306 if (!isKeptNode(cgNode))
307 continue;
308
309 // Check if there's a kept fork edge from this fork site
310 // Use sliced view to get out edges
311 std::vector<const CallGraphEdge*> outEdges;
313
314 bool hasKeptForkEdge = false;
315 for (const CallGraphEdge* edge : outEdges)
316 {
317 if (edge->getEdgeKind() == CallGraphEdge::TDForkEdge)
318 {
319 // Check if this edge corresponds to the fork site
320 const CallGraphEdge::CallInstSet& directCalls = edge->getDirectCalls();
321 const CallGraphEdge::CallInstSet& indirectCalls = edge->getIndirectCalls();
322
323 if (directCalls.count(callNode) > 0 || indirectCalls.count(callNode) > 0)
324 {
325 // Check if the destination is kept
326 const CallGraphNode* dstNode = edge->getDstNode();
327 if (isKeptNode(dstNode))
328 {
329 hasKeptForkEdge = true;
330 break;
331 }
332 }
333 }
334 }
335
336 if (hasKeptForkEdge)
337 {
338 out.push_back(forkSite);
339 }
340 }
341}
Set< const CallICFGNode * > CallInstSet
Definition CallGraph.h:55
const CallGraphNode * getCallGraphNode(const std::string &name) const
Get call graph node.
bool isKeptNode(const CallGraphNode *node) const
void getOutEdgesOf(const CallGraphNode *node, std::vector< const CallGraphEdge * > &out) const
Get out edges of a node (only returns kept edges and target nodes)
ThreadCallGraph * tcg
Definition TCT.h:447
CallSiteSet::const_iterator forksitesEnd() const
CallSiteSet::const_iterator forksitesBegin() const
Fork sites iterators.

◆ getKeptJoinSites()

void SVF::SlicedTCT::getKeptJoinSites ( std::vector< const ICFGNode * > &  out) const
private

Definition at line 343 of file MTASlicer.cpp.

344{
345 out.clear();
346 if (tcgView == nullptr)
347 {
348 // Fall back to original
349 for (ThreadCallGraph::CallSiteSet::const_iterator it = tcg->joinsitesBegin(), eit = tcg->joinsitesEnd(); it != eit; ++it)
350 {
351 out.push_back(*it);
352 }
353 return;
354 }
355
356 // Get all join sites from original ThreadCallGraph, but filter by:
357 // 1. The function containing the join site is kept
358 // 2. There exists a kept join edge to this join site
359 for (ThreadCallGraph::CallSiteSet::const_iterator it = tcg->joinsitesBegin(), eit = tcg->joinsitesEnd(); it != eit; ++it)
360 {
361 const ICFGNode* joinSite = *it;
362 const CallICFGNode* callNode = SVFUtil::dyn_cast<CallICFGNode>(joinSite);
363 if (callNode == nullptr)
364 continue;
365
366 // Check if the function containing the join site is kept
367 const FunObjVar* fun = joinSite->getFun();
368 CallGraphNode* cgNode = tcg->getCallGraphNode(fun);
369 if (!isKeptNode(cgNode))
370 continue;
371
372 // Check if there's a kept join edge to this join site
373 // Use sliced view to get in edges
374 std::vector<const CallGraphEdge*> inEdges;
375 tcgView->getInEdgesOf(cgNode, inEdges);
376
377 bool hasKeptJoinEdge = false;
378 for (const CallGraphEdge* edge : inEdges)
379 {
380 if (edge->getEdgeKind() == CallGraphEdge::TDJoinEdge)
381 {
382 // Check if this edge corresponds to the join site
383 const CallGraphEdge::CallInstSet& directCalls = edge->getDirectCalls();
384 const CallGraphEdge::CallInstSet& indirectCalls = edge->getIndirectCalls();
385
386 if (directCalls.count(callNode) > 0 || indirectCalls.count(callNode) > 0)
387 {
388 // Check if the source is kept
389 const CallGraphNode* srcNode = edge->getSrcNode();
390 if (isKeptNode(srcNode))
391 {
392 hasKeptJoinEdge = true;
393 break;
394 }
395 }
396 }
397 }
398
399 if (hasKeptJoinEdge)
400 {
401 out.push_back(joinSite);
402 }
403 }
404}
CallSiteSet::const_iterator joinsitesEnd() const
CallSiteSet::const_iterator joinsitesBegin() const
Join sites iterators.

◆ handleCallRelation()

void SVF::SlicedTCT::handleCallRelation ( CxtThreadProc ctp,
const CallGraphEdge cgEdge,
const CallICFGNode cs 
)
overrideprotectedvirtual

Handle call relations.

Handle call relations

handle calling context for candidate functions only

Create spawnee TCT node

Add TCT nodes and edge

Reimplemented from SVF::TCT.

Definition at line 233 of file MTASlicer.cpp.

234{
235 // Check if the call site and callee are kept in sliced view
236 if (!isKeptEdge(cgEdge))
237 return;
238
239 const CallGraphNode* dstNode = cgEdge->getDstNode();
240 if (!isKeptNode(dstNode))
241 return;
242
243 // Call base class implementation
245}
bool isKeptEdge(const CallGraphEdge *edge) const
virtual void handleCallRelation(CxtThreadProc &ctp, const CallGraphEdge *cgEdge, const CallICFGNode *call)
Handle call relations.
Definition TCT.cpp:267

◆ isKeptEdge()

bool SVF::SlicedTCT::isKeptEdge ( const CallGraphEdge edge) const
private

Definition at line 272 of file MTASlicer.cpp.

273{
274 if (tcgView == nullptr)
275 return true;
277 return keptEdges.find(const_cast<CallGraphEdge*>(edge)) != keptEdges.end();
278}
CallGraphEdge::CallGraphEdgeSet CallGraphEdgeSet
Definition CallGraph.h:241
const CallGraph::CallGraphEdgeSet & getKeptEdges() const
Get all kept edges.

◆ isKeptNode()

bool SVF::SlicedTCT::isKeptNode ( const CallGraphNode node) const
private

Definition at line 265 of file MTASlicer.cpp.

266{
267 if (tcgView == nullptr)
268 return true;
269 return tcgView->isKeptNode(node);
270}
bool isKeptNode(const CallGraphNode *node) const
Check if a node is in the sliced view.

◆ markRelProcs() [1/2]

void SVF::SlicedTCT::markRelProcs ( )
overrideprotectedvirtual

Mark relevant procedures that are backward reachable from any fork/join site.

Mark relevant procedures that are backward reachable from any fork/join site

Reimplemented from SVF::TCT.

Definition at line 98 of file MTASlicer.cpp.

99{
100 if (tcgView == nullptr)
101 {
103 return;
104 }
105
106 // Get kept fork sites from sliced view
107 std::vector<const ICFGNode*> keptForkSites;
109
110 for (const ICFGNode* forkSite : keptForkSites)
111 {
112 // Get function from fork site
113 const FunObjVar* svfun = forkSite->getFun();
115
116 // Get fork edges from sliced view (use tcgView to get out edges)
117 const CallICFGNode* callNode = SVFUtil::cast<CallICFGNode>(forkSite);
118 const FunObjVar* callerFun = callNode->getFun();
120
122 continue;
123
124 // Use sliced view to get out edges (which filters by kept edges)
125 std::vector<const CallGraphEdge*> outEdges;
127
128 for (const CallGraphEdge* edge : outEdges)
129 {
130 // Check if this is a fork edge
131 if (edge->getEdgeKind() == CallGraphEdge::TDForkEdge)
132 {
133 const CallGraphNode* forkeeNode = edge->getDstNode();
135 {
136 // Check if this edge corresponds to the fork site
137 const CallGraphEdge::CallInstSet& directCalls = edge->getDirectCalls();
138 const CallGraphEdge::CallInstSet& indirectCalls = edge->getIndirectCalls();
139
140 if (directCalls.count(callNode) > 0 || indirectCalls.count(callNode) > 0)
141 {
144 }
145 }
146 }
147 }
148 }
149
150 // Get kept join sites from sliced view
151 std::vector<const ICFGNode*> keptJoinSites;
153
154 for (const ICFGNode* joinSite : keptJoinSites)
155 {
156 const FunObjVar* svfun = joinSite->getFun();
158 }
159
160 if(getMakredProcs().empty())
161 SVFUtil::writeWrnMsg("We didn't recognize any fork site, this is single thread program?");
162}
void getKeptForkSites(std::vector< const ICFGNode * > &out) const
const FunSet & getMakredProcs() const
Get marked candidate functions.
Definition TCT.h:233
FunSet candidateFuncSet
Procedures that are neither called by other functions nor extern functions.
Definition TCT.h:625
virtual void markRelProcs()
Mark relevant procedures that are backward reachable from any fork/join site.
Definition TCT.cpp:155
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition SVFUtil.cpp:72

◆ markRelProcs() [2/2]

void SVF::SlicedTCT::markRelProcs ( const FunObjVar svffun)
overrideprotectedvirtual

Add relevant procedures that are backward reachable from svffun on Thread Call Graph

Reimplemented from SVF::TCT.

Definition at line 164 of file MTASlicer.cpp.

165{
166 // Call base class implementation
168}

◆ pushCxt()

void SVF::SlicedTCT::pushCxt ( CallStrCxt cxt,
const CallICFGNode call,
const FunObjVar callee 
)
overridevirtual

Override pushCxt to use the custom maxContextLen.

Reimplemented from SVF::TCT.

Definition at line 247 of file MTASlicer.cpp.

248{
249 const FunObjVar* caller = call->getFun();
250 CallSiteID csId = tcg->getCallSiteID(call, callee);
251
253 {
254 cxt.push_back(csId);
255 // Use custom maxContextLen if set, otherwise use Options::MaxContextLen()
256 u32_t maxLen = (maxContextLen > 0) ? maxContextLen : Options::MaxContextLen();
257 if (cxt.size() > maxLen)
258 cxt.erase(cxt.begin());
259 if (cxt.size() > MaxCxtSize)
260 MaxCxtSize = cxt.size();
261 DBOUT(DMTA, dumpCxt(cxt));
262 }
263}
unsigned u32_t
Definition CommandLine.h:18
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition SVFType.h:576
#define DMTA
Definition SVFType.h:597
CallSiteID getCallSiteID(const CallICFGNode *cs, const FunObjVar *callee) const
Get CallSiteID.
Definition CallGraph.h:389
virtual const FunObjVar * getFun() const
Return the function of this ICFGNode.
Definition ICFGNode.h:75
Carries around command line options.
Definition Options.h:16
bool inSameCallGraphSCC(const CallGraphNode *src, const CallGraphNode *dst)
Whether two functions in the same callgraph scc.
Definition TCT.h:303
void dumpCxt(CallStrCxt &cxt)
Dump calling context.
Definition TCT.cpp:541
u32_t MaxCxtSize
Definition TCT.h:451
unsigned CallSiteID
Definition GeneralType.h:78

Member Data Documentation

◆ maxContextLen

u32_t SVF::SlicedTCT::maxContextLen
private

Definition at line 104 of file MTASlicer.h.

◆ tcgView

const SlicedThreadCallGraphView* SVF::SlicedTCT::tcgView
private

Definition at line 103 of file MTASlicer.h.


The documentation for this class was generated from the following files: