Static Value-Flow Analysis
Loading...
Searching...
No Matches
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::MTASVFGBuilder 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=Options::SVFGWithIndirectCall(), bool _SVFGWithPostOpts=Options::OPTSVFG())
 Constructor.
 
virtual ~SVFGBuilder ()=default
 Destructor.
 
SVFGbuildPTROnlySVFG (BVDataPTAImpl *pta)
 
SVFGbuildFullSVFG (BVDataPTAImpl *pta)
 
SVFGgetSVFG () const
 Get SVFG instance.
 
void markValidVFEdge (SVFGEdgeSet &edges)
 Mark feasible VF edge by removing it from set vfEdgesAtIndCallSite.
 
bool isSpuriousVFEdgeAtIndCallSite (const SVFGEdge *edge)
 Return true if this is an VF Edge pre-connected by Andersen's analysis.
 
virtual std::unique_ptr< MemSSAbuildMSSA (BVDataPTAImpl *pta, bool ptrOnlyMSSA)
 Build Memory SSA.
 

Protected Member Functions

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

Protected Attributes

SVFGEdgeSet vfEdgesAtIndCallSite
 SVFG Edges connected at indirect call/ret sites.
 
std::unique_ptr< SVFGsvfg
 
bool SVFGWithIndCall
 SVFG with precomputed indirect call edges.
 
bool SVFGWithPostOpts
 Build optimised version of SVFG.
 

Detailed Description

SVFG Builder

Definition at line 43 of file SVFGBuilder.h.

Member Typedef Documentation

◆ CallEdgeMap

Definition at line 48 of file SVFGBuilder.h.

◆ CallSiteSet

Definition at line 47 of file SVFGBuilder.h.

◆ FunctionSet

Definition at line 49 of file SVFGBuilder.h.

◆ SVFGEdgeSet

Definition at line 50 of file SVFGBuilder.h.

Constructor & Destructor Documentation

◆ SVFGBuilder()

SVF::SVFGBuilder::SVFGBuilder ( bool  _SVFGWithIndCall = Options::SVFGWithIndirectCall(),
bool  _SVFGWithPostOpts = Options::OPTSVFG() 
)
inlineexplicit

Constructor.

Definition at line 53 of file SVFGBuilder.h.

55 {
56 }
bool SVFGWithPostOpts
Build optimised version of SVFG.
bool SVFGWithIndCall
SVFG with precomputed indirect call edges.
std::unique_ptr< SVFG > svfg
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ ~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 63 of file SVFGBuilder.cpp.

64{
65
66 auto mssa = buildMSSA(
67 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:576
#define DGENERAL
Definition SVFType.h:582
static const Option< bool > DumpVFG
Definition Options.h:107
virtual std::unique_ptr< MemSSA > buildMSSA(BVDataPTAImpl *pta, bool ptrOnlyMSSA)
Build Memory SSA.
virtual void buildSVFG()
Can be rewritten by subclasses.
@ 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:105
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52

◆ buildFullSVFG()

SVFG * SVFGBuilder::buildFullSVFG ( BVDataPTAImpl pta)

Definition at line 48 of file SVFGBuilder.cpp.

49{
50 return this->SVFGWithPostOpts ? build(pta, VFG::FULLSVFG_OPT)
51 : 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 VFG.h:51

◆ buildMSSA()

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

Build Memory SSA.

Definition at line 117 of file SVFGBuilder.cpp.

119{
120
121 DBOUT(DGENERAL, outs() << pasMsg("Build Memory SSA \n"));
122
123 auto mssa = std::make_unique<MemSSA>(pta, createMRGenerator(pta, ptrOnlyMSSA));
124
126 for (const auto& item : *svfirCallGraph)
127 {
128
129 const FunObjVar* fun = item.second->getFunction();
130 if (isExtCall(fun))
131 continue;
132
133 mssa->buildMemSSA(*fun);
134 }
135
136 mssa->performStat();
137 if (Options::DumpMSSA())
138 {
139 mssa->dumpMSSA();
140 }
141
142 return mssa;
143}
cJSON * item
Definition cJSON.h:222
static const Option< bool > DumpMSSA
Definition Options.h:138
virtual std::unique_ptr< MRGenerator > createMRGenerator(BVDataPTAImpl *pta, bool ptrOnlyMSSA)
const CallGraph * getCallGraph()
Get CG.
Definition SVFIR.h:248
static SVFIR * getPAG(bool buildFromFile=false)
Singleton design here to make sure we only have one instance during any analysis.
Definition SVFIR.h:120
bool isExtCall(const FunObjVar *fun)
Definition SVFUtil.cpp:441

◆ buildPTROnlySVFG()

SVFG * SVFGBuilder::buildPTROnlySVFG ( BVDataPTAImpl pta)

Definition at line 42 of file SVFGBuilder.cpp.

43{
45 : build(pta, VFG::PTRONLYSVFG);
46}

◆ buildSVFG()

void SVFGBuilder::buildSVFG ( )
protectedvirtual

Can be rewritten by subclasses.

Create SVFG

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

Definition at line 57 of file SVFGBuilder.cpp.

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

◆ createMRGenerator()

std::unique_ptr< MRGenerator > SVFGBuilder::createMRGenerator ( BVDataPTAImpl pta,
bool  ptrOnlyMSSA 
)
protectedvirtual

Hook supplying the MRGenerator for the MemSSA built above. The default builds the stock generator selected by Options::MemPar(); MTASVFGBuilder overrides this to inject a thread-aware (ThreadMRG) generator. Ownership transfers to the MemSSA constructed in buildMSSA.

Build the stock MRGenerator selected by Options::MemPar(). MTASVFGBuilder overrides this hook to inject a thread-aware (ThreadMRG) generator instead.

Reimplemented in SVF::MTASVFGBuilder.

Definition at line 101 of file SVFGBuilder.cpp.

102{
103 switch (Options::MemPar())
104 {
106 return std::make_unique<DistinctMRG>(pta, ptrOnlyMSSA);
108 return std::make_unique<IntraDisjointMRG>(pta, ptrOnlyMSSA);
110 return std::make_unique<InterDisjointMRG>(pta, ptrOnlyMSSA);
111 default:
112 assert(false && "unrecognised memory partition strategy");
113 return nullptr;
114 }
115}
@ InterDisjoint
Definition MemSSA.h:117
@ IntraDisjoint
Definition MemSSA.h:116
static const OptionMap< u32_t > MemPar
Definition Options.h:141

◆ getSVFG()

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

Get SVFG instance.

Definition at line 65 of file SVFGBuilder.h.

66 {
67 return svfg.get();
68 }

◆ 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 77 of file SVFGBuilder.h.

78 {
79 return vfEdgesAtIndCallSite.find(const_cast<SVFGEdge*>(edge))!=vfEdgesAtIndCallSite.end();
80 }
SVFGEdgeSet vfEdgesAtIndCallSite
SVFG Edges connected at indirect call/ret sites.
VFGEdge SVFGEdge
Definition SVFG.h:42

◆ markValidVFEdge()

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

Mark feasible VF edge by removing it from set vfEdgesAtIndCallSite.

Definition at line 71 of file SVFGBuilder.h.

72 {
73 for(SVFGEdgeSet::iterator it = edges.begin(), eit = edges.end(); it!=eit; ++it)
74 vfEdgesAtIndCallSite.erase(*it);
75 }

◆ 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 101 of file SVFGBuilder.h.

◆ SVFGWithIndCall

bool SVF::SVFGBuilder::SVFGWithIndCall
protected

SVFG with precomputed indirect call edges.

Definition at line 103 of file SVFGBuilder.h.

◆ SVFGWithPostOpts

bool SVF::SVFGBuilder::SVFGWithPostOpts
protected

Build optimised version of SVFG.

Definition at line 105 of file SVFGBuilder.h.

◆ vfEdgesAtIndCallSite

SVFGEdgeSet SVF::SVFGBuilder::vfEdgesAtIndCallSite
protected

SVFG Edges connected at indirect call/ret sites.

Definition at line 100 of file SVFGBuilder.h.


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