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 const PointsTogetPts (NodeID var)
 Retrieve points-to set information.
 
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 *callInst1, const CallICFGNode *callInst2)
 Interface of mod-ref analysis to determine whether a CallSite instruction can mod or ref a specific memory location, given Location infos.
 
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 57 of file WPAPass.h.

Member Typedef Documentation

◆ PTAVector

Definition at line 59 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 65 of file WPAPass.h.

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

Constructor & Destructor Documentation

◆ WPAPass()

SVF::WPAPass::WPAPass ( )
inline

Constructor needs TargetLibraryInfo to be passed to the AliasAnalysis.

Definition at line 73 of file WPAPass.h.

74 {
75
76 }

◆ ~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:112
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

Member Function Documentation

◆ getModRefInfo() [1/2]

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 167 of file WPAPass.cpp.

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

◆ getModRefInfo() [2/2]

ModRefInfo WPAPass::getModRefInfo ( const CallICFGNode callInst1,
const CallICFGNode callInst2 
)
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 between two CallSite instructions

Return mod-ref result between two CallInsts

Definition at line 177 of file WPAPass.cpp.

178{
179 assert(Options::PASelected(PTATY::AndersenWaveDiff_WPA) && Options::AnderSVFG() && "mod-ref query is only support with -ander and -svfg turned on");
181}

◆ getPassName()

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

PTA name.

Definition at line 103 of file WPAPass.h.

104 {
105 return "WPAPass";
106 }

◆ getPts()

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

Retrieve points-to set information.

Definition at line 158 of file WPAPass.cpp.

159{
160 assert(_pta && "initialize a pointer analysis first");
161 return _pta->getPts(var);
162}
virtual const PointsTo & getPts(NodeID ptr)=0
Get points-to targets of a pointer. It needs to be implemented in child class.
PointerAnalysis * _pta
pointer analysis to be executed.
Definition WPAPass.h:113

◆ 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 FunObjVar* fun1 = node1->getFunction();
146 const FunObjVar* 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->getName()
150 << "@" << (fun1==nullptr?"":fun1->getName()) << "] --"
151 << " var" << node2->getId() << "[" << node2->getName()
152 << "@" << (fun2==nullptr?"":fun2->getName()) << "]\n";
153 }
154 }
155}
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
iterator begin()
Iterators.
IDToNodeMapTy::iterator iterator
Node Iterators.
SVFIR * getPAG() const
virtual AliasResult alias(const SVFVar *V1, const SVFVar *V2)=0
Interface exposed to users of our pointer analysis, given Value infos.
std::ostream & outs()
Overwrite llvm::outs()
Definition SVFUtil.h:52
AliasResult
Definition SVFType.h:619
@ NoAlias
Definition SVFType.h:620

◆ 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<= PTATY::Default_PTA; i++)
72 {
73 PTATY iPtaTy = static_cast<PTATY>(i);
76 }
77 assert(!ptaVector.empty() && "No pointer analysis is specified.\n");
78}
unsigned u32_t
Definition CommandLine.h:18
void runPointerAnalysis(SVFIR *pag, u32_t kind)
Create pointer analysis according to specified kind and analyze the module.
Definition WPAPass.cpp:83
PTATY
Pointer analysis type list.
Definition PTATY.h:9
@ Default_PTA
default pta without any analysis
Definition PTATY.h:35

◆ 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;
106 case PTATY::VFS_WPA:
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:216
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
@ VFS_WPA
Versioned sparse flow-sensitive WPA.
Definition PTATY.h:21
@ Andersen_WPA
Andersen PTA.
Definition PTATY.h:12
@ FSSPARSE_WPA
Sparse flow sensitive WPA.
Definition PTATY.h:20
@ AndersenSFR_WPA
Stride-based field representation.
Definition PTATY.h:14
@ TypeCPP_WPA
Type-based analysis for C++.
Definition PTATY.h:26
@ Steensgaard_WPA
Steensgaard PTA.
Definition PTATY.h:16
@ AndersenSCD_WPA
Selective cycle detection andersen-style WPA.
Definition PTATY.h:13

Member Data Documentation

◆ _pta

PointerAnalysis* SVF::WPAPass::_pta
private

pointer analysis to be executed.

Definition at line 113 of file WPAPass.h.

◆ _svfg

SVFG* SVF::WPAPass::_svfg
private

svfg generated through -ander pointer analysis

Definition at line 114 of file WPAPass.h.

◆ ID

char WPAPass::ID = 0
static

Pass ID.

Definition at line 63 of file WPAPass.h.

◆ ptaVector

PTAVector SVF::WPAPass::ptaVector
private

all pointer analysis to be executed.

Definition at line 112 of file WPAPass.h.


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