From 6f90450c67f580d209bae4ee73fae321eb645bbf Mon Sep 17 00:00:00 2001 From: sadrabt Date: Thu, 28 Nov 2024 14:26:49 +1000 Subject: [PATCH] assertion of invariant, fix to clone --- src/main/scala/analysis/data_structure_analysis/Graph.scala | 5 +++-- .../scala/analysis/data_structure_analysis/LocalPhase.scala | 2 ++ .../scala/analysis/data_structure_analysis/Utility.scala | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/scala/analysis/data_structure_analysis/Graph.scala b/src/main/scala/analysis/data_structure_analysis/Graph.scala index 8b8574a27..f320dc9ef 100644 --- a/src/main/scala/analysis/data_structure_analysis/Graph.scala +++ b/src/main/scala/analysis/data_structure_analysis/Graph.scala @@ -674,9 +674,10 @@ class Graph(val proc: Procedure, assert(formals.size == newGraph.formals.size) val nodes = mutable.Set[Node]() val idToNode: mutable.Map[Int, Node] = mutable.Map() - formals.foreach { (variable, slice) => + formals.foreach { (variable, s) => // assert(newGraph.formals.contains(variable)) - val node = find(slice).node + val slice = find(s) + val node = slice.node nodes.add(node) if !idToNode.contains(node.id) then val newNode = node.cloneSelf(newGraph) diff --git a/src/main/scala/analysis/data_structure_analysis/LocalPhase.scala b/src/main/scala/analysis/data_structure_analysis/LocalPhase.scala index 7b660817b..243150497 100644 --- a/src/main/scala/analysis/data_structure_analysis/LocalPhase.scala +++ b/src/main/scala/analysis/data_structure_analysis/LocalPhase.scala @@ -283,6 +283,7 @@ class LocalPhase(proc: Procedure, val global = isGlobal(indexUnwrapped, n, byteSize) val stack = isStack(indexUnwrapped, n) val indexCell = graph.adjust(graph.accessIndexToSlice(load)) + assert(!indexCell.node.get.flags.merged) // check index cell is a placeholder if global.isDefined then graph.mergeCells(graph.find(global.get), indexCell) graph.mergeCells(lhsCell, graph.adjust(graph.find(global.get).getPointee)) @@ -315,6 +316,7 @@ class LocalPhase(proc: Procedure, val global = isGlobal(index, n, byteSize) val stack = isStack(index, n) val indexCell = graph.adjust(graph.accessIndexToSlice(store)) + assert(!indexCell.node.get.flags.merged) // check index cell is a placeholder val addressPointee: Cell = if (global.isDefined) { graph.mergeCells(graph.find(global.get), indexCell) graph.adjust(graph.find(global.get).getPointee) diff --git a/src/main/scala/analysis/data_structure_analysis/Utility.scala b/src/main/scala/analysis/data_structure_analysis/Utility.scala index a276e27bf..13803df58 100644 --- a/src/main/scala/analysis/data_structure_analysis/Utility.scala +++ b/src/main/scala/analysis/data_structure_analysis/Utility.scala @@ -34,6 +34,7 @@ class Flags() { var modified = false var incomplete = false var foreign = false + var merged = false def join(other: Flags): Unit = collapsed = collapsed || other.collapsed @@ -45,6 +46,7 @@ class Flags() { modified = other.modified || modified incomplete = other.incomplete || incomplete foreign = other.foreign && foreign + merged = true } /**