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

#include <CSC.h>

Public Types

typedef Map< NodeID, NodeIDIdToIdMap
 
typedef FILOWorkList< NodeIDWorkStack
 
typedef IdToIdMap::iterator iterator
 

Public Member Functions

 CSC (ConstraintGraph *g, CGSCC *c)
 
void find (NodeStack &candidates)
 
void visit (NodeID nodeId, s32_t _w)
 
void clear ()
 
bool isVisited (NodeID nId)
 
void setVisited (NodeID nId)
 

Private Attributes

ConstraintGraph_consG
 
CGSCC_scc
 
NodeID _I
 
IdToIdMap _D
 
NodeStack _S
 
NodeSet _visited
 

Detailed Description

class CSC: cycle stride calculation

Definition at line 49 of file CSC.h.

Member Typedef Documentation

◆ IdToIdMap

Definition at line 52 of file CSC.h.

◆ iterator

typedef IdToIdMap::iterator SVF::CSC::iterator

Definition at line 54 of file CSC.h.

◆ WorkStack

Definition at line 53 of file CSC.h.

Constructor & Destructor Documentation

◆ CSC()

SVF::CSC::CSC ( ConstraintGraph g,
CGSCC c 
)
inline

Definition at line 68 of file CSC.h.

69 : _consG(g), _scc(c), _I(0) {}
ConstraintGraph * _consG
Definition CSC.h:57
CGSCC * _scc
Definition CSC.h:58
NodeID _I
Definition CSC.h:60
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:74

Member Function Documentation

◆ clear()

void CSC::clear ( )

Definition at line 39 of file CSC.cpp.

40{
41 _I = 0;
42 _D.clear();
43}
IdToIdMap _D
Definition CSC.h:61

◆ find()

void CSC::find ( NodeStack candidates)

Definition at line 49 of file CSC.cpp.

50{
51 clear();
52
54 while (!candidates.empty())
55 {
56 NodeID nId = candidates.top();
57 revCandidates.push(nId);
58 candidates.pop();
59
60 if (_scc->subNodes(nId).count()>1 && !isVisited(nId)) // node is actually in a cycle
61 visit(nId, 0);
62 }
63
64 while (!revCandidates.empty())
65 {
66 NodeID nId = revCandidates.top();
67 candidates.push(nId);
68 revCandidates.pop();
69 }
70}
void visit(NodeID nodeId, s32_t _w)
Definition CSC.cpp:76
bool isVisited(NodeID nId)
Definition CSC.h:75
void clear()
Definition CSC.cpp:39
std::stack< NodeID > NodeStack
u32_t NodeID
Definition GeneralType.h:55

◆ isVisited()

bool SVF::CSC::isVisited ( NodeID  nId)
inline

Definition at line 75 of file CSC.h.

76 {
77 return _visited.find(nId) != _visited.end();
78 }
NodeSet _visited
Definition CSC.h:63

◆ setVisited()

void SVF::CSC::setVisited ( NodeID  nId)
inline

Definition at line 80 of file CSC.h.

81 {
82 _visited.insert(nId);
83 }

◆ visit()

void CSC::visit ( NodeID  nodeId,
s32_t  _w 
)

Definition at line 76 of file CSC.cpp.

77{
78// pwcReps[nodeId] = _scc->repNode(nodeId);
80
81 _I += _w;
82 _D[nodeId] = _I;
83 _S.push(nodeId);
84
87 {
89 if (NormalGepCGEdge* gepCGEdge = SVFUtil::dyn_cast<NormalGepCGEdge>(*eit))
90 offset = gepCGEdge->getConstantFieldIdx();
91 else
92 offset = 0;
93 NodeID dstId = (*eit)->getDstID();
94 if (_scc->repNode(nodeId) == _scc->repNode(dstId) && !isVisited(dstId))
96 }
97
99 NodeSet _C;
100
101 while (!_S.empty())
102 {
103 NodeID backNodeId = _S.top();
104 _S.pop();
105 _revS.push(backNodeId);
108 {
109 NormalGepCGEdge* normalGep = SVFUtil::dyn_cast<NormalGepCGEdge>(_consG->getEdge(node, backNode, ConstraintEdge::NormalGep));
110 s32_t _w = normalGep->getConstantFieldIdx();
112 backNode->strides.set(_l);
113 for (auto cNodeId : _C)
114 _consG->getConstraintNode(cNodeId)->strides.set(_l);
115 }
118 {
120 backNode->strides.set(_l);
121 for (auto cNodeId : _C)
122 _consG->getConstraintNode(cNodeId)->strides.set(_l);
123 }
124 _C.insert(backNodeId);
125 }
126
127 while (!_revS.empty())
128 {
129 NodeID backedId = _revS.top();
130 _S.push(backedId);
131 _revS.pop();
132 }
133
134 _S.pop(); // after checking all the edges of the top node of _S, remove the node
135}
set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) add_llvm_executable(wpa wpa.cpp) target_link_libraries(wpa PUBLIC $
Definition CMakeLists.txt:1
buffer offset
Definition cJSON.cpp:1113
NodeStack _S
Definition CSC.h:62
void setVisited(NodeID nId)
Definition CSC.h:80
bool hasEdge(ConstraintNode *src, ConstraintNode *dst, ConstraintEdge::ConstraintEdgeK kind)
Definition ConsG.h:130
ConstraintNode * getConstraintNode(NodeID id) const
Get/add/remove constraint node.
Definition ConsG.h:109
ConstraintEdge * getEdge(ConstraintNode *src, ConstraintNode *dst, ConstraintEdge::ConstraintEdgeK kind)
Get an edge via its src and dst nodes and kind.
Definition ConsG.h:148
iterator directOutEdgeEnd()
Definition ConsG.cpp:674
ConstraintEdge::ConstraintEdgeSetTy::const_iterator const_iterator
Definition ConsGNode.h:45
iterator directOutEdgeBegin()
Iterators.
Definition ConsG.cpp:666
Set< NodeID > NodeSet
signed s32_t
Definition GeneralType.h:47

Member Data Documentation

◆ _consG

ConstraintGraph* SVF::CSC::_consG
private

Definition at line 57 of file CSC.h.

◆ _D

IdToIdMap SVF::CSC::_D
private

Definition at line 61 of file CSC.h.

◆ _I

NodeID SVF::CSC::_I
private

Definition at line 60 of file CSC.h.

◆ _S

NodeStack SVF::CSC::_S
private

Definition at line 62 of file CSC.h.

◆ _scc

CGSCC* SVF::CSC::_scc
private

Definition at line 58 of file CSC.h.

◆ _visited

NodeSet SVF::CSC::_visited
private

Definition at line 63 of file CSC.h.


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