Skip to content

Commit 59972bb

Browse files
committed
Merge remote-tracking branch 'origin/patch'
2 parents b9f914d + f36583f commit 59972bb

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

Ghidra/Features/CodeCompare/src/main/java/ghidra/codecompare/graphanalysis/DataGraph.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ private void eliminatePtrsubs(ArrayList<DataVertex> ptrsubs) {
201201
DataVertex outNode = subop.sinks.get(0);
202202
in1Node.sinks.clear();
203203
replaceNodeInOutEdges(outNode, in1Node);
204-
in0Node.clearEdges();
205-
subop.clearEdges();
206-
outNode.clearEdges();
204+
in0Node.collapse();
205+
subop.collapse();
206+
outNode.collapse();
207207
makeAssociation(subop, outNode, in1Node, 0); // Attach subop and outNode -> in1Node
208208
}
209209
}
@@ -245,7 +245,7 @@ private void eliminateCasts(ArrayList<DataVertex> casts) {
245245
out.sources.clear();
246246
topOp.sinks.add(out);
247247
out.sources.add(topOp);
248-
in.clearEdges();
248+
in.collapse();
249249
if (assoc == null) {
250250
assoc = out;
251251
}
@@ -256,13 +256,13 @@ private void eliminateCasts(ArrayList<DataVertex> casts) {
256256
// output is isolated
257257
removeInEdge(castNode, 0);
258258
replaceNodeInOutEdges(out, in);
259-
out.clearEdges();
259+
out.collapse();
260260
if (assoc == null) {
261261
assoc = in;
262262
}
263263
makeAssociation(castNode, out, assoc, assocSlot);
264264
}
265-
castNode.clearEdges();
265+
castNode.collapse();
266266
}
267267
}
268268

@@ -273,6 +273,9 @@ private void eliminateCasts(ArrayList<DataVertex> casts) {
273273
public void makeNGrams(int numNGrams) {
274274
for (int i = 0; i < numNGrams - 1; ++i) {
275275
for (DataVertex node : nodeList) {
276+
if (node.isCollapsed()) {
277+
continue; // Don't hash if disconnected from graph
278+
}
276279
node.nextNGramSource(i); // Construct (n+1)-gram from existing n-gram
277280
}
278281
}

Ghidra/Features/CodeCompare/src/main/java/ghidra/codecompare/graphanalysis/DataVertex.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ public String toString() {
9898
}
9999

100100
/**
101-
* Clear any incoming or outgoing edges to/from this node
101+
* Mark this node as disconnected from its graph.
102+
* Clear any incoming or outgoing edges to/from this node.
103+
* Clear the ngrams
102104
*/
103-
void clearEdges() {
105+
void collapse() {
104106
sinks.clear();
105107
sources.clear();
108+
ngrams.clear();
106109
}
107110

108111
@Override
@@ -188,6 +191,13 @@ public boolean isOp() {
188191
return (op != null);
189192
}
190193

194+
/**
195+
* @return true if this node has been removed from its DataGraph
196+
*/
197+
public boolean isCollapsed() {
198+
return (ngrams.size() == 0);
199+
}
200+
191201
/**
192202
* Is the underlying node a PcodeOp which takes commutative inputs?
193203
* @return true if the PcodeOp is commutative

0 commit comments

Comments
 (0)