Skip to content

Commit

Permalink
cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ailrst committed Jan 24, 2024
1 parent 2851650 commit fa65d14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
8 changes: 8 additions & 0 deletions src/main/scala/ir/Program.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ class Program(var procedures: ArrayBuffer[Procedure], var mainProcedure: Procedu
initialMemory = initialMemoryNew
}

/**
* Iterator in approximate syntactic pre-order of procedures, blocks, and commands. Blocks and procedures are
* not guaranteed to be in any defined order.
*/
class ILUnorderedIterator(private val begin: Program) extends Iterator[CFGPosition] {
val stack = mutable.Stack[CFGPosition]()
stack.addAll(begin.procedures)
Expand All @@ -142,6 +146,10 @@ class Program(var procedures: ArrayBuffer[Procedure], var mainProcedure: Procedu

}

/**
* Get an Iterator in approximate syntactic pre-order of procedures, blocks, and commands. Blocks and procedures are
* not guaranteed to be in any defined order.
*/
def iterator: Iterator[CFGPosition] = {
ILUnorderedIterator(this)
}
Expand Down
31 changes: 3 additions & 28 deletions src/main/scala/util/RunUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,34 +166,9 @@ object RunUtils {
val constPropSolver = ConstantPropagationSolver(cfg)
val constPropResult = constPropSolver.analyze()

def newSolverTest(): Unit = {
val ilcpsolver = IRSimpleValueAnalysis.Solver(IRProgram)
val newCPResult = ilcpsolver.analyze()

val newCommandDomain = ilcpsolver.domain.filter(_.isInstanceOf[Command])

val newRes = newCPResult.flatMap((x, y) => y.flatMap {
case (_, el) if el == FlatLattice[BitVecLiteral].top || el == FlatLattice[BitVecLiteral].bottom => None
case z => Some(x -> z)
})
val oldRes = constPropResult.filter((x,y) => x.isInstanceOf[CfgNodeWithData[CFGPosition]]).flatMap((x, y) => y.flatMap {
case (_, el) if el == FlatLattice[BitVecLiteral].top || el == FlatLattice[BitVecLiteral].bottom => None
case z => Some(x.asInstanceOf[CfgNodeWithData[Any]].data -> z)
})
val both = newRes.toSet.intersect(oldRes.toSet)
val notnew = (newRes.toSet).filter(x => !both.contains(x)).toList.sorted((a, b) => a._2._1.name.compare(b._2._1.name))
val notOld = (oldRes.toSet).filter(x => !both.contains(x)).toList.sorted((a,b) => a._2._1.name.compare(b._2._1.name))
// newRes and oldRes should have value equality

//config.analysisResultsPath.foreach(s => writeToFile(printAnalysisResults(IRProgram, newCPResult), s"${s}_newconstprop$iteration.txt"))
config.analysisResultsPath.foreach(s => writeToFile(toDot(IRProgram), s"program.dot"))
config.analysisResultsPath.foreach(s => writeToFile(toDot(IRProgram, newCPResult.map((k,v) => (k, v.toString))), s"program-constprop.dot"))

config.analysisResultsPath.foreach(s => writeToFile(printAnalysisResults(IRProgram, newCPResult), s"${s}_new_cpres$iteration.txt"))
config.analysisResultsPath.foreach(s => writeToFile(printAnalysisResults(IRProgram, cfg, constPropResult), s"${s}_old_cpres$iteration.txt"))

}
newSolverTest()
val ilcpsolver = IRSimpleValueAnalysis.Solver(IRProgram)
val newCPResult = ilcpsolver.analyze()
config.analysisResultsPath.foreach(s => writeToFile(printAnalysisResults(IRProgram, newCPResult), s"${s}_new_ir_constprop$iteration.txt"))

config.analysisDotPath.foreach(s => writeToFile(cfg.toDot(Output.labeler(constPropResult, true), Output.dotIder), s"${s}_constprop$iteration.dot"))
config.analysisResultsPath.foreach(s => writeToFile(printAnalysisResults(IRProgram, cfg, constPropResult), s"${s}_constprop$iteration.txt"))
Expand Down

0 comments on commit fa65d14

Please sign in to comment.