Skip to content

Commit

Permalink
assertion of invariant, fix to clone
Browse files Browse the repository at this point in the history
  • Loading branch information
sadrabt committed Nov 28, 2024
1 parent 7b485e7 commit 6f90450
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/scala/analysis/data_structure_analysis/Graph.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/analysis/data_structure_analysis/Utility.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,6 +46,7 @@ class Flags() {
modified = other.modified || modified
incomplete = other.incomplete || incomplete
foreign = other.foreign && foreign
merged = true
}

/**
Expand Down

0 comments on commit 6f90450

Please sign in to comment.