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

#include <PreAnalysis.h>

Public Types

typedef SCCDetection< CallGraph * > CallGraphSCC
 

Public Member Functions

 PreAnalysis (SVFIR *pag, ICFG *icfg)
 
virtual ~PreAnalysis ()
 
AndersenWaveDiffgetPointerAnalysis () const
 Accessors for Andersen's results.
 
CallGraphgetCallGraph () const
 
CallGraphSCCgetCallGraphSCC () const
 
SVFGgetSVFG () const
 
const Set< const ICFGNode * > getUseSitesOfObjVar (const ObjVar *obj, const ICFGNode *node) const
 Given an ObjVar and its def-site ICFGNode, find all use-site ICFGNodes.
 
const Set< const ICFGNode * > getUseSitesOfValVar (const ValVar *var) const
 
const ICFGNodegetDefSiteOfValVar (const ValVar *var) const
 
const ICFGNodegetDefSiteOfObjVar (const ObjVar *obj, const ICFGNode *node) const
 
void initWTO ()
 Build WTO for each function using call graph SCC.
 
const Map< const FunObjVar *, const ICFGWTO * > & getFuncToWTO () const
 Accessors for WTO data.
 

Private Attributes

SVFIRsvfir
 
ICFGicfg
 
SVFGsvfg
 
AndersenWaveDiffpta
 
CallGraphcallGraph
 
CallGraphSCCcallGraphSCC
 
Map< const FunObjVar *, const ICFGWTO * > funcToWTO
 

Detailed Description

Definition at line 47 of file PreAnalysis.h.

Member Typedef Documentation

◆ CallGraphSCC

Definition at line 50 of file PreAnalysis.h.

Constructor & Destructor Documentation

◆ PreAnalysis()

PreAnalysis::PreAnalysis ( SVFIR pag,
ICFG icfg 
)

Definition at line 37 of file PreAnalysis.cpp.

38 : svfir(pag), icfg(icfg), svfg(nullptr), pta(nullptr), callGraph(nullptr), callGraphSCC(nullptr)
39{
44 {
45 SVFGBuilder memSSA(true);
46 svfg = memSSA.buildFullSVFG(pta);
47 }
48}
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition Andersen.h:407
static const Option< bool > SparseAE
Definition Options.h:243
CallGraph * getCallGraph() const
Return call graph.
CallGraphSCC * getCallGraphSCC() const
Return call graph SCC.
CallGraphSCC * callGraphSCC
AndersenWaveDiff * pta
CallGraph * callGraph

◆ ~PreAnalysis()

PreAnalysis::~PreAnalysis ( )
virtual

Definition at line 50 of file PreAnalysis.cpp.

51{
52 for (auto& [func, wto] : funcToWTO)
53 delete wto;
54}
Map< const FunObjVar *, const ICFGWTO * > funcToWTO
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

Member Function Documentation

◆ getCallGraph()

CallGraph * SVF::PreAnalysis::getCallGraph ( ) const
inline

Definition at line 60 of file PreAnalysis.h.

61 {
62 return callGraph;
63 }

◆ getCallGraphSCC()

CallGraphSCC * SVF::PreAnalysis::getCallGraphSCC ( ) const
inline

Definition at line 64 of file PreAnalysis.h.

65 {
66 return callGraphSCC;
67 }

◆ getDefSiteOfObjVar()

const ICFGNode * PreAnalysis::getDefSiteOfObjVar ( const ObjVar obj,
const ICFGNode node 
) const

Given an ObjVar and its use-site ICFGNode, find the definition-site ICFGNode by following incoming IndirectSVFGEdges whose pts contains the ObjVar (asserts unique definition)

Definition at line 98 of file PreAnalysis.cpp.

99{
100 if (Options::SparseAE())
101 {
102 assert(svfg && "SVFG is not built for sparse AE");
103 return svfg->getDefSiteOfObjVar(obj, node);
104 }
105 // Non-sparse mode: return ICFG predecessor node
106 for (const auto* edge : node->getInEdges())
107 return edge->getSrcNode();
108 return nullptr;
109}
return(char *) p.buffer
const ICFGNode * getDefSiteOfObjVar(const ObjVar *obj, const ICFGNode *node) const
Definition SVFG.cpp:772

◆ getDefSiteOfValVar()

const ICFGNode * PreAnalysis::getDefSiteOfValVar ( const ValVar var) const

Given a ValVar and its SVFGNode, find the definition-site ICFGNode by following incoming direct VFGEdges (asserts unique definition)

Definition at line 87 of file PreAnalysis.cpp.

88{
90 {
91 assert(svfg && "SVFG is not built for sparse AE");
93 }
94 // Non-sparse mode: return the ValVar's associated ICFGNode
95 return var->getICFGNode();
96}
const ICFGNode * getDefSiteOfValVar(const ValVar *var) const
Definition SVFG.cpp:765

◆ getFuncToWTO()

const Map< const FunObjVar *, const ICFGWTO * > & SVF::PreAnalysis::getFuncToWTO ( ) const
inline

Accessors for WTO data.

Definition at line 91 of file PreAnalysis.h.

92 {
93 return funcToWTO;
94 }

◆ getPointerAnalysis()

AndersenWaveDiff * SVF::PreAnalysis::getPointerAnalysis ( ) const
inline

Accessors for Andersen's results.

Definition at line 56 of file PreAnalysis.h.

57 {
58 return pta;
59 }

◆ getSVFG()

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

Definition at line 68 of file PreAnalysis.h.

69 {
70 return svfg;
71 }

◆ getUseSitesOfObjVar()

const Set< const ICFGNode * > PreAnalysis::getUseSitesOfObjVar ( const ObjVar obj,
const ICFGNode node 
) const

Given an ObjVar and its def-site ICFGNode, find all use-site ICFGNodes.

Definition at line 56 of file PreAnalysis.cpp.

57{
59 {
60 assert(svfg && "SVFG is not built for sparse AE");
61 return svfg->getUseSitesOfObjVar(obj, node);
62 }
63 // Non-sparse mode: return ICFG successor nodes
65 for (const auto* edge : node->getOutEdges())
66 succs.insert(edge->getDstNode());
67 return succs;
68}
const Set< const ICFGNode * > getUseSitesOfObjVar(const ObjVar *obj, const ICFGNode *node) const
Definition SVFG.cpp:815

◆ getUseSitesOfValVar()

const Set< const ICFGNode * > PreAnalysis::getUseSitesOfValVar ( const ValVar var) const

Given a ValVar, find all use-site ICFGNodes by following outgoing direct VFGEdges from its unique definition SVFGNode

Definition at line 70 of file PreAnalysis.cpp.

71{
73 {
74 assert(svfg && "SVFG is not built for sparse AE");
76 }
77 // Non-sparse mode: return ICFG successor nodes of the ValVar's ICFGNode
79 if (const ICFGNode* node = var->getICFGNode())
80 {
81 for (const auto* edge : node->getOutEdges())
82 succs.insert(edge->getDstNode());
83 }
84 return succs;
85}
const Set< const ICFGNode * > getUseSitesOfValVar(const ValVar *var) const
Definition SVFG.cpp:795

◆ initWTO()

void PreAnalysis::initWTO ( )

Build WTO for each function using call graph SCC.

Definition at line 111 of file PreAnalysis.cpp.

112{
113 callGraphSCC->find();
114
115 for (auto it = callGraph->begin(); it != callGraph->end(); it++)
116 {
117 const FunObjVar *fun = it->second->getFunction();
118 if (fun->isDeclaration())
119 continue;
120
121 NodeID repNodeId = callGraphSCC->repNode(it->second->getId());
122 auto cgSCCNodes = callGraphSCC->subNodes(repNodeId);
123
124 bool isEntry = false;
125 if (it->second->getInEdges().empty())
126 isEntry = true;
127 for (auto inEdge: it->second->getInEdges())
128 {
129 NodeID srcNodeId = inEdge->getSrcID();
130 if (!cgSCCNodes.test(srcNodeId))
131 isEntry = true;
132 }
133
134 if (isEntry)
135 {
137 for (const auto& node: cgSCCNodes)
138 {
139 funcScc.insert(callGraph->getGNode(node)->getFunction());
140 }
142 iwto->init();
143 funcToWTO[it->second->getFunction()] = iwto;
144 }
145 }
146
147}
virtual const FunObjVar * getFunction() const
Get containing function, or null for globals/constants.
bool isDeclaration() const
iterator begin()
Iterators.
NodeType * getGNode(NodeID id) const
Get a node.
FunEntryICFGNode * getFunEntryICFGNode(const FunObjVar *fun)
Add a function entry node.
Definition ICFG.cpp:242
u32_t NodeID
Definition GeneralType.h:56

Member Data Documentation

◆ callGraph

CallGraph* SVF::PreAnalysis::callGraph
private

Definition at line 101 of file PreAnalysis.h.

◆ callGraphSCC

CallGraphSCC* SVF::PreAnalysis::callGraphSCC
private

Definition at line 102 of file PreAnalysis.h.

◆ funcToWTO

Map<const FunObjVar*, const ICFGWTO*> SVF::PreAnalysis::funcToWTO
private

Definition at line 104 of file PreAnalysis.h.

◆ icfg

ICFG* SVF::PreAnalysis::icfg
private

Definition at line 98 of file PreAnalysis.h.

◆ pta

AndersenWaveDiff* SVF::PreAnalysis::pta
private

Definition at line 100 of file PreAnalysis.h.

◆ svfg

SVFG* SVF::PreAnalysis::svfg
private

Definition at line 99 of file PreAnalysis.h.

◆ svfir

SVFIR* SVF::PreAnalysis::svfir
private

Definition at line 97 of file PreAnalysis.h.


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