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

Classes

struct  NodeData
 

Static Public Member Functions

static unsigned detectSCCs (VersionedFlowSensitive *vfs, const SVFG *svfg, const NodeID object, const std::vector< const SVFGNode * > &startingNodes, std::vector< int > &partOf, std::vector< const IndirectSVFGEdge * > &footprint)
 

Private Types

typedef struct SVF::VersionedFlowSensitive::SCC::NodeData NodeData
 

Static Private Member Functions

static void visit (VersionedFlowSensitive *vfs, const NodeID object, std::vector< int > &partOf, std::vector< const IndirectSVFGEdge * > &footprint, std::vector< NodeData > &nodeData, std::stack< const SVFGNode * > &stack, int &index, int &currentSCC, const SVFGNode *v)
 Called by detectSCCs then called recursively.
 

Detailed Description

Definition at line 249 of file VersionedFlowSensitive.h.

Member Typedef Documentation

◆ NodeData

Member Function Documentation

◆ detectSCCs()

unsigned VersionedFlowSensitive::SCC::detectSCCs ( VersionedFlowSensitive vfs,
const SVFG svfg,
const NodeID  object,
const std::vector< const SVFGNode * > &  startingNodes,
std::vector< int > &  partOf,
std::vector< const IndirectSVFGEdge * > &  footprint 
)
static

Determines the strongly connected components of svfg following only edges labelled with object. partOf[n] = scc means nodes n is part of SCC scc. startingNodes contains the nodes to begin the search from. After completion, footprint will contain all edges which object appears on (as reached through the algorithm described above) sorted.

This is not a general SCC detection but specifically for versioning, so edges to delta nodes are skipped as they are prelabelled. Edges to stores are also skipped to as they yield a new version (they cannot be part of an SCC containing more than themselves). Skipped edges still form part of the footprint.

Definition at line 1115 of file VersionedFlowSensitive.cpp.

1120{
1121 partOf.resize(svfg->getTotalNodeNum());
1122 std::fill(partOf.begin(), partOf.end(), -1);
1123 footprint.clear();
1124
1125 std::vector<NodeData> nodeData(svfg->getTotalNodeNum(), { -1, -1, false});
1126 std::stack<const SVFGNode *> stack;
1127
1128 int index = 0;
1129 int currentSCC = 0;
1130
1131 for (const SVFGNode *v : startingNodes)
1132 {
1133 if (nodeData[v->getId()].index == -1)
1134 {
1136 }
1137 }
1138
1139 // Make sure footprints with the same edges pass ==/hash the same.
1140 std::sort(footprint.begin(), footprint.end());
1141
1142 return currentSCC;
1143}
int index
Definition cJSON.h:170
u32_t getTotalNodeNum() const
Get total number of node/edge.
static void visit(VersionedFlowSensitive *vfs, const NodeID object, std::vector< int > &partOf, std::vector< const IndirectSVFGEdge * > &footprint, std::vector< NodeData > &nodeData, std::stack< const SVFGNode * > &stack, int &index, int &currentSCC, const SVFGNode *v)
Called by detectSCCs then called recursively.
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76

◆ visit()

void VersionedFlowSensitive::SCC::visit ( VersionedFlowSensitive vfs,
const NodeID  object,
std::vector< int > &  partOf,
std::vector< const IndirectSVFGEdge * > &  footprint,
std::vector< NodeData > &  nodeData,
std::stack< const SVFGNode * > &  stack,
int index,
int currentSCC,
const SVFGNode v 
)
staticprivate

Called by detectSCCs then called recursively.

Definition at line 1145 of file VersionedFlowSensitive.cpp.

1154{
1155 const NodeID vId = v->getId();
1156
1157 nodeData[vId].index = index;
1158 nodeData[vId].lowlink = index;
1159 ++index;
1160
1161 stack.push(v);
1162 nodeData[vId].onStack = true;
1163
1164 for (const SVFGEdge *e : v->getOutEdges())
1165 {
1166 const IndirectSVFGEdge *ie = SVFUtil::dyn_cast<IndirectSVFGEdge>(e);
1167 if (!ie) continue;
1168
1169 const SVFGNode *w = ie->getDstNode();
1170 const NodeID wId = w->getId();
1171
1172 // If object is not part of the edge, there is no edge from v to w.
1173 if (!ie->getPointsTo().test(object)) continue;
1174
1175 // Even if we don't count edges to stores and deltas for SCCs' sake, they
1176 // are relevant to the footprint as a propagation still occurs over such edges.
1177 footprint.push_back(ie);
1178
1179 // Ignore edges to delta nodes because they are prelabeled so cannot
1180 // be part of the SCC v is in (already in nodesTodo from the prelabeled set).
1181 // Similarly, store nodes.
1182 if (vfs->delta(wId) || vfs->isStore(wId)) continue;
1183
1184 if (nodeData[wId].index == -1)
1185 {
1187 nodeData[vId].lowlink = std::min(nodeData[vId].lowlink, nodeData[wId].lowlink);
1188 }
1189 else if (nodeData[wId].onStack)
1190 {
1191 nodeData[vId].lowlink = std::min(nodeData[vId].lowlink, nodeData[wId].index);
1192 }
1193 }
1194
1195 if (nodeData[vId].lowlink == nodeData[vId].index)
1196 {
1197 const SVFGNode *w = nullptr;
1198 do
1199 {
1200 w = stack.top();
1201 stack.pop();
1202 const NodeID wId = w->getId();
1203 nodeData[wId].onStack = false;
1205 }
1206 while (w != v);
1207
1208 // For the next SCC.
1209 ++currentSCC;
1210 }
1211}
NodeID getId() const
Get ID.
Definition SVFValue.h:158
u32_t NodeID
Definition GeneralType.h:76

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