Conversation
…oized sets of analyses
…enerateProcedureSummaries and generateRelyGuaranteeConditions; added documentation to Transform, StaticAnalysis and AnalysisManager classes; started on transforms for doSimplify
…e appropriate locations
|
|
…orms out of RunUtils.IRTransforms. Created some new transforms.
katrinafyi
left a comment
There was a problem hiding this comment.
seems fine, it's very good to unify the dumping and logging things.
comments are more for future work
| if memo.isEmpty then memo = Some(analysis(AnalysisManager.this)) | ||
| memo.get |
| def getStripUnreachableFunctionsTransform(depth: Int): Transform = | ||
| SingleTransform( |
There was a problem hiding this comment.
i dont really like the need to wrap parametrised transforms in a get method. maybe the Transform class can be changed to take an additional custom parameter.
| trait Log { | ||
| def dump(ctx: IRContext, transformName: String): Unit | ||
| } | ||
|
|
||
| // dumps a blockgraph log | ||
| case class BlockgraphLog(filenamePrefix: String) extends Log { | ||
| def dump(ctx: IRContext, transformName: String): Unit = | ||
| DebugDumpIRLogger.writeToFile( | ||
| File(s"${filenamePrefix}_blockgraph-${transformName}.dot"), | ||
| dotBlockGraph(ctx.program.mainProcedure) | ||
| ) | ||
| } | ||
|
|
||
| // dumps an IR log | ||
| case class IrLog(filenamePrefix: String) extends Log { | ||
| def dump(ctx: IRContext, transformName: String): Unit = | ||
| DebugDumpIRLogger.writeToFile(File(s"${filenamePrefix}_il-${transformName}.il"), pp_prog(ctx.program)) | ||
| } |
There was a problem hiding this comment.
what's the point of this? these could just be methods surely
| // executes the transform with any modifications or book-keeping specified by the given config | ||
| def apply(ctx: IRContext, man: AnalysisManager, config: TransformConfig = emptyConfig): Unit = { | ||
| if (config.disabled.contains(this)) return | ||
| if (notice != "") then Logger.info(s"[!] ${notice}") | ||
| if (man.program ne ctx.program) { | ||
| // the program we are transforming should be the same one for which the analysis results were produced | ||
| throw new RuntimeException( | ||
| s"Transform '$name' was passed an AnalysisManager of an IR Program with a different " + | ||
| s"reference value than the program being transformed." | ||
| ) | ||
| } | ||
| val maybeLogs = config.dumpLogs.get(this) | ||
| maybeLogs.foreach(_.foreach(_.dump(ctx, s"before-$name"))) | ||
| timer.checkPoint("start") | ||
| val invalidation = transform(ctx, man, config) // run the actual transform and get the analysis results to clobber | ||
| timer.checkPoint("end") | ||
| postRun(ctx) // runs after performance checks, and before logging | ||
| maybeLogs.foreach(_.foreach(_.dump(ctx, s"after-$name"))) | ||
| man.invalidate(invalidation) // clobber the specified analysis results | ||
| } |
There was a problem hiding this comment.
i think this method belongs more in the AnalysisManager, but shrug
| case class SingleTransform( | ||
| name: String, | ||
| implementation: (ctx: IRContext, man: AnalysisManager) => man.Invalidation, | ||
| notice: String = "" | ||
| ) extends Transform { |
There was a problem hiding this comment.
single transform could be done as a special case of transform batch
…reamlined the Transform and TransformBatch classes
|
This most recent merge had some pretty significant conflicts. Fortunately, most of these were due to @katrinafyi's changes to the IRLoading object, which @ailrst moved to a new file in the feature branch. I resolved these by overwriting the new file with Kait's changes. Another was due to the new loop invariant generation pass, which I resolved by creating a new reducibleLoops function in AnalysePipelineMRA.scala, effectively re-creating the function added to the now-removed StaticAnalysis object in RunUtils. One important change that I'm not sure about is the tests. Particularly, I removed some tests from IntervalDSATest.scala in an attempt to capture the latest changes made to the file. I'm not sure if this was correct and it would be good to check this with the author of the tests. To ensure the refactor preserves the old behaviour, I loosely combed through the prepareForTranslation and doCleanup transforms and didn't find any discrepancies with the original functions in RunUtils. The doSimplify transform is still under development in Simp.scala. |
Some initial progress towards cleaning up RunUtils. Created classes Transform, StaticAnalysis and AnalysisManager. Refactored doCleanup, prepareForTranslation, generateRelyGuaranteeConditions, and generateFunctionSummaries to use the Transform class.
Some initial progress towards cleaning up RunUtils.
Created classes Transform, StaticAnalysis and AnalysisManager. Refactored doCleanup, prepareForTranslation, generateRelyGuaranteeConditions, and generateFunctionSummaries to use the Transform class.