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

#include <SVFGBuilder.h>

Inheritance diagram for SVF::SVFGBuilder:
SVF::SaberSVFGBuilder SVF::CFLSVFGBuilder

Public Types

typedef PointerAnalysis::CallSiteSet CallSiteSet
 
typedef PointerAnalysis::CallEdgeMap CallEdgeMap
 
typedef PointerAnalysis::FunctionSet FunctionSet
 
typedef SVFG::SVFGEdgeSetTy SVFGEdgeSet
 

Public Member Functions

 SVFGBuilder (bool _SVFGWithIndCall=false)
 Constructor. More...
 
virtual ~SVFGBuilder ()=default
 Destructor. More...
 
SVFGbuildPTROnlySVFG (BVDataPTAImpl *pta)
 
SVFGbuildFullSVFG (BVDataPTAImpl *pta)
 
SVFGgetSVFG () const
 Get SVFG instance. More...
 
void markValidVFEdge (SVFGEdgeSet &edges)
 Mark feasible VF edge by removing it from set vfEdgesAtIndCallSite. More...
 
bool isSpuriousVFEdgeAtIndCallSite (const SVFGEdge *edge)
 Return true if this is an VF Edge pre-connected by Andersen's analysis. More...
 
virtual std::unique_ptr< MemSSAbuildMSSA (BVDataPTAImpl *pta, bool ptrOnlyMSSA)
 Build Memory SSA. More...
 

Protected Member Functions

SVFGbuild (BVDataPTAImpl *pta, VFG::VFGK kind)
 Create a DDA SVFG. By default actualOut and FormalIN are removed, unless withAOFI is set true. More...
 
virtual void buildSVFG ()
 Can be rewritten by subclasses. More...
 
virtual void releaseMemory ()
 Release global SVFG. More...
 

Protected Attributes

SVFGEdgeSet vfEdgesAtIndCallSite
 SVFG Edges connected at indirect call/ret sites. More...
 
std::unique_ptr< SVFGsvfg
 
bool SVFGWithIndCall
 SVFG with precomputed indirect call edges. More...
 

Detailed Description

SVFG Builder

Definition at line 42 of file SVFGBuilder.h.

Member Typedef Documentation

◆ CallEdgeMap

Definition at line 47 of file SVFGBuilder.h.

◆ CallSiteSet

Definition at line 46 of file SVFGBuilder.h.

◆ FunctionSet

Definition at line 48 of file SVFGBuilder.h.

◆ SVFGEdgeSet

Definition at line 49 of file SVFGBuilder.h.

Constructor & Destructor Documentation

◆ SVFGBuilder()

SVF::SVFGBuilder::SVFGBuilder ( bool  _SVFGWithIndCall = false)
inlineexplicit

Constructor.

Definition at line 52 of file SVFGBuilder.h.

52 : svfg(nullptr), SVFGWithIndCall(_SVFGWithIndCall) {}
bool SVFGWithIndCall
SVFG with precomputed indirect call edges.
Definition: SVFGBuilder.h:93
std::unique_ptr< SVFG > svfg
Definition: SVFGBuilder.h:91

◆ ~SVFGBuilder()

virtual SVF::SVFGBuilder::~SVFGBuilder ( )
virtualdefault

Destructor.

Member Function Documentation

◆ build()

SVFG * SVFGBuilder::build ( BVDataPTAImpl pta,
VFG::VFGK  kind 
)
protected

Create a DDA SVFG. By default actualOut and FormalIN are removed, unless withAOFI is set true.

Create DDA SVFG.

Update call graph using pre-analysis results

Definition at line 64 of file SVFGBuilder.cpp.

65 {
66 
67  auto mssa = buildMSSA(pta, (VFG::PTRONLYSVFG==kind || VFG::PTRONLYSVFG_OPT==kind));
68 
69  DBOUT(DGENERAL, outs() << pasMsg("Build Sparse Value-Flow Graph \n"));
70  if(kind == VFG::FULLSVFG_OPT || kind == VFG::PTRONLYSVFG_OPT)
71  svfg = std::make_unique<SVFGOPT>(std::move(mssa), kind);
72  else
73  svfg = std::unique_ptr<SVFG>(new SVFG(std::move(mssa),kind));
74  buildSVFG();
75 
78  svfg->updateCallGraph(pta);
79 
80  if(svfg->getMSSA()->getPTA()->printStat())
81  svfg->performStat();
82 
83  if(Options::DumpVFG())
84  svfg->dump("svfg_final");
85 
86  return svfg.get();
87 }
#define DBOUT(TYPE, X)
LLVM debug macros, define type of your DBUG model of each pass.
Definition: SVFType.h:484
#define DGENERAL
Definition: SVFType.h:490
static const Option< bool > SVFGWithIndirectCall
Definition: Options.h:148
static const Option< bool > DumpVFG
Definition: Options.h:111
virtual std::unique_ptr< MemSSA > buildMSSA(BVDataPTAImpl *pta, bool ptrOnlyMSSA)
Build Memory SSA.
Definition: SVFGBuilder.cpp:97
virtual void buildSVFG()
Can be rewritten by subclasses.
Definition: SVFGBuilder.cpp:58
Definition: SVFG.h:66
@ PTRONLYSVFG_OPT
Definition: VFG.h:57
@ FULLSVFG_OPT
Definition: VFG.h:57
@ PTRONLYSVFG
Definition: VFG.h:57
std::string pasMsg(const std::string &msg)
Print each pass/phase message by converting a string into blue string output.
Definition: SVFUtil.cpp:99
constexpr std::remove_reference< T >::type && move(T &&t) noexcept
Definition: SVFUtil.h:447
std::ostream & outs()
Overwrite llvm::outs()
Definition: SVFUtil.h:50

◆ buildFullSVFG()

SVFG * SVFGBuilder::buildFullSVFG ( BVDataPTAImpl pta)

Definition at line 49 of file SVFGBuilder.cpp.

50 {
51  return build(pta, VFG::FULLSVFG);
52 }
SVFG * build(BVDataPTAImpl *pta, VFG::VFGK kind)
Create a DDA SVFG. By default actualOut and FormalIN are removed, unless withAOFI is set true.
Definition: SVFGBuilder.cpp:64
@ FULLSVFG
Definition: VFG.h:57

◆ buildMSSA()

std::unique_ptr< MemSSA > SVFGBuilder::buildMSSA ( BVDataPTAImpl pta,
bool  ptrOnlyMSSA 
)
virtual

Build Memory SSA.

Definition at line 97 of file SVFGBuilder.cpp.

98 {
99 
100  DBOUT(DGENERAL, outs() << pasMsg("Build Memory SSA \n"));
101 
102  auto mssa = std::make_unique<MemSSA>(pta, ptrOnlyMSSA);
103 
104  PTACallGraph* svfirCallGraph = PAG::getPAG()->getCallGraph();
105  for (const auto& item: *svfirCallGraph)
106  {
107 
108  const SVFFunction *fun = item.second->getFunction();
109  if (isExtCall(fun))
110  continue;
111 
112  mssa->buildMemSSA(*fun);
113  }
114 
115  mssa->performStat();
116  if (Options::DumpMSSA())
117  {
118  mssa->dumpMSSA();
119  }
120 
121  return mssa;
122 }
cJSON * item
Definition: cJSON.h:222
static const Option< bool > DumpMSSA
Definition: Options.h:142
PTACallGraph * getCallGraph()
Definition: SVFIR.h:192
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition: SVFIR.h:115
bool isExtCall(const SVFFunction *fun)
Definition: SVFUtil.h:278

◆ buildPTROnlySVFG()

SVFG * SVFGBuilder::buildPTROnlySVFG ( BVDataPTAImpl pta)

Definition at line 41 of file SVFGBuilder.cpp.

42 {
43  if(Options::OPTSVFG())
44  return build(pta, VFG::PTRONLYSVFG_OPT);
45  else
46  return build(pta, VFG::PTRONLYSVFG);
47 }
static Option< bool > OPTSVFG
Definition: Options.h:149

◆ buildSVFG()

void SVFGBuilder::buildSVFG ( )
protectedvirtual

Can be rewritten by subclasses.

Create SVFG

Reimplemented in SVF::SaberSVFGBuilder, and SVF::CFLSVFGBuilder.

Definition at line 58 of file SVFGBuilder.cpp.

59 {
60  svfg->buildSVFG();
61 }

◆ getSVFG()

SVFG* SVF::SVFGBuilder::getSVFG ( ) const
inline

Get SVFG instance.

Definition at line 61 of file SVFGBuilder.h.

62  {
63  return svfg.get();
64  }

◆ isSpuriousVFEdgeAtIndCallSite()

bool SVF::SVFGBuilder::isSpuriousVFEdgeAtIndCallSite ( const SVFGEdge edge)
inline

Return true if this is an VF Edge pre-connected by Andersen's analysis.

Definition at line 73 of file SVFGBuilder.h.

74  {
75  return vfEdgesAtIndCallSite.find(const_cast<SVFGEdge*>(edge))!=vfEdgesAtIndCallSite.end();
76  }
SVFGEdgeSet vfEdgesAtIndCallSite
SVFG Edges connected at indirect call/ret sites.
Definition: SVFGBuilder.h:90
VFGEdge SVFGEdge
Definition: SVFG.h:40

◆ markValidVFEdge()

void SVF::SVFGBuilder::markValidVFEdge ( SVFGEdgeSet edges)
inline

Mark feasible VF edge by removing it from set vfEdgesAtIndCallSite.

Definition at line 67 of file SVFGBuilder.h.

68  {
69  for(SVFGEdgeSet::iterator it = edges.begin(), eit = edges.end(); it!=eit; ++it)
70  vfEdgesAtIndCallSite.erase(*it);
71  }

◆ releaseMemory()

void SVFGBuilder::releaseMemory ( )
protectedvirtual

Release global SVFG.

Release memory

Definition at line 92 of file SVFGBuilder.cpp.

93 {
94  svfg->clearMSSA();
95 }

Member Data Documentation

◆ svfg

std::unique_ptr<SVFG> SVF::SVFGBuilder::svfg
protected

Definition at line 91 of file SVFGBuilder.h.

◆ SVFGWithIndCall

bool SVF::SVFGBuilder::SVFGWithIndCall
protected

SVFG with precomputed indirect call edges.

Definition at line 93 of file SVFGBuilder.h.

◆ vfEdgesAtIndCallSite

SVFGEdgeSet SVF::SVFGBuilder::vfEdgesAtIndCallSite
protected

SVFG Edges connected at indirect call/ret sites.

Definition at line 90 of file SVFGBuilder.h.


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