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

#include <AEWTO.h>

Public Types

typedef SCCDetection< CallGraph * > CallGraphSCC
 

Public Member Functions

 AEWTO (SVFIR *pag, ICFG *icfg)
 
virtual ~AEWTO ()
 
AndersenWaveDiffgetPointerAnalysis () const
 Accessors for Andersen's results.
 
CallGraphgetCallGraph () const
 
CallGraphSCCgetCallGraphSCC () const
 
void initWTO ()
 Build WTO for each function using call graph SCC.
 
const Map< const FunObjVar *, const ICFGWTO * > & getFuncToWTO () const
 Accessors for WTO data.
 
void initCycleValVars ()
 
const Set< const ValVar * > getCycleValVars (const ICFGCycleWTO *cycle) const
 

Private Attributes

SVFIRsvfir
 
ICFGicfg
 
AndersenWaveDiffpta
 
CallGraphcallGraph
 
CallGraphSCCcallGraphSCC
 
Map< const FunObjVar *, const ICFGWTO * > funcToWTO
 
Map< const ICFGCycleWTO *, Set< const ValVar * > > cycleToValVars
 

Detailed Description

Definition at line 47 of file AEWTO.h.

Member Typedef Documentation

◆ CallGraphSCC

Definition at line 50 of file AEWTO.h.

Constructor & Destructor Documentation

◆ AEWTO()

AEWTO::AEWTO ( SVFIR pag,
ICFG icfg 
)

Definition at line 37 of file AEWTO.cpp.

38 : svfir(pag), icfg(icfg), pta(nullptr), callGraph(nullptr), callGraphSCC(nullptr)
39{
43}
ICFG * icfg
Definition AEWTO.h:91
SVFIR * svfir
Definition AEWTO.h:90
AndersenWaveDiff * pta
Definition AEWTO.h:92
CallGraph * callGraph
Definition AEWTO.h:93
CallGraphSCC * callGraphSCC
Definition AEWTO.h:94
static AndersenWaveDiff * createAndersenWaveDiff(SVFIR *_pag)
Create an singleton instance directly instead of invoking llvm pass manager.
Definition Andersen.h:407
CallGraph * getCallGraph() const
Return call graph.
CallGraphSCC * getCallGraphSCC() const
Return call graph SCC.

◆ ~AEWTO()

AEWTO::~AEWTO ( )
virtual

Definition at line 45 of file AEWTO.cpp.

46{
47 for (auto& [func, wto] : funcToWTO)
48 delete wto;
49}
Map< const FunObjVar *, const ICFGWTO * > funcToWTO
Definition AEWTO.h:96
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

Member Function Documentation

◆ getCallGraph()

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

Definition at line 60 of file AEWTO.h.

61 {
62 return callGraph;
63 }

◆ getCallGraphSCC()

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

Definition at line 64 of file AEWTO.h.

65 {
66 return callGraphSCC;
67 }

◆ getCycleValVars()

const Set< const ValVar * > SVF::AEWTO::getCycleValVars ( const ICFGCycleWTO cycle) const
inline

Look up the ValVar id set of a WTO cycle. Returns nullptr if the cycle is unknown (e.g. dense mode, where the map is never built).

Definition at line 83 of file AEWTO.h.

84 {
85 auto it = cycleToValVars.find(cycle);
86 return it == cycleToValVars.end() ? Set<const ValVar*>() : it->second;
87 }
Map< const ICFGCycleWTO *, Set< const ValVar * > > cycleToValVars
Definition AEWTO.h:101

◆ getFuncToWTO()

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

Accessors for WTO data.

Definition at line 72 of file AEWTO.h.

73 {
74 return funcToWTO;
75 }

◆ getPointerAnalysis()

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

Accessors for Andersen's results.

Definition at line 56 of file AEWTO.h.

57 {
58 return pta;
59 }

◆ initCycleValVars()

void AEWTO::initCycleValVars ( )

Walk every function's WTO and populate cycleToValVars bottom-up. Called once right after initWTO(). No-op in dense mode.

Definition at line 98 of file AEWTO.cpp.

99{
100 // Step 1: Collect all cycles in top-down order using a stack-based DFS,
101 // then reverse to get bottom-up order (inner cycles before outer ones).
102 std::vector<const ICFGCycleWTO*> cycles;
103 {
104 std::vector<const ICFGWTOComp*> stack;
105 for (const auto& kv : funcToWTO)
106 {
107 if (!kv.second) continue;
108 for (const ICFGWTOComp* comp : kv.second->getWTOComponents())
110 }
111 while (!stack.empty())
112 {
113 const ICFGWTOComp* comp = stack.back();
114 stack.pop_back();
115 if (const ICFGCycleWTO* cycle = SVFUtil::dyn_cast<ICFGCycleWTO>(comp))
116 {
117 for (const ICFGWTOComp* sub : cycle->getWTOComponents())
119 cycles.push_back(cycle);
120 }
121 }
122 std::reverse(cycles.begin(), cycles.end());
123 }
124
125 // Step 2: Build ValVar sets bottom-up. Inner cycles are already in the
126 // map when we reach their enclosing cycle.
127 for (const ICFGCycleWTO* cycle : cycles)
128 {
130
131 // Gather every ICFG node in this cycle (head + body singletons).
132 // For nested sub-cycles, merge their already-computed sets instead.
133 std::vector<const ICFGNode*> nodes;
134 nodes.push_back(cycle->head()->getICFGNode());
135 for (const ICFGWTOComp* comp : cycle->getWTOComponents())
136 {
137 if (const ICFGSingletonWTO* s = SVFUtil::dyn_cast<ICFGSingletonWTO>(comp))
138 nodes.push_back(s->getICFGNode());
139 else if (const ICFGCycleWTO* sub = SVFUtil::dyn_cast<ICFGCycleWTO>(comp))
140 out.insert(cycleToValVars[sub].begin(), cycleToValVars[sub].end());
141 }
142
143 // For each node, collect LHS ValVar IDs from its statements.
144 for (const ICFGNode* node : nodes)
145 {
146 for (const SVFStmt* stmt : node->getSVFStmts())
147 {
148 const ValVar* lhs = nullptr;
149 if (const AssignStmt* a = SVFUtil::dyn_cast<AssignStmt>(stmt))
150 lhs = SVFUtil::dyn_cast<ValVar>(a->getLHSVar());
151 else if (const MultiOpndStmt* m = SVFUtil::dyn_cast<MultiOpndStmt>(stmt))
152 lhs = m->getRes();
153 if (lhs)
154 out.insert(lhs);
155 }
156 // FunEntryICFGNode owns ArgValVars (formal parameters) that have
157 // no defining stmt at the entry — the CallPE lives on the caller
158 // side. For recursive cycles whose head is a FunEntry, we need
159 // these IDs so widening/narrowing observes them across iterations.
160 if (const FunEntryICFGNode* fe = SVFUtil::dyn_cast<FunEntryICFGNode>(node))
161 {
162 for (const SVFVar* fp : fe->getFormalParms())
163 if (const ValVar* v = SVFUtil::dyn_cast<ValVar>(fp))
164 out.insert(v);
165 }
166 }
167 }
168}
if(prebuffer< 0)
Definition cJSON.cpp:1269
cJSON * a
Definition cJSON.cpp:2560
LLVM_NODISCARD std::enable_if_t<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type > dyn_cast(const Y &Val)
Definition Casting.h:405
WTONode< ICFG > ICFGSingletonWTO
Definition ICFGWTO.h:45
iter_range< typename GenericGraphTraits< GraphType >::nodes_iterator > nodes(const GraphType &G)
WTOComponent< ICFG > ICFGWTOComp
Definition ICFGWTO.h:44

◆ initWTO()

void AEWTO::initWTO ( )

Build WTO for each function using call graph SCC.

Definition at line 51 of file AEWTO.cpp.

52{
53 callGraphSCC->find();
54
55 for (auto it = callGraph->begin(); it != callGraph->end(); it++)
56 {
57 const FunObjVar *fun = it->second->getFunction();
58 if (fun->isDeclaration())
59 continue;
60
61 NodeID repNodeId = callGraphSCC->repNode(it->second->getId());
62 auto cgSCCNodes = callGraphSCC->subNodes(repNodeId);
63
64 bool isEntry = false;
65 if (it->second->getInEdges().empty())
66 isEntry = true;
67 for (auto inEdge: it->second->getInEdges())
68 {
69 NodeID srcNodeId = inEdge->getSrcID();
70 if (!cgSCCNodes.test(srcNodeId))
71 isEntry = true;
72 }
73
74 if (isEntry)
75 {
77 for (const auto& node: cgSCCNodes)
78 {
79 funcScc.insert(callGraph->getGNode(node)->getFunction());
80 }
82 iwto->init();
83 funcToWTO[it->second->getFunction()] = iwto;
84 }
85 }
86
87}
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::AEWTO::callGraph
private

Definition at line 93 of file AEWTO.h.

◆ callGraphSCC

CallGraphSCC* SVF::AEWTO::callGraphSCC
private

Definition at line 94 of file AEWTO.h.

◆ cycleToValVars

Map<const ICFGCycleWTO*, Set<const ValVar*> > SVF::AEWTO::cycleToValVars
private

Pre-computed (semi-sparse only) map from a WTO cycle to the IDs of every ValVar whose def-site is inside that cycle, including all nested sub-cycles. Empty in dense mode.

Definition at line 101 of file AEWTO.h.

◆ funcToWTO

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

Definition at line 96 of file AEWTO.h.

◆ icfg

ICFG* SVF::AEWTO::icfg
private

Definition at line 91 of file AEWTO.h.

◆ pta

AndersenWaveDiff* SVF::AEWTO::pta
private

Definition at line 92 of file AEWTO.h.

◆ svfir

SVFIR* SVF::AEWTO::svfir
private

Definition at line 90 of file AEWTO.h.


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