From 7c49ddf8863644da7f39c7d217d15a1ae2808719 Mon Sep 17 00:00:00 2001 From: "Ben L. Titzer" Date: Wed, 21 Oct 2026 10:48:21 -0400 Subject: [PATCH] Remove fine-grained optimization enable / disable machinery --- aeneas/src/ir/SsaNormalizer.v3 | 6 ++-- aeneas/src/mach/MachProgram.v3 | 3 +- aeneas/src/main/CLOptions.v3 | 8 ----- aeneas/src/main/Compiler.v3 | 66 ++-------------------------------- aeneas/src/main/Version.v3 | 2 +- 5 files changed, 6 insertions(+), 79 deletions(-) diff --git a/aeneas/src/ir/SsaNormalizer.v3 b/aeneas/src/ir/SsaNormalizer.v3 index bf6d8d3d4..0b5a4acb7 100644 --- a/aeneas/src/ir/SsaNormalizer.v3 +++ b/aeneas/src/ir/SsaNormalizer.v3 @@ -20,11 +20,9 @@ class SsaRaNormalizer extends SsaRebuilder { context.method = newMethod; context.graph = newMethod.ssa; context.printSsa("Normalized"); - if (context.compiler.NormOptimize && - context.compiler.optEnabled("(ra)", newMethod, null, null)) { + if (context.compiler.NormOptimize) { var opt = SsaOptimizer.new(context); - opt.optimize_loads = context.compiler.LoadOptimize && - context.compiler.optEnabled("(ra loads)", newMethod, null, null); + opt.optimize_loads = context.compiler.LoadOptimize; opt.optGraph(); context.printSsa("Norm Optimized"); } diff --git a/aeneas/src/mach/MachProgram.v3 b/aeneas/src/mach/MachProgram.v3 index 1697b0746..03eb09685 100644 --- a/aeneas/src/mach/MachProgram.v3 +++ b/aeneas/src/mach/MachProgram.v3 @@ -51,8 +51,7 @@ class MachProgram extends TargetProgram { var methods = prog.ir.methods; for (i < methods.length) { lowering.doMethod(methods[i]); - if (compiler.MachOptimize && - compiler.optEnabled("(mach)", methods[i], null, null)) { + if (compiler.MachOptimize) { opt.reset(lowering.context.graph); opt.optGraph(); lowering.context.printSsa("Mach Optimized"); diff --git a/aeneas/src/main/CLOptions.v3 b/aeneas/src/main/CLOptions.v3 index 6bfc73666..e3b6ba313 100644 --- a/aeneas/src/main/CLOptions.v3 +++ b/aeneas/src/main/CLOptions.v3 @@ -65,14 +65,6 @@ component CLOptions { "Limit the maximum number of scalars allowed for auto-unboxing variant types."); def INLINE = sharedOpt.newMatcherOption("inline", "Force inlining of direct calls to the given method(s)."); - def FIRST_ENABLED = sharedOpt.newIntOption("first-enabled", -1, - "First optimization decision enabled (count from 1)"); - def LAST_ENABLED = sharedOpt.newIntOption("last-enabled", Int.MAX_VALUE, - "Last optimization decision enabled (count from 1)"); - def FIRST_DISABLED = sharedOpt.newIntOption("first-disabled", Int.MAX_VALUE, - "First optimization decision disabled (count from 1)"); - def LAST_DISABLED = sharedOpt.newIntOption("last-disabled", -1, - "Last optimization decision disabled (count from 1)"); def LICM = sharedOpt.newBoolOption("licm", false, "Optimize with loop invariant code motion."); def USE_GLOBALREGALLOC = sharedOpt.newMatcherOption("global-regalloc", diff --git a/aeneas/src/main/Compiler.v3 b/aeneas/src/main/Compiler.v3 index ea06f5181..adc679a06 100644 --- a/aeneas/src/main/Compiler.v3 +++ b/aeneas/src/main/Compiler.v3 @@ -108,12 +108,6 @@ class Compiler(target: Target) { var MachBuildOpt = flags.get("MachBuildOpt", false); var LoopInvariantCodeMotion = flags.get("LoopInvariantCodeMotion", CLOptions.LICM.val); var IrAlloc = CLOptions.IR_ALLOC.get(); - var firstEnabled = CLOptions.FIRST_ENABLED.get(); - var lastEnabled = CLOptions.LAST_ENABLED.get(); - var firstDisabled = CLOptions.FIRST_DISABLED.get(); - var lastDisabled = CLOptions.LAST_DISABLED.get(); - var optCount = 0; // count of optimization decision points - private var doOptEnabledCheck = false; // XXX: flags for folding, reduction, typechecks, dead code, phi simplification // XXX: implement CSE and code motion // unsafe optimization settings; for performance testing only @@ -141,33 +135,6 @@ class Compiler(target: Target) { // target configures the compiler only once if (target != null) target.configureCompiler(this); - doOptEnabledCheck = !(firstEnabled == CLOptions.FIRST_ENABLED.init && - lastEnabled == CLOptions.LAST_ENABLED.init && - firstDisabled == CLOptions.FIRST_DISABLED.init && - lastDisabled == CLOptions.LAST_DISABLED.init); - } - - def optEnabledAt(count: int) -> bool { - if (count < firstEnabled || count > lastEnabled) return false; - if (count < firstDisabled || count > lastDisabled) return true; - return false; - } - def optEnabled(s: string, meth: IrMethod, block: SsaBlock, inst: SsaInstr) -> bool { - if (!doOptEnabledCheck) return true; - // want to identify enabled / disabled and transitions - var prev = optCount++; - var prevEnabled = optEnabledAt(prev); - var nowEnabled = optEnabledAt(optCount); - if (nowEnabled && !prevEnabled) { - var sb = Terminal.buf.yellow().put1("First enabled after disabled optimization #%d: ", optCount).end(); - showPoint(sb, s, meth, block, inst); - sb.outln(); - } else if (prevEnabled && !nowEnabled) { - var sb = Terminal.buf.yellow().put1("First disabled after enabled optimization #%d: ", optCount).end(); - showPoint(sb, s, meth, block, inst); - sb.outln(); - } - return nowEnabled; } def setLinkingModel(default: LinkingModel, supported: LinkingModel.set) { if (linking == LinkingModel.NONE) return; @@ -177,32 +144,6 @@ class Compiler(target: Target) { optError.addError(null, null, "target does not support linking model", linking.opt); } } - def showPoint(sb: StringBuilder, s: string, meth: IrMethod, block: SsaBlock, inst: SsaInstr) { - var sep = ""; - if (s != null && s.length > 0) { - sb.put1("%s", s); - sep = " "; - } - if (meth != null) { - sb.put3("%sMethod %q.%q", sep, meth.receiver.render, meth.render); - sep = " "; - } - if (block != null) { - sb.put2("%sBlock #%d", sep, block.uid); - sep = " "; - } - if (inst != null) { - sb.put2("%sSsaInst #%d", sep, inst.uid); - } - } - - def showOptCount() -> bool { - if (doOptEnabledCheck) { - Terminal.buf.yellow().put1("Number of optimization decision points: %d", optCount).end().outln(); - } - return true; - } - def getOutputFileName(fileName: string, ext: string) -> string { return Paths.assemble(CLOptions.OUTPUT.get(), fileName, ext); } @@ -258,7 +199,6 @@ class Compilation(compiler: Compiler, prog: Program) { && (!compiler.VstInit || init()) && (!compiler.Reachability || reachability()) && (!compiler.Emit || emit()) - && compiler.showOptCount() && prog.ERROR.noErrors; } def parse() -> bool { @@ -421,12 +361,10 @@ class Compilation(compiler: Compiler, prog: Program) { SsaOptimizer.new(context).optControlFlow(); context.printSsa("Control Optimized"); } - if (compiler.PostpassOptimize && - compiler.optEnabled("(gen)", meth, null, null)) { + if (compiler.PostpassOptimize) { // Run the post-pass optimizer. var opt = SsaOptimizer.new(context); - opt.optimize_loads = compiler.LoadOptimize && - compiler.optEnabled("(gen loads)", meth, null, null); + opt.optimize_loads = compiler.LoadOptimize; opt.optGraph(); context.printSsa("Postpass Optimized"); } diff --git a/aeneas/src/main/Version.v3 b/aeneas/src/main/Version.v3 index 8bda7b2d6..236ee5eec 100644 --- a/aeneas/src/main/Version.v3 +++ b/aeneas/src/main/Version.v3 @@ -4,6 +4,6 @@ // Updated by VCS scripts. DO NOT EDIT. component Version { def UNSTABLE = true; - def version: string = "III-13.2006"; + def version: string = "III-13.2007"; var buildData: string; }