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 252 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 1113 of file VersionedFlowSensitive.cpp.

1118{
1119 partOf.resize(svfg->getTotalNodeNum());
1120 std::fill(partOf.begin(), partOf.end(), -1);
1121 footprint.clear();
1122
1123 std::vector<NodeData> nodeData(svfg->getTotalNodeNum(), { -1, -1, false});
1124 std::stack<const SVFGNode *> stack;
1125
1126 int index = 0;
1127 int currentSCC = 0;
1128
1129 for (const SVFGNode *v : startingNodes)
1130 {
1131 if (nodeData[v->getId()].index == -1)
1132 {
1134 }
1135 }
1136
1137 // Make sure footprints with the same edges pass ==/hash the same.
1138 std::sort(footprint.begin(), footprint.end());
1139
1140 return currentSCC;
1141}
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 1143 of file VersionedFlowSensitive.cpp.

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

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