Skip to content

Commit

Permalink
use names that make it clear in Boogie whether a region is a stack re…
Browse files Browse the repository at this point in the history
…gion
  • Loading branch information
l-kent committed Nov 28, 2024
1 parent 879e124 commit 7b485e7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/main/scala/analysis/RegionInjector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MergedRegionMRA(private val nameIn: String, val subregions: mutable.Set[Me
name = nameIn
}

class MergedRegionDSA(private val nameIn: String, val cell: Cell) extends MergedRegion {
class MergedRegionDSA(private val nameIn: String, val cell: Cell, val stack: Boolean) extends MergedRegion {
name = nameIn
}

Expand Down Expand Up @@ -182,6 +182,9 @@ class RegionInjectorMRA(override val program: Program, mmm: MemoryModelMap) exte
class RegionInjectorDSA(override val program: Program, DSATopDown: mutable.Map[Procedure, Graph]) extends RegionInjector {
private val mergedRegions: mutable.Map[Cell, MergedRegionDSA] = mutable.Map()

private var sharedMemoryCounter = 0
private var stackCounter = 0

def injectRegions(): Unit = {
// visit reachable procedures
val queue = mutable.Queue[Procedure]()
Expand Down Expand Up @@ -233,16 +236,19 @@ class RegionInjectorDSA(override val program: Program, DSATopDown: mutable.Map[P
}

private def createRegion(cell: Cell): MergedRegionDSA = {
val name = if (cell.node.isDefined) {
s"cell${cell.node.get.id}_${cell.offset}"
val stack = cell.node.get.flags.stack
val name = if (stack) {
stackCounter += 1
s"stack$$${stackCounter}"
} else {
???
sharedMemoryCounter += 1
s"mem$$${sharedMemoryCounter}"
}
MergedRegionDSA(name, cell)
MergedRegionDSA(name, cell, stack)
}

private def replaceMemory(memory: Memory, mergedRegion: MergedRegionDSA): Memory = {
if (mergedRegion.cell.node.get.flags.stack) {
if (mergedRegion.stack) {
StackMemory(mergedRegion.name, memory.addressSize, memory.valueSize)
} else {
SharedMemory(mergedRegion.name, memory.addressSize, memory.valueSize)
Expand Down Expand Up @@ -298,7 +304,7 @@ class RegionInjectorDSA(override val program: Program, DSATopDown: mutable.Map[P
}

override def sharedRegions(): Iterable[MergedRegion] = {
mergedRegions.values.filter(region => !region.cell.node.get.flags.stack)
mergedRegions.values.filter(region => !region.stack)
}

}

0 comments on commit 7b485e7

Please sign in to comment.