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::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.
 
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

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.
 

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.

bool SVFGWithIndCall
SVFG with precomputed indirect call edges.
Definition SVFGBuilder.h:93
std::unique_ptr< SVFG > svfg
Definition SVFGBuilder.h:91
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

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

67{
68
69 auto mssa = buildMSSA(pta, (VFG::PTRONLYSVFG==kind || VFG::PTRONLYSVFG_OPT==kind));
70
71 DBOUT(DGENERAL, outs() << pasMsg("Build Sparse Value-Flow Graph \n"));
72 if(kind == VFG::FULLSVFG_OPT || kind == VFG::PTRONLYSVFG_OPT)
73 svfg = std::make_unique<SVFGOPT>(std::move(mssa), kind);
74 else
75 svfg = std::unique_ptr<SVFG>(new SVFG(std::move(mssa),kind));
76 buildSVFG();
77
80 svfg->updateCallGraph(pta);
81
82 if(svfg->getMSSA()->getPTA()->printStat())
83 svfg->performStat();
84
86 svfg->dump("svfg_final");
87
88 return svfg.get();
89}
#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.
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:100
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50

◆ buildFullSVFG()

SVFG * SVFGBuilder::buildFullSVFG ( BVDataPTAImpl pta)

Definition at line 51 of file SVFGBuilder.cpp.

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

◆ buildMSSA()

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

Build Memory SSA.

Definition at line 99 of file SVFGBuilder.cpp.

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

◆ buildPTROnlySVFG()

SVFG * SVFGBuilder::buildPTROnlySVFG ( BVDataPTAImpl pta)

Definition at line 43 of file SVFGBuilder.cpp.

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

◆ buildSVFG()

void SVFGBuilder::buildSVFG ( )
protectedvirtual

Can be rewritten by subclasses.

Create SVFG

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

Definition at line 60 of file SVFGBuilder.cpp.

61{
62 svfg->buildSVFG();
63}

◆ 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:42

◆ 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)
71 }

◆ releaseMemory()

void SVFGBuilder::releaseMemory ( )
protectedvirtual

Release global SVFG.

Release memory

Definition at line 94 of file SVFGBuilder.cpp.

95{
96 svfg->clearMSSA();
97}

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: