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

#include <WPAPass.h>

Public Types

enum  AliasCheckRule { Conservative , Veto , Precise }
 

Public Member Functions

 WPAPass ()
 Constructor needs TargetLibraryInfo to be passed to the AliasAnalysis.
 
virtual ~WPAPass ()
 Destructor.
 
virtual AliasResult alias (const SVFValue *V1, const SVFValue *V2)
 Interface expose to users of our pointer analysis, given Value infos.
 
virtual const PointsTogetPts (const SVFValue *value)
 Retrieve points-to set information.
 
virtual const PointsTogetPts (NodeID var)
 
virtual void PrintAliasPairs (PointerAnalysis *pta)
 Print all alias pairs.
 
virtual ModRefInfo getModRefInfo (const CallICFGNode *callInst)
 Interface of mod-ref analysis to determine whether a CallSite instruction can mod or ref any memory location.
 
virtual ModRefInfo getModRefInfo (const CallICFGNode *callInst, const SVFValue *V)
 Interface of mod-ref analysis to determine whether a CallSite instruction can mod or ref a specific memory location, given Location infos.
 
virtual ModRefInfo getModRefInfo (const CallICFGNode *callInst1, const CallICFGNode *callInst2)
 Interface of mod-ref analysis between two CallSite instructions.
 
virtual void runOnModule (SVFIR *svfModule)
 Run pointer analysis on SVFModule.
 
virtual std::string getPassName () const
 PTA name.
 

Static Public Attributes

static char ID = 0
 Pass ID.
 

Private Types

typedef std::vector< PointerAnalysis * > PTAVector
 

Private Member Functions

void runPointerAnalysis (SVFIR *pag, u32_t kind)
 Create pointer analysis according to specified kind and analyze the module.
 

Private Attributes

PTAVector ptaVector
 all pointer analysis to be executed.
 
PointerAnalysis_pta
 pointer analysis to be executed.
 
SVFG_svfg
 svfg generated through -ander pointer analysis
 

Detailed Description

Whole program pointer analysis. This class performs various pointer analysis on the given module.

Definition at line 54 of file WPAPass.h.

Member Typedef Documentation

◆ PTAVector

Definition at line 56 of file WPAPass.h.

Member Enumeration Documentation

◆ AliasCheckRule

Enumerator
Conservative 

return MayAlias if any pta says alias

Veto 

return NoAlias if any pta says no alias

Precise 

return alias result by the most precise pta

Definition at line 62 of file WPAPass.h.

63 {
65 Veto,
66 Precise
67 };
@ Conservative
return MayAlias if any pta says alias
Definition WPAPass.h:64
@ Precise
return alias result by the most precise pta
Definition WPAPass.h:66
@ Veto
return NoAlias if any pta says no alias
Definition WPAPass.h:65

Constructor & Destructor Documentation

◆ WPAPass()

SVF::WPAPass::WPAPass ( )
inline

Constructor needs TargetLibraryInfo to be passed to the AliasAnalysis.

Definition at line 70 of file WPAPass.h.

71 {
72
73 }

◆ ~WPAPass()

WPAPass::~WPAPass ( )
virtual

Destructor.

Destructor

Definition at line 54 of file WPAPass.cpp.

55{
56 PTAVector::const_iterator it = ptaVector.begin();
57 PTAVector::const_iterator eit = ptaVector.end();
58 for (; it != eit; ++it)
59 {
60 PointerAnalysis* pta = *it;
61 delete pta;
62 }
63 ptaVector.clear();
64}
PTAVector ptaVector
all pointer analysis to be executed.
Definition WPAPass.h:116
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

Member Function Documentation

◆ alias()

AliasResult WPAPass::alias ( const SVFValue V1,
const SVFValue V2 
)
virtual

Interface expose to users of our pointer analysis, given Value infos.

Return alias results based on our points-to/alias analysis TODO: Need to handle PartialAlias and MustAlias here.

TODO: When this method is invoked during compiler optimizations, the IR used for pointer analysis may been changed, so some Values may not find corresponding SVFIR node. In this case, we only check alias between two Values if they both have SVFIR nodes. Otherwise, MayAlias will be returned.

Veto is used by default

Return NoAlias if any PTA gives NoAlias result

Return MayAlias if any PTA gives MayAlias result

Definition at line 174 of file WPAPass.cpp.

175{
176
178
179 SVFIR* pag = _pta->getPAG();
180
186 if (pag->hasValueNode(V1) && pag->hasValueNode(V2))
187 {
189 if (Options::AliasRule.nothingSet() || Options::AliasRule(Veto))
190 {
193
194 for (PTAVector::const_iterator it = ptaVector.begin(), eit = ptaVector.end();
195 it != eit; ++it)
196 {
197 if ((*it)->alias(V1, V2) == AliasResult::NoAlias)
199 }
200 }
202 {
205
206 for (PTAVector::const_iterator it = ptaVector.begin(), eit = ptaVector.end();
207 it != eit; ++it)
208 {
209 if ((*it)->alias(V1, V2) == AliasResult::MayAlias)
211 }
212 }
213 }
214
215 return result;
216}
bool hasValueNode(const SVFValue *V)
Definition IRGraph.h:141
static OptionMultiple< WPAPass::AliasCheckRule > AliasRule
Definition Options.h:225
SVFIR * getPAG() const
PointerAnalysis * _pta
pointer analysis to be executed.
Definition WPAPass.h:117
AliasResult
Definition SVFType.h:527
@ MayAlias
Definition SVFType.h:529
@ NoAlias
Definition SVFType.h:528

◆ getModRefInfo() [1/3]

ModRefInfo WPAPass::getModRefInfo ( const CallICFGNode callInst)
virtual

Interface of mod-ref analysis to determine whether a CallSite instruction can mod or ref any memory location.

Return mod-ref result of a Callsite

Definition at line 221 of file WPAPass.cpp.

222{
223 assert(Options::PASelected(PointerAnalysis::AndersenWaveDiff_WPA) && Options::AnderSVFG() && "mod-ref query is only support with -ander and -svfg turned on");
224 return _svfg->getMSSA()->getMRGenerator()->getModRefInfo(callInst);
225}
ModRefInfo getModRefInfo(const CallICFGNode *cs)
MRGenerator * getMRGenerator()
Return MRGenerator.
Definition MemSSA.h:313
static OptionMultiple< PointerAnalysis::PTATY > PASelected
Definition Options.h:224
static const Option< bool > AnderSVFG
Definition Options.h:221
@ AndersenWaveDiff_WPA
Diff wave propagation andersen-style WPA.
MemSSA * getMSSA() const
Get SVFG memory SSA.
Definition SVFG.h:138
SVFG * _svfg
svfg generated through -ander pointer analysis
Definition WPAPass.h:118

◆ getModRefInfo() [2/3]

ModRefInfo WPAPass::getModRefInfo ( const CallICFGNode callInst,
const SVFValue V 
)
virtual

Interface of mod-ref analysis to determine whether a CallSite instruction can mod or ref a specific memory location, given Location infos.

Interface of mod-ref analysis to determine whether a CallSite instruction can mod or ref a specific memory location, given Value infos

Return mod-ref results of a Callsite to a specific memory location

Definition at line 230 of file WPAPass.cpp.

231{
232 assert(Options::PASelected(PointerAnalysis::AndersenWaveDiff_WPA) && Options::AnderSVFG() && "mod-ref query is only support with -ander and -svfg turned on");
233 return _svfg->getMSSA()->getMRGenerator()->getModRefInfo(callInst, V);
234}

◆ getModRefInfo() [3/3]

ModRefInfo WPAPass::getModRefInfo ( const CallICFGNode callInst1,
const CallICFGNode callInst2 
)
virtual

Interface of mod-ref analysis between two CallSite instructions.

Return mod-ref result between two CallInsts

Definition at line 239 of file WPAPass.cpp.

240{
241 assert(Options::PASelected(PointerAnalysis::AndersenWaveDiff_WPA) && Options::AnderSVFG() && "mod-ref query is only support with -ander and -svfg turned on");
243}

◆ getPassName()

virtual std::string SVF::WPAPass::getPassName ( ) const
inlinevirtual

PTA name.

Definition at line 107 of file WPAPass.h.

108 {
109 return "WPAPass";
110 }

◆ getPts() [1/2]

const PointsTo & WPAPass::getPts ( const SVFValue value)
virtual

Retrieve points-to set information.

Definition at line 157 of file WPAPass.cpp.

158{
159 assert(_pta && "initialize a pointer analysis first");
160 SVFIR* pag = _pta->getPAG();
161 return getPts(pag->getValueNode(value));
162}
NodeID getValueNode(const SVFValue *V)
Definition IRGraph.h:137
virtual const PointsTo & getPts(const SVFValue *value)
Retrieve points-to set information.
Definition WPAPass.cpp:157

◆ getPts() [2/2]

const PointsTo & WPAPass::getPts ( NodeID  var)
virtual

Definition at line 164 of file WPAPass.cpp.

165{
166 assert(_pta && "initialize a pointer analysis first");
167 return _pta->getPts(var);
168}
virtual const PointsTo & getPts(NodeID ptr)=0
Get points-to targets of a pointer. It needs to be implemented in child class.

◆ PrintAliasPairs()

void WPAPass::PrintAliasPairs ( PointerAnalysis pta)
virtual

Print all alias pairs.

Definition at line 133 of file WPAPass.cpp.

134{
135 SVFIR* pag = pta->getPAG();
136 for (SVFIR::iterator lit = pag->begin(), elit = pag->end(); lit != elit; ++lit)
137 {
138 PAGNode* node1 = lit->second;
140 for (SVFIR::iterator rit = lit, erit = pag->end(); rit != erit; ++rit)
141 {
142 node2 = rit->second;
143 if(node1==node2)
144 continue;
145 const SVFFunction* fun1 = node1->getFunction();
146 const SVFFunction* fun2 = node2->getFunction();
147 AliasResult result = pta->alias(node1->getId(), node2->getId());
148 SVFUtil::outs() << (result == AliasResult::NoAlias ? "NoAlias" : "MayAlias")
149 << " var" << node1->getId() << "[" << node1->getValueName()
150 << "@" << (fun1==nullptr?"":fun1->getName()) << "] --"
151 << " var" << node2->getId() << "[" << node2->getValueName()
152 << "@" << (fun2==nullptr?"":fun2->getName()) << "]\n";
153 }
154 }
155}
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.
virtual AliasResult alias(const SVFValue *V1, const SVFValue *V2)=0
Interface exposed to users of our pointer analysis, given Value infos.
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:50

◆ runOnModule()

void WPAPass::runOnModule ( SVFIR pag)
virtual

Run pointer analysis on SVFModule.

We start from here

Definition at line 69 of file WPAPass.cpp.

70{
71 for (u32_t i = 0; i<= PointerAnalysis::Default_PTA; i++)
72 {
76 }
77 assert(!ptaVector.empty() && "No pointer analysis is specified.\n");
78}
unsigned u32_t
Definition CommandLine.h:18
PTATY
Pointer analysis type list.
@ Default_PTA
default pta without any analysis
void runPointerAnalysis(SVFIR *pag, u32_t kind)
Create pointer analysis according to specified kind and analyze the module.
Definition WPAPass.cpp:83

◆ runPointerAnalysis()

void WPAPass::runPointerAnalysis ( SVFIR pag,
u32_t  kind 
)
private

Create pointer analysis according to specified kind and analyze the module.

Create pointer analysis according to a specified kind and then analyze the module.

Initialize pointer analysis.

support mod-ref queries only for -ander

Definition at line 83 of file WPAPass.cpp.

84{
86 switch (kind)
87 {
89 _pta = new Andersen(pag);
90 break;
92 _pta = new AndersenSCD(pag);
93 break;
95 _pta = new AndersenSFR(pag);
96 break;
98 _pta = new AndersenWaveDiff(pag);
99 break;
101 _pta = new Steensgaard(pag);
102 break;
104 _pta = new FlowSensitive(pag);
105 break;
107 _pta = new VersionedFlowSensitive(pag);
108 break;
110 _pta = new TypeAnalysis(pag);
111 break;
112 default:
113 assert(false && "This pointer analysis has not been implemented yet.\n");
114 return;
115 }
116
117 ptaVector.push_back(_pta);
118 _pta->analyze();
119 if (Options::AnderSVFG())
120 {
121 SVFGBuilder memSSA(true);
122 assert(SVFUtil::isa<AndersenBase>(_pta) && "supports only andersen/steensgaard for pre-computed SVFG");
123 SVFG *svfg = memSSA.buildFullSVFG((BVDataPTAImpl*)_pta);
126 _svfg = svfg;
127 }
128
131}
static const Option< bool > PrintAliases
Definition Options.h:223
@ VFS_WPA
Versioned sparse flow-sensitive WPA.
@ AndersenSCD_WPA
Selective cycle detection andersen-style WPA.
@ Andersen_WPA
Andersen PTA.
@ TypeCPP_WPA
Type-based analysis for C++.
@ AndersenSFR_WPA
Stride-based field representation.
@ Steensgaard_WPA
Steensgaard PTA.
@ FSSPARSE_WPA
Sparse flow sensitive WPA.
virtual void analyze()=0
Start Analysis here (main part of pointer analysis). It needs to be implemented in child class.
virtual void PrintAliasPairs(PointerAnalysis *pta)
Print all alias pairs.
Definition WPAPass.cpp:133

Member Data Documentation

◆ _pta

PointerAnalysis* SVF::WPAPass::_pta
private

pointer analysis to be executed.

Definition at line 117 of file WPAPass.h.

◆ _svfg

SVFG* SVF::WPAPass::_svfg
private

svfg generated through -ander pointer analysis

Definition at line 118 of file WPAPass.h.

◆ ID

char WPAPass::ID = 0
static

Pass ID.

Definition at line 60 of file WPAPass.h.

◆ ptaVector

PTAVector SVF::WPAPass::ptaVector
private

all pointer analysis to be executed.

Definition at line 116 of file WPAPass.h.


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