Static Value-Flow Analysis
Public Types | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SVF::WPASolver< GraphType > Class Template Reference

#include <WPASolver.h>

Inheritance diagram for SVF::WPASolver< GraphType >:
SVF::AndersenBase SVF::WPAFSSolver< GraphType > SVF::Andersen SVF::Steensgaard SVF::TypeAnalysis SVF::FlowSensitive SVF::WPASCCSolver< GraphType > SVF::AndersenSCD SVF::AndersenWaveDiff SVF::VersionedFlowSensitive SVF::WPAMinimumSolver< GraphType > SVF::AndersenSFR

Public Types

typedef SVF::GenericGraphTraits< GraphType > GTraits
 Define the GTraits and node iterator for printing. More...
 
typedef GTraits::NodeRef GNODE
 
typedef GTraits::EdgeType GEDGE
 
typedef GTraits::ChildIteratorType child_iterator
 
typedef SCCDetection< GraphType > SCC
 
typedef FIFOWorkList< NodeIDWorkList
 

Public Attributes

u32_t numOfIteration
 num of iterations during constraint solving More...
 

Protected Member Functions

 WPASolver ()
 Constructor. More...
 
virtual ~WPASolver ()=default
 Destructor. More...
 
SCCgetSCCDetector () const
 Get SCC detector. More...
 
const GraphType graph ()
 Get/Set graph methods. More...
 
void setGraph (GraphType g)
 
virtual NodeStackSCCDetect ()
 SCC detection. More...
 
virtual NodeStackSCCDetect (NodeSet &candidates)
 
virtual void initWorklist ()
 
virtual void solveWorklist ()
 
virtual void processNode (NodeID)
 Following methods are to be implemented in child class, in order to achieve a fully worked PTA. More...
 
virtual void collapseFields ()
 collapse positive weight cycles of a graph More...
 
virtual void propagate (GNODE *v)
 
virtual bool propFromSrcToDst (GEDGE *)
 Propagate information from source to destination node, to be implemented in the child class. More...
 
virtual NodeID sccRepNode (NodeID id) const
 
NodeID popFromWorklist ()
 Worklist operations. More...
 
virtual void pushIntoWorklist (NodeID id)
 
bool isWorklistEmpty ()
 
bool isInWorklist (NodeID id)
 
GNODENode (NodeID id)
 Get node on the graph. More...
 
NodeID Node_Index (GNODE node)
 Get node ID. More...
 

Protected Attributes

bool reanalyze
 Reanalyze if any constraint value changed. More...
 
u32_t iterationForPrintStat
 print out statistics for i-th iteration More...
 
GraphType _graph
 Graph. More...
 
std::unique_ptr< SCCscc
 SCC. More...
 
WorkList worklist
 Worklist for resolution. More...
 

Detailed Description

template<class GraphType>
class SVF::WPASolver< GraphType >

Definition at line 43 of file WPASolver.h.

Member Typedef Documentation

◆ child_iterator

template<class GraphType >
typedef GTraits::ChildIteratorType SVF::WPASolver< GraphType >::child_iterator

Definition at line 51 of file WPASolver.h.

◆ GEDGE

template<class GraphType >
typedef GTraits::EdgeType SVF::WPASolver< GraphType >::GEDGE

Definition at line 50 of file WPASolver.h.

◆ GNODE

template<class GraphType >
typedef GTraits::NodeRef SVF::WPASolver< GraphType >::GNODE

Definition at line 49 of file WPASolver.h.

◆ GTraits

template<class GraphType >
typedef SVF::GenericGraphTraits<GraphType> SVF::WPASolver< GraphType >::GTraits

Define the GTraits and node iterator for printing.

Definition at line 48 of file WPASolver.h.

◆ SCC

template<class GraphType >
typedef SCCDetection<GraphType> SVF::WPASolver< GraphType >::SCC

Definition at line 53 of file WPASolver.h.

◆ WorkList

template<class GraphType >
typedef FIFOWorkList<NodeID> SVF::WPASolver< GraphType >::WorkList

Definition at line 55 of file WPASolver.h.

Constructor & Destructor Documentation

◆ WPASolver()

template<class GraphType >
SVF::WPASolver< GraphType >::WPASolver ( )
inlineprotected

Constructor.

Definition at line 60 of file WPASolver.h.

60  : reanalyze(false), iterationForPrintStat(1000), _graph(nullptr), numOfIteration(0)
61  {
62  }
GraphType _graph
Graph.
Definition: WPASolver.h:190
u32_t iterationForPrintStat
print out statistics for i-th iteration
Definition: WPASolver.h:173
u32_t numOfIteration
num of iterations during constraint solving
Definition: WPASolver.h:200
bool reanalyze
Reanalyze if any constraint value changed.
Definition: WPASolver.h:171

◆ ~WPASolver()

template<class GraphType >
virtual SVF::WPASolver< GraphType >::~WPASolver ( )
protectedvirtualdefault

Destructor.

Member Function Documentation

◆ collapseFields()

template<class GraphType >
virtual void SVF::WPASolver< GraphType >::collapseFields ( )
inlineprotectedvirtual

collapse positive weight cycles of a graph

Reimplemented in SVF::Andersen.

Definition at line 124 of file WPASolver.h.

124 {}

◆ getSCCDetector()

template<class GraphType >
SCC* SVF::WPASolver< GraphType >::getSCCDetector ( ) const
inlineprotected

Get SCC detector.

Definition at line 67 of file WPASolver.h.

68  {
69  return scc.get();
70  }
std::unique_ptr< SCC > scc
SCC.
Definition: WPASolver.h:193

◆ graph()

template<class GraphType >
const GraphType SVF::WPASolver< GraphType >::graph ( )
inlineprotected

Get/Set graph methods.

Definition at line 74 of file WPASolver.h.

75  {
76  return _graph;
77  }

◆ initWorklist()

template<class GraphType >
virtual void SVF::WPASolver< GraphType >::initWorklist ( )
inlineprotectedvirtual

Reimplemented in SVF::Andersen.

Definition at line 97 of file WPASolver.h.

98  {
99  NodeStack& nodeStack = SCCDetect();
100  while (!nodeStack.empty())
101  {
102  NodeID nodeId = nodeStack.top();
103  nodeStack.pop();
104  pushIntoWorklist(nodeId);
105  }
106  }
virtual void pushIntoWorklist(NodeID id)
Definition: WPASolver.h:156
virtual NodeStack & SCCDetect()
SCC detection.
Definition: WPASolver.h:86
std::stack< NodeID > NodeStack
Definition: GeneralType.h:118
u32_t NodeID
Definition: GeneralType.h:55

◆ isInWorklist()

template<class GraphType >
bool SVF::WPASolver< GraphType >::isInWorklist ( NodeID  id)
inlineprotected

Definition at line 164 of file WPASolver.h.

165  {
166  return worklist.find(id);
167  }
bool find(const Data &data) const
Definition: WorkList.h:157
WorkList worklist
Worklist for resolution.
Definition: WPASolver.h:196

◆ isWorklistEmpty()

template<class GraphType >
bool SVF::WPASolver< GraphType >::isWorklistEmpty ( )
inlineprotected

Definition at line 160 of file WPASolver.h.

161  {
162  return worklist.empty();
163  }
bool empty() const
Definition: WorkList.h:146

◆ Node()

template<class GraphType >
GNODE* SVF::WPASolver< GraphType >::Node ( NodeID  id)
inlineprotected

Get node on the graph.

Definition at line 177 of file WPASolver.h.

178  {
179  return GTraits::getNode(_graph, id);
180  }

◆ Node_Index()

template<class GraphType >
NodeID SVF::WPASolver< GraphType >::Node_Index ( GNODE  node)
inlineprotected

Get node ID.

Definition at line 183 of file WPASolver.h.

184  {
185  return GTraits::getNodeID(node);
186  }

◆ popFromWorklist()

template<class GraphType >
NodeID SVF::WPASolver< GraphType >::popFromWorklist ( )
inlineprotected

Worklist operations.

Definition at line 151 of file WPASolver.h.

152  {
153  return sccRepNode(worklist.pop());
154  }
virtual NodeID sccRepNode(NodeID id) const
Definition: WPASolver.h:144

◆ processNode()

template<class GraphType >
virtual void SVF::WPASolver< GraphType >::processNode ( NodeID  )
inlineprotectedvirtual

Following methods are to be implemented in child class, in order to achieve a fully worked PTA.

Process each node on the graph, to be implemented in the child class

Reimplemented in SVF::FlowSensitive, SVF::AndersenWaveDiff, SVF::Andersen, and SVF::VersionedFlowSensitive.

Definition at line 122 of file WPASolver.h.

122 {}

◆ propagate()

template<class GraphType >
virtual void SVF::WPASolver< GraphType >::propagate ( GNODE v)
inlineprotectedvirtual

dump statistics Propagation for the solving, to be implemented in the child class

Reimplemented in SVF::WPASCCSolver< GraphType >.

Definition at line 127 of file WPASolver.h.

128  {
129  child_iterator EI = GTraits::direct_child_begin(*v);
130  child_iterator EE = GTraits::direct_child_end(*v);
131  for (; EI != EE; ++EI)
132  {
133  if (propFromSrcToDst(*(EI.getCurrent())))
135  }
136  }
NodeID Node_Index(GNODE node)
Get node ID.
Definition: WPASolver.h:183
GTraits::ChildIteratorType child_iterator
Definition: WPASolver.h:51
virtual bool propFromSrcToDst(GEDGE *)
Propagate information from source to destination node, to be implemented in the child class.
Definition: WPASolver.h:138

◆ propFromSrcToDst()

template<class GraphType >
virtual bool SVF::WPASolver< GraphType >::propFromSrcToDst ( GEDGE )
inlineprotectedvirtual

Propagate information from source to destination node, to be implemented in the child class.

Definition at line 138 of file WPASolver.h.

139  {
140  return false;
141  }

◆ pushIntoWorklist()

template<class GraphType >
virtual void SVF::WPASolver< GraphType >::pushIntoWorklist ( NodeID  id)
inlineprotectedvirtual

Definition at line 156 of file WPASolver.h.

157  {
158  worklist.push(sccRepNode(id));
159  }
bool push(const Data &data)
Definition: WorkList.h:165

◆ SCCDetect() [1/2]

template<class GraphType >
virtual NodeStack& SVF::WPASolver< GraphType >::SCCDetect ( )
inlineprotectedvirtual

SCC detection.

Reimplemented in SVF::FlowSensitive, SVF::WPAFSSolver< GraphType >, SVF::AndersenSCD, and SVF::Andersen.

Definition at line 86 of file WPASolver.h.

87  {
88  getSCCDetector()->find();
89  return getSCCDetector()->topoNodeStack();
90  }
void find(void)
Definition: SCC.h:308
GNodeStack & topoNodeStack()
Definition: SCC.h:128
SCC * getSCCDetector() const
Get SCC detector.
Definition: WPASolver.h:67

◆ SCCDetect() [2/2]

template<class GraphType >
virtual NodeStack& SVF::WPASolver< GraphType >::SCCDetect ( NodeSet candidates)
inlineprotectedvirtual

Definition at line 91 of file WPASolver.h.

92  {
93  getSCCDetector()->find(candidates);
94  return getSCCDetector()->topoNodeStack();
95  }

◆ sccRepNode()

template<class GraphType >
virtual NodeID SVF::WPASolver< GraphType >::sccRepNode ( NodeID  id) const
inlineprotectedvirtual

Reimplemented in SVF::Steensgaard, SVF::AndersenBase, and SVF::WPAFSSolver< GraphType >.

Definition at line 144 of file WPASolver.h.

145  {
146  return getSCCDetector()->repNode(id);
147  }
NodeID repNode(NodeID n) const
get the rep node if not found return itself
Definition: SCC.h:139

◆ setGraph()

template<class GraphType >
void SVF::WPASolver< GraphType >::setGraph ( GraphType  g)
inlineprotected

Definition at line 78 of file WPASolver.h.

79  {
80  _graph = g;
81  scc = std::make_unique<SCC>(_graph);
82  }

◆ solveWorklist()

template<class GraphType >
virtual void SVF::WPASolver< GraphType >::solveWorklist ( )
inlineprotectedvirtual

Reimplemented in SVF::Steensgaard, SVF::AndersenSCD, and SVF::AndersenWaveDiff.

Definition at line 108 of file WPASolver.h.

109  {
110  while (!isWorklistEmpty())
111  {
112  NodeID nodeId = popFromWorklist();
113  // Keep solving until workList is empty.
114  processNode(nodeId);
115  collapseFields();
116  }
117  }
NodeID popFromWorklist()
Worklist operations.
Definition: WPASolver.h:151
virtual void collapseFields()
collapse positive weight cycles of a graph
Definition: WPASolver.h:124
bool isWorklistEmpty()
Definition: WPASolver.h:160
virtual void processNode(NodeID)
Following methods are to be implemented in child class, in order to achieve a fully worked PTA.
Definition: WPASolver.h:122

Member Data Documentation

◆ _graph

template<class GraphType >
GraphType SVF::WPASolver< GraphType >::_graph
protected

Graph.

Definition at line 190 of file WPASolver.h.

◆ iterationForPrintStat

template<class GraphType >
u32_t SVF::WPASolver< GraphType >::iterationForPrintStat
protected

print out statistics for i-th iteration

Definition at line 173 of file WPASolver.h.

◆ numOfIteration

template<class GraphType >
u32_t SVF::WPASolver< GraphType >::numOfIteration

num of iterations during constraint solving

Definition at line 200 of file WPASolver.h.

◆ reanalyze

template<class GraphType >
bool SVF::WPASolver< GraphType >::reanalyze
protected

Reanalyze if any constraint value changed.

Definition at line 171 of file WPASolver.h.

◆ scc

template<class GraphType >
std::unique_ptr<SCC> SVF::WPASolver< GraphType >::scc
protected

SCC.

Definition at line 193 of file WPASolver.h.

◆ worklist

template<class GraphType >
WorkList SVF::WPASolver< GraphType >::worklist
protected

Worklist for resolution.

Definition at line 196 of file WPASolver.h.


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