Skip to content

Commit

Permalink
make injecting regions happen in a consistent place
Browse files Browse the repository at this point in the history
  • Loading branch information
l-kent committed Dec 5, 2024
1 parent b8cd9fb commit db6f2ca
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions src/main/scala/util/RunUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -466,21 +466,6 @@ object StaticAnalysis {

mmm.setCallSiteSummaries(steensgaardSolver.callSiteSummary)

Logger.debug("[!] Injecting regions")
val regionInjector = if (config.memoryRegions == MemoryRegionsMode.MRA) {
val injector = RegionInjectorMRA(IRProgram, mmm)
injector.injectRegions()
Some(injector)
} else {
None
}
config.analysisDotPath.foreach { s =>
writeToFile(
toDot(IRProgram, IRProgram.filter(_.isInstanceOf[Command]).map(b => b -> "").toMap),
s"${s}_InjectedRegions$iteration.dot"
)
}

val paramResults: Map[Procedure, Set[Variable]] = ParamAnalysis(IRProgram).analyze()
val interLiveVarsResults: Map[CFGPosition, Map[Variable, TwoElement]] = InterLiveVarsAnalysis(IRProgram).analyze()

Expand All @@ -496,7 +481,7 @@ object StaticAnalysis {
symbolicAddresses = Map.empty,
reachingDefs = reachingDefinitionsAnalysisResults,
varDepsSummaries = varDepsSummaries,
regionInjector = regionInjector,
regionInjector = None,
localDSA = Map.empty,
bottomUpDSA = Map.empty,
topDownDSA = Map.empty,
Expand Down Expand Up @@ -625,7 +610,7 @@ object RunUtils {
).resolveIndirectCalls()
*/

if (config.memoryRegions == MemoryRegionsMode.MRA && *(previousResult.isEmpty ||result.vsaResult != previousResult.get.vsaResult)) {
if (config.memoryRegions == MemoryRegionsMode.MRA && (previousResult.isEmpty || result.vsaResult != previousResult.get.vsaResult)) {
modified = true
} else {
modified = transforms.VSAIndirectCallResolution(
Expand Down Expand Up @@ -675,7 +660,12 @@ object RunUtils {
writeToFile(dsa.topDown(ctx.program.mainProcedure).toDot, s"${s}_main_dsg.dot")
}

val regionInjector = if (config.memoryRegions == MemoryRegionsMode.DSA) {
Logger.debug("[!] Injecting regions")
val regionInjector = if (config.memoryRegions == MemoryRegionsMode.MRA) {
val injector = RegionInjectorMRA(ctx.program, analysisResult.last.mmmResults)
injector.injectRegions()
Some(injector)
} else if (config.memoryRegions == MemoryRegionsMode.DSA) {
val injector = RegionInjectorDSA(ctx.program, dsa.topDown)
injector.injectRegions()
Some(injector)
Expand Down

0 comments on commit db6f2ca

Please sign in to comment.