Static Value-Flow Analysis
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
SVF::PCG Class Reference

#include <PCG.h>

Public Types

typedef Set< const SVFFunction * > FunSet
 
typedef std::vector< const SVFFunction * > FunVec
 
typedef Set< const SVFInstruction * > CallInstSet
 
typedef FIFOWorkList< const SVFFunction * > FunWorkList
 
typedef FIFOWorkList< const SVFBasicBlock * > BBWorkList
 

Public Member Functions

 PCG (PointerAnalysis *an)
 Constructor. More...
 
virtual bool analyze ()
 We start the pass here. More...
 
virtual ~PCG ()
 Destructor. More...
 
CallICFGNodegetCallICFGNode (const SVFInstruction *inst)
 
virtual bool mayHappenInParallel (const SVFInstruction *i1, const SVFInstruction *i2) const
 Interface to query whether two function may happen-in-parallel. More...
 
bool mayHappenInParallelBetweenFunctions (const SVFFunction *fun1, const SVFFunction *fun2) const
 
const FunSetgetMHPFunctions () const
 
void initFromThreadAPI (SVFModule *module)
 Initialize spawner and spawnee sets with threadAPI. More...
 
void inferFromCallGraph ()
 Infer spawner spawnee and followers sets by traversing on callGraph. More...
 
void collectSpawners ()
 
void collectSpawnees ()
 
void collectFollowers ()
 
void identifyFollowers ()
 
const FunSetgetSpawners () const
 Get spawners/spawnees/followers. More...
 
const FunSetgetSpawnees () const
 
const FunSetgetFollowers () const
 
FunSet::const_iterator spawnersBegin (const SVFFunction *fun) const
 Iterators for thread properties of a procedure. More...
 
FunSet::const_iterator spawnersEnd (const SVFFunction *fun) const
 
FunSet::const_iterator spawneesBegin (const SVFFunction *fun) const
 
FunSet::const_iterator spawneesEnd (const SVFFunction *fun) const
 
FunSet::const_iterator followersBegin (const SVFFunction *fun) const
 
FunSet::const_iterator followersEnd (const SVFFunction *fun) const
 
void interferenceAnalysis ()
 Thread interferenceAnalysis. More...
 
void printResults ()
 Print analysis results. More...
 
void printTDFuns ()
 

Private Member Functions

bool isSpawnerFun (const SVFFunction *fun) const
 Add/Get methods for thread properties of a procedure. More...
 
bool isSpawneeFun (const SVFFunction *fun) const
 
bool isFollowerFun (const SVFFunction *fun) const
 
bool addSpawnerFun (const SVFFunction *fun)
 
bool addSpawneeFun (const SVFFunction *fun)
 
bool addFollowerFun (const SVFFunction *fun)
 
bool addSpawnsite (const SVFInstruction *callInst)
 Add/search spawn sites which directly or indirectly create a thread. More...
 
bool isSpawnsite (const SVFInstruction *callInst)
 
CallInstSet::const_iterator spawnSitesBegin () const
 Spawn sites iterators. More...
 
CallInstSet::const_iterator spawnSitesEnd () const
 

Private Attributes

FunSet spawners
 
FunSet spawnees
 
FunSet followers
 
FunSet mhpfuns
 
PTACallGraphcallgraph
 
SVFModulemod
 
PointerAnalysispta
 
ThreadAPItdAPI
 
CallInstSet spawnCallSites
 Callsites direct or Indirect call a function which spawn a thread. More...
 

Detailed Description

This class serves as a base may-happen in parallel analysis for multithreaded program It distinguish thread spawner, spawnee, follower in procedure level by modeling pthread_create, pthread_join, pthread_exit, pthread_cancel synchronization operations

Definition at line 50 of file PCG.h.

Member Typedef Documentation

◆ BBWorkList

Definition at line 58 of file PCG.h.

◆ CallInstSet

Definition at line 56 of file PCG.h.

◆ FunSet

typedef Set<const SVFFunction*> SVF::PCG::FunSet

Definition at line 54 of file PCG.h.

◆ FunVec

typedef std::vector<const SVFFunction*> SVF::PCG::FunVec

Definition at line 55 of file PCG.h.

◆ FunWorkList

Definition at line 57 of file PCG.h.

Constructor & Destructor Documentation

◆ PCG()

SVF::PCG::PCG ( PointerAnalysis an)
inline

Constructor.

Definition at line 133 of file PCG.h.

133  : pta(an)
134  {
135  mod = pta->getModule();
138  }
ThreadAPI * tdAPI
Definition: PCG.h:68
SVFModule * mod
Definition: PCG.h:66
PointerAnalysis * pta
Definition: PCG.h:67
PTACallGraph * callgraph
Definition: PCG.h:65
PTACallGraph * getPTACallGraph() const
Return call graph.
SVFModule * getModule() const
Module.
static ThreadAPI * getThreadAPI()
Return a static reference.
Definition: ThreadAPI.h:102

◆ ~PCG()

virtual SVF::PCG::~PCG ( )
inlinevirtual

Destructor.

Definition at line 144 of file PCG.h.

145  {
146  }

Member Function Documentation

◆ addFollowerFun()

bool SVF::PCG::addFollowerFun ( const SVFFunction fun)
inlineprivate

Definition at line 99 of file PCG.h.

100  {
101  if (fun->isDeclaration())
102  return false;
103  return followers.insert(fun).second;
104  }
FunSet followers
Definition: PCG.h:63

◆ addSpawneeFun()

bool SVF::PCG::addSpawneeFun ( const SVFFunction fun)
inlineprivate

Definition at line 93 of file PCG.h.

94  {
95  if (fun->isDeclaration())
96  return false;
97  return spawnees.insert(fun).second;
98  }
FunSet spawnees
Definition: PCG.h:62

◆ addSpawnerFun()

bool SVF::PCG::addSpawnerFun ( const SVFFunction fun)
inlineprivate

Definition at line 87 of file PCG.h.

88  {
89  if (fun->isDeclaration())
90  return false;
91  return spawners.insert(fun).second;
92  }
FunSet spawners
Definition: PCG.h:61

◆ addSpawnsite()

bool SVF::PCG::addSpawnsite ( const SVFInstruction callInst)
inlineprivate

Add/search spawn sites which directly or indirectly create a thread.

Definition at line 109 of file PCG.h.

110  {
111  return spawnCallSites.insert(callInst).second;
112  }
CallInstSet spawnCallSites
Callsites direct or Indirect call a function which spawn a thread.
Definition: PCG.h:71

◆ analyze()

bool PCG::analyze ( )
virtual

We start the pass here.

Whether two functions may happen in parallel

Definition at line 49 of file PCG.cpp.

50 {
51 
52  //callgraph = new PTACallGraph(mod);
53 
54  DBOUT(DMTA, outs() << pasMsg("Starting MHP analysis\n"));
55 
57 
59 
60  //interferenceAnalysis();
61 
62  //if (Options::TDPrint()) {
63  //printResults();
64  //tdAPI->performAPIStat(mod);
65  //}
66  return false;
67 }
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition: SVFType.h:484
#define DMTA
Definition: SVFType.h:505
void initFromThreadAPI(SVFModule *module)
Initialize spawner and spawnee sets with threadAPI.
Definition: PCG.cpp:96
void inferFromCallGraph()
Infer spawner spawnee and followers sets by traversing on callGraph.
Definition: PCG.cpp:133
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
Definition: SVFUtil.cpp:99
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ collectFollowers()

void PCG::collectFollowers ( )

collect follower procedures which may be called after pthread_create is invoked directly or indirectly a procedure which is called from a follower is also a follower.

identify initial followers

find all the followers recursively on call graph

Definition at line 265 of file PCG.cpp.

266 {
267 
270 
272  FunWorkList worklist;
273  for (FunSet::iterator it = followers.begin(), eit = followers.end(); it != eit; ++it)
274  {
275  worklist.push(*it);
276  }
277  while (!worklist.empty())
278  {
279  const SVFFunction* svffun = worklist.pop();
280  PTACallGraphNode* funNode = callgraph->getCallGraphNode(svffun);
281  for (PTACallGraphNode::const_iterator it = funNode->OutEdgeBegin(), eit = funNode->OutEdgeEnd(); it != eit;
282  ++it)
283  {
284  const SVFFunction* caller = (*it)->getDstNode()->getFunction();
285  if (isFollowerFun(caller) == false)
286  {
287  worklist.push(caller);
288  addFollowerFun(caller);
289  }
290  }
291  }
292 }
iterator OutEdgeEnd()
Definition: GenericGraph.h:221
iterator OutEdgeBegin()
iterators
Definition: GenericGraph.h:217
bool addFollowerFun(const SVFFunction *fun)
Definition: PCG.h:99
bool isFollowerFun(const SVFFunction *fun) const
Definition: PCG.h:83
FIFOWorkList< const SVFFunction * > FunWorkList
Definition: PCG.h:57
void identifyFollowers()
Definition: PCG.cpp:217
PTACallGraphEdge::CallGraphEdgeSet::const_iterator const_iterator
Definition: PTACallGraph.h:180
PTACallGraphNode * getCallGraphNode(NodeID id) const
Get call graph node.
Definition: PTACallGraph.h:315

◆ collectSpawnees()

void PCG::collectSpawnees ( )

spawnee: given a spawnee, all its callees on callgraph are spawnees

find all the spawnees recursively on call graph

Definition at line 187 of file PCG.cpp.

188 {
189 
191  FunWorkList worklist;
192  for (FunSet::iterator it = spawnees.begin(), eit = spawnees.end(); it != eit; ++it)
193  {
194  worklist.push(*it);
195  }
196  while (!worklist.empty())
197  {
198  const SVFFunction* svffun = worklist.pop();
199  PTACallGraphNode* funNode = callgraph->getCallGraphNode(svffun);
200  for (PTACallGraphNode::const_iterator it = funNode->OutEdgeBegin(), eit = funNode->OutEdgeEnd(); it != eit;
201  ++it)
202  {
203  const SVFFunction* caller = (*it)->getDstNode()->getFunction();
204  if (isSpawneeFun(caller) == false)
205  {
206  worklist.push(caller);
207  addSpawneeFun(caller);
208  }
209  }
210  }
211 }
bool addSpawneeFun(const SVFFunction *fun)
Definition: PCG.h:93
bool isSpawneeFun(const SVFFunction *fun) const
Definition: PCG.h:79

◆ collectSpawners()

void PCG::collectSpawners ( )

spawner: given a spawner, all its callers on callgraph are spawners

find all the spawners recursively on call graph

add all the callsites from callers to callee (spawner) as a spawn site.

Definition at line 146 of file PCG.cpp.

147 {
148 
150  FunWorkList worklist;
151  for (FunSet::iterator it = spawners.begin(), eit = spawners.end(); it != eit; ++it)
152  {
153  worklist.push(*it);
154  }
155  while (!worklist.empty())
156  {
157  const SVFFunction* svffun = worklist.pop();
158  PTACallGraphNode* funNode = callgraph->getCallGraphNode(svffun);
159  for (PTACallGraphNode::const_iterator it = funNode->InEdgeBegin(), eit = funNode->InEdgeEnd(); it != eit;
160  ++it)
161  {
162  PTACallGraphEdge* callEdge = (*it);
163  const SVFFunction* caller = callEdge->getSrcNode()->getFunction();
164  if (isSpawnerFun(caller) == false)
165  {
166  worklist.push(caller);
167  addSpawnerFun(caller);
168  }
170  for (PTACallGraphEdge::CallInstSet::const_iterator dit = callEdge->directCallsBegin(), deit =
171  callEdge->directCallsEnd(); dit != deit; ++dit)
172  {
173  addSpawnsite((*dit)->getCallSite());
174  }
175  for (PTACallGraphEdge::CallInstSet::const_iterator dit = callEdge->indirectCallsBegin(), deit =
176  callEdge->indirectCallsEnd(); dit != deit; ++dit)
177  {
178  addSpawnsite((*dit)->getCallSite());
179  }
180  }
181  }
182 }
NodeType * getSrcNode() const
Definition: GenericGraph.h:97
iterator InEdgeBegin()
Definition: GenericGraph.h:225
iterator InEdgeEnd()
Definition: GenericGraph.h:229
bool isSpawnerFun(const SVFFunction *fun) const
Add/Get methods for thread properties of a procedure.
Definition: PCG.h:75
bool addSpawnerFun(const SVFFunction *fun)
Definition: PCG.h:87
bool addSpawnsite(const SVFInstruction *callInst)
Add/search spawn sites which directly or indirectly create a thread.
Definition: PCG.h:109
CallInstSet::const_iterator indirectCallsEnd() const
Definition: PTACallGraph.h:135
CallInstSet::const_iterator directCallsBegin() const
Iterators for direct and indirect callsites.
Definition: PTACallGraph.h:122
CallInstSet::const_iterator directCallsEnd() const
Definition: PTACallGraph.h:126
CallInstSet::const_iterator indirectCallsBegin() const
Definition: PTACallGraph.h:131

◆ followersBegin()

FunSet::const_iterator SVF::PCG::followersBegin ( const SVFFunction fun) const
inline

Definition at line 206 of file PCG.h.

207  {
208  return followers.begin();
209  }

◆ followersEnd()

FunSet::const_iterator SVF::PCG::followersEnd ( const SVFFunction fun) const
inline

Definition at line 210 of file PCG.h.

211  {
212  return followers.end();
213  }

◆ getCallICFGNode()

CallICFGNode* SVF::PCG::getCallICFGNode ( const SVFInstruction inst)
inline

Definition at line 148 of file PCG.h.

149  {
150  return pta->getICFG()->getCallICFGNode(inst);
151  }
CallICFGNode * getCallICFGNode(const SVFInstruction *inst)
Definition: ICFG.cpp:241
ICFG * getICFG() const
Get ICFG.

◆ getFollowers()

const FunSet& SVF::PCG::getFollowers ( ) const
inline

Definition at line 182 of file PCG.h.

183  {
184  return followers;
185  }

◆ getMHPFunctions()

const FunSet& SVF::PCG::getMHPFunctions ( ) const
inline

Definition at line 155 of file PCG.h.

156  {
157  return mhpfuns;
158  }
FunSet mhpfuns
Definition: PCG.h:64

◆ getSpawnees()

const FunSet& SVF::PCG::getSpawnees ( ) const
inline

Definition at line 178 of file PCG.h.

179  {
180  return spawnees;
181  }

◆ getSpawners()

const FunSet& SVF::PCG::getSpawners ( ) const
inline

Get spawners/spawnees/followers.

Definition at line 174 of file PCG.h.

175  {
176  return spawners;
177  }

◆ identifyFollowers()

void PCG::identifyFollowers ( )

Identify initial followers a procedure whose callsite lies in a control flow path that starts just after a spawner's callsite

Definition at line 217 of file PCG.cpp.

218 {
219 
220  for (CallInstSet::const_iterator sit = spawnSitesBegin(), esit = spawnSitesEnd(); sit != esit; ++sit)
221  {
222  const SVFInstruction* inst = *sit;
223  BBWorkList bb_worklist;
224  Set<const SVFBasicBlock*> visitedBBs;
225  bb_worklist.push(inst->getParent());
226  while (!bb_worklist.empty())
227  {
228  const SVFBasicBlock* bb = bb_worklist.pop();
229  for (SVFBasicBlock::const_iterator it = bb->begin(), eit = bb->end(); it != eit; ++it)
230  {
231  const SVFInstruction* inst = *it;
232  // mark the callee of this callsite as follower
233  // if this is an call/invoke instruction but not a spawn site
234  if ((SVFUtil::isCallSite(inst)) && !isSpawnsite(inst) && !SVFUtil::isIntrinsicInst(inst))
235  {
236  CallICFGNode* cbn = getCallICFGNode(inst);
237  if (callgraph->hasCallGraphEdge(cbn))
238  {
239  for (PTACallGraph::CallGraphEdgeSet::const_iterator cgIt = callgraph->getCallEdgeBegin(cbn),
240  ecgIt = callgraph->getCallEdgeEnd(cbn); cgIt != ecgIt; ++cgIt)
241  {
242  const PTACallGraphEdge* edge = *cgIt;
243  addFollowerFun(edge->getDstNode()->getFunction());
244  }
245  }
246  }
247  }
248  for (const SVFBasicBlock* svf_scc_bb : bb->getSuccessors())
249  {
250  if (visitedBBs.count(svf_scc_bb) == 0)
251  {
252  visitedBBs.insert(svf_scc_bb);
253  bb_worklist.push(svf_scc_bb);
254  }
255  }
256  }
257  }
258 
259 }
NodeType * getDstNode() const
Definition: GenericGraph.h:101
CallInstSet::const_iterator spawnSitesBegin() const
Spawn sites iterators.
Definition: PCG.h:120
FIFOWorkList< const SVFBasicBlock * > BBWorkList
Definition: PCG.h:58
bool isSpawnsite(const SVFInstruction *callInst)
Definition: PCG.h:113
CallInstSet::const_iterator spawnSitesEnd() const
Definition: PCG.h:124
CallICFGNode * getCallICFGNode(const SVFInstruction *inst)
Definition: PCG.h:148
CallGraphEdgeSet::const_iterator getCallEdgeEnd(const CallICFGNode *inst) const
Definition: PTACallGraph.h:408
CallGraphEdgeSet::const_iterator getCallEdgeBegin(const CallICFGNode *inst) const
Definition: PTACallGraph.h:401
bool hasCallGraphEdge(const CallICFGNode *inst) const
Get call graph edge via call instruction.
Definition: PTACallGraph.h:397
const std::vector< const SVFBasicBlock * > & getSuccessors() const
Definition: SVFValue.h:612
std::vector< const SVFInstruction * >::const_iterator const_iterator
Definition: SVFValue.h:536
const_iterator end() const
Definition: SVFValue.h:583
const_iterator begin() const
Definition: SVFValue.h:578
const SVFBasicBlock * getParent() const
Definition: SVFValue.h:658
bool isIntrinsicInst(const SVFInstruction *inst)
Return true if it is an llvm intrinsic instruction.
Definition: SVFUtil.cpp:247
bool isCallSite(const SVFInstruction *inst)
Whether an instruction is a call or invoke instruction.
Definition: SVFUtil.h:174
std::unordered_set< Key, Hash, KeyEqual, Allocator > Set
Definition: GeneralType.h:96

◆ inferFromCallGraph()

void PCG::inferFromCallGraph ( )

Infer spawner spawnee and followers sets by traversing on callGraph.

Infer spawners and spawnees from call graph. The inference are recursively done spawners: procedures may create a thread and return with the created thread still running spawnees: procedures may be executed as a spawned thread followers: procedures may be invoked by a thread after the thread returns from a spawner (procedure may be called after pthread_creat is called).

Definition at line 133 of file PCG.cpp.

134 {
135 
136  collectSpawners();
137 
138  collectSpawnees();
139 
141 }
void collectFollowers()
Definition: PCG.cpp:265
void collectSpawnees()
Definition: PCG.cpp:187
void collectSpawners()
Definition: PCG.cpp:146

◆ initFromThreadAPI()

void PCG::initFromThreadAPI ( SVFModule module)

Initialize spawner and spawnee sets with threadAPI.

Initialize thread spawners and spawnees from threadAPI functions a procedure is a spawner if it creates a thread and the created thread is still existent on its return a procedure is a spawnee if it is created by fork call

TODO: handle indirect call here for the fork Fun

Definition at line 96 of file PCG.cpp.

97 {
98  for (const SVFFunction* fun : module->getFunctionSet())
99  {
100  for (const SVFBasicBlock* svfbb : fun->getBasicBlockList())
101  {
102  for (const SVFInstruction* inst : svfbb->getInstructionList())
103  {
104  if (tdAPI->isTDFork(inst))
105  {
106  const SVFValue* forkVal = tdAPI->getForkedFun(inst);
107  if (const SVFFunction* svForkfun = SVFUtil::dyn_cast<SVFFunction>(forkVal))
108  {
109  addSpawnsite(inst);
110  spawners.insert(fun);
111  spawnees.insert(svForkfun);
112  }
114  else
115  {
116  writeWrnMsg("pthread create");
117  outs() << inst->toString() << "\n";
118  writeWrnMsg("invoke spawnee indirectly");
119  }
120  }
121  }
122  }
123  }
124 }
const FunctionSetType & getFunctionSet() const
Definition: SVFModule.h:216
bool isTDFork(const SVFInstruction *inst) const
Return true if this call create a new thread.
Definition: ThreadAPI.h:129
const SVFValue * getForkedFun(const SVFInstruction *inst) const
Definition: ThreadAPI.h:168
void writeWrnMsg(const std::string &msg)
Writes a message run through wrnMsg.
Definition: SVFUtil.cpp:66

◆ interferenceAnalysis()

void PCG::interferenceAnalysis ( )

Thread interferenceAnalysis.

Thread interference analysis, Suppose we have a undirected graph G = {F,E,I} F denotes procedure, E represents interference edge (x,y) \in E, x \in F, y \in F means execution of x in one thread may overlap execution of y in another thread I(x,y) is a set of memory locations for this interference edge

Definition at line 302 of file PCG.cpp.

303 {
304 
305 // DBOUT(DMTA, outs() << pasMsg("Starting Race Detection\n"));
306 
307  PCG::FunVec worklist;
308  for (SVFModule::const_iterator F = mod->begin(), E = mod->end(); F != E; ++F)
309  {
310  const SVFFunction* fun = *F;
311  if (isExtCall(fun))
312  continue;
313  worklist.push_back(fun);
314  }
315 
316  while (!worklist.empty())
317  {
318  const SVFFunction* fun1 = worklist.back();
319  worklist.pop_back();
320 
321  bool ismhpfun = false;
322  for (PCG::FunVec::iterator it = worklist.begin(), eit = worklist.end(); it != eit; ++it)
323  {
324  const SVFFunction* fun2 = *it;
325  if (mayHappenInParallelBetweenFunctions(fun1, fun2))
326  {
327  ismhpfun = true;
328  mhpfuns.insert(fun2);
329  }
330  }
331  if (ismhpfun)
332  {
333  mhpfuns.insert(fun1);
334  }
335  }
336 }
#define F(f)
std::vector< const SVFFunction * > FunVec
Definition: PCG.h:55
bool mayHappenInParallelBetweenFunctions(const SVFFunction *fun1, const SVFFunction *fun2) const
Definition: PCG.cpp:69
const SVFBasicBlock * back() const
Definition: SVFValue.h:427
iterator begin()
Definition: SVFModule.h:133
iterator end()
Definition: SVFModule.h:141
FunctionSetType::const_iterator const_iterator
Definition: SVFModule.h:54
bool isExtCall(const SVFFunction *fun)
Definition: SVFUtil.h:309

◆ isFollowerFun()

bool SVF::PCG::isFollowerFun ( const SVFFunction fun) const
inlineprivate

Definition at line 83 of file PCG.h.

84  {
85  return followers.find(fun) != followers.end();
86  }

◆ isSpawneeFun()

bool SVF::PCG::isSpawneeFun ( const SVFFunction fun) const
inlineprivate

Definition at line 79 of file PCG.h.

80  {
81  return spawnees.find(fun) != spawnees.end();
82  }

◆ isSpawnerFun()

bool SVF::PCG::isSpawnerFun ( const SVFFunction fun) const
inlineprivate

Add/Get methods for thread properties of a procedure.

Definition at line 75 of file PCG.h.

76  {
77  return spawners.find(fun) != spawners.end();
78  }

◆ isSpawnsite()

bool SVF::PCG::isSpawnsite ( const SVFInstruction callInst)
inlineprivate

Definition at line 113 of file PCG.h.

114  {
115  return spawnCallSites.find(callInst) != spawnCallSites.end();
116  }

◆ mayHappenInParallel()

bool PCG::mayHappenInParallel ( const SVFInstruction i1,
const SVFInstruction i2 
) const
virtual

Interface to query whether two function may happen-in-parallel.

Definition at line 83 of file PCG.cpp.

84 {
85  const SVFFunction* fun1 = i1->getFunction();
86  const SVFFunction* fun2 = i2->getFunction();
87  return mayHappenInParallelBetweenFunctions(fun1, fun2);
88 }
const SVFFunction * getFunction() const
Definition: SVFValue.h:683

◆ mayHappenInParallelBetweenFunctions()

bool PCG::mayHappenInParallelBetweenFunctions ( const SVFFunction fun1,
const SVFFunction fun2 
) const

Definition at line 69 of file PCG.cpp.

70 {
71  // if neither of functions are spawnees, then they won't happen in parallel
72  if (isSpawneeFun(fun1) == false && isSpawneeFun(fun2) == false)
73  return false;
74  // if there exit one of the function are not spawner, spawnee or follower, then they won't happen in parallel
75  if (isSpawnerFun(fun1) == false && isSpawneeFun(fun1) == false && isFollowerFun(fun1) == false)
76  return false;
77  if (isSpawnerFun(fun2) == false && isSpawneeFun(fun2) == false && isFollowerFun(fun2) == false)
78  return false;
79 
80  return true;
81 }

◆ printResults()

void PCG::printResults ( )

Print analysis results.

Print analysis results

Definition at line 341 of file PCG.cpp.

342 {
343 
344  printTDFuns();
345 }
void printTDFuns()
Definition: PCG.cpp:350

◆ printTDFuns()

void PCG::printTDFuns ( )

Print Thread sensitive properties for each function

Definition at line 350 of file PCG.cpp.

351 {
352 
353  for (SVFModule::const_iterator fi = mod->begin(), efi = mod->end(); fi != efi; ++fi)
354  {
355  const SVFFunction* fun = (*fi);
356  if (fun->isDeclaration())
357  continue;
358 
359  std::string isSpawner = isSpawnerFun(fun) ? " SPAWNER " : "";
360  std::string isSpawnee = isSpawneeFun(fun) ? " CHILDREN " : "";
361  std::string isFollower = isFollowerFun(fun) ? " FOLLOWER " : "";
362  outs() << fun->getName() << " [" << isSpawner << isSpawnee << isFollower << "]\n";
363  }
364 }
const char *const string
Definition: cJSON.h:172
bool isDeclaration() const
Definition: SVFValue.h:367
const std::string & getName() const
Definition: SVFValue.h:243

◆ spawneesBegin()

FunSet::const_iterator SVF::PCG::spawneesBegin ( const SVFFunction fun) const
inline

Definition at line 198 of file PCG.h.

199  {
200  return spawnees.begin();
201  }

◆ spawneesEnd()

FunSet::const_iterator SVF::PCG::spawneesEnd ( const SVFFunction fun) const
inline

Definition at line 202 of file PCG.h.

203  {
204  return spawnees.end();
205  }

◆ spawnersBegin()

FunSet::const_iterator SVF::PCG::spawnersBegin ( const SVFFunction fun) const
inline

Iterators for thread properties of a procedure.

Definition at line 190 of file PCG.h.

191  {
192  return spawners.begin();
193  }

◆ spawnersEnd()

FunSet::const_iterator SVF::PCG::spawnersEnd ( const SVFFunction fun) const
inline

Definition at line 194 of file PCG.h.

195  {
196  return spawners.end();
197  }

◆ spawnSitesBegin()

CallInstSet::const_iterator SVF::PCG::spawnSitesBegin ( ) const
inlineprivate

Spawn sites iterators.

Definition at line 120 of file PCG.h.

121  {
122  return spawnCallSites.begin();
123  }

◆ spawnSitesEnd()

CallInstSet::const_iterator SVF::PCG::spawnSitesEnd ( ) const
inlineprivate

Definition at line 124 of file PCG.h.

125  {
126  return spawnCallSites.end();
127  }

Member Data Documentation

◆ callgraph

PTACallGraph* SVF::PCG::callgraph
private

Definition at line 65 of file PCG.h.

◆ followers

FunSet SVF::PCG::followers
private

Definition at line 63 of file PCG.h.

◆ mhpfuns

FunSet SVF::PCG::mhpfuns
private

Definition at line 64 of file PCG.h.

◆ mod

SVFModule* SVF::PCG::mod
private

Definition at line 66 of file PCG.h.

◆ pta

PointerAnalysis* SVF::PCG::pta
private

Definition at line 67 of file PCG.h.

◆ spawnCallSites

CallInstSet SVF::PCG::spawnCallSites
private

Callsites direct or Indirect call a function which spawn a thread.

Definition at line 71 of file PCG.h.

◆ spawnees

FunSet SVF::PCG::spawnees
private

Definition at line 62 of file PCG.h.

◆ spawners

FunSet SVF::PCG::spawners
private

Definition at line 61 of file PCG.h.

◆ tdAPI

ThreadAPI* SVF::PCG::tdAPI
private

Definition at line 68 of file PCG.h.


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