Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ailrst committed Aug 9, 2024
1 parent b7378b6 commit 37ee553
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/main/scala/analysis/solvers/IDESolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,14 @@ abstract class BackwardIDESolver[D, T, L <: Lattice[T]](program: Program)

protected def isCall(call: CFGPosition): Boolean =
call match
case c : Command => isAfterCall(c)
&& c.parent.parent.returnBlock.isDefined
&& IRWalk.prevCommandInBlock(c).map(c => (!IRWalk.nextCommandInBlock(c).get.isInstanceOf[Halt]) && c.isInstanceOf[DirectCall]).getOrElse(false)
case c: Halt => false /* don't process non-returning calls */
case c : Command if isAfterCall(c) => {
val call = IRWalk.prevCommandInBlock(c)
call match {
case Some(d: DirectCall) if d.target.returnBlock.isDefined => true
case _ => false
}
}
case _ => false

protected def isExit(exit: CFGPosition): Boolean =
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/ir/Program.scala
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ class Procedure private (
}

def addBlocks(block: Block): Block = {
block.parent = this
if (!_blocks.contains(block)) {
block.parent = this
_blocks.add(block)
Expand Down Expand Up @@ -284,7 +283,8 @@ class Procedure private (

def clearBlocks(): Unit = {
// O(n) because we are careful to unlink the parents etc.
removeBlocksDisconnect(_blocks)
// .toList to avoid modifying our own iterator
removeBlocksDisconnect(_blocks.toList)
}

def callers(): Iterable[Procedure] = _callers.map(_.parent.parent).toSet[Procedure]
Expand Down
4 changes: 1 addition & 3 deletions src/main/scala/util/RunUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,8 @@ object StaticAnalysis {
mmm.logRegions(memoryRegionContents)

// turn fake procedures into diamonds
transforms.addReturnBlocks(ctx.program, true) // add return to all blocks because IDE solver expects it
Logger.info("[!] Running VSA")
val vsaSolver =
ValueSetAnalysisSolver(IRProgram, globalAddresses, externalAddresses, globalOffsets, subroutines, mmm, constPropResult)
val vsaSolver = ValueSetAnalysisSolver(IRProgram, globalAddresses, externalAddresses, globalOffsets, subroutines, mmm, constPropResult)
val vsaResult: Map[CFGPosition, LiftedElement[Map[Variable | MemoryRegion, Set[Value]]]] = vsaSolver.analyze()

Logger.info("[!] Running Interprocedural Live Variables Analysis")
Expand Down

0 comments on commit 37ee553

Please sign in to comment.