From fa65d14c3b91c466e3cc5a5069c2a16124c8bace Mon Sep 17 00:00:00 2001 From: Alistair Michael Date: Wed, 24 Jan 2024 16:22:21 +1000 Subject: [PATCH] cleanup comments --- src/main/scala/ir/Program.scala | 8 ++++++++ src/main/scala/util/RunUtils.scala | 31 +++--------------------------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/main/scala/ir/Program.scala b/src/main/scala/ir/Program.scala index 94a9bdd04..600c7361f 100644 --- a/src/main/scala/ir/Program.scala +++ b/src/main/scala/ir/Program.scala @@ -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) @@ -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) } diff --git a/src/main/scala/util/RunUtils.scala b/src/main/scala/util/RunUtils.scala index 83946a12b..ade5cfdab 100644 --- a/src/main/scala/util/RunUtils.scala +++ b/src/main/scala/util/RunUtils.scala @@ -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"))