From 78b3e2f40ff2ed97a12efebe59434b77d40a0f5f Mon Sep 17 00:00:00 2001 From: Yonah Goldberg Date: Tue, 3 Dec 2024 17:08:12 -0500 Subject: [PATCH] changes --- aeneas/src/ssa/SsaSubtypeSpecializer.v3 | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/aeneas/src/ssa/SsaSubtypeSpecializer.v3 b/aeneas/src/ssa/SsaSubtypeSpecializer.v3 index 38ffa0545..e6245f707 100644 --- a/aeneas/src/ssa/SsaSubtypeSpecializer.v3 +++ b/aeneas/src/ssa/SsaSubtypeSpecializer.v3 @@ -90,16 +90,16 @@ class SsaSpecializingRebuilder extends SsaRebuilder { newMethod.specialized = true; newMethod.source = om.source; newMethod.ssa = newGraph; - ssaPrinter.printGraph("Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig); + // ssaPrinter.printGraph("Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig); def newIrSpec = IrSpec.new(newMethod.receiver, [newMethod.receiver], newMethod); optContext.enterSpec(newIrSpec); SsaEarlyInliner.new(optContext, norm.ra.compilation, gen).inline(0); - ssaPrinter.printGraph("Post-Inlined Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig); + // ssaPrinter.printGraph("Post-Inlined Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig); optContext.enterSpec(newIrSpec); SsaOptimizer.new(optContext).optGraph(); - ssaPrinter.printGraph("Post-Optimized Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig); + // ssaPrinter.printGraph("Post-Optimized Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig); norm.newIr.methods.put(newMethod); return newMethod; @@ -181,6 +181,7 @@ class SsaSpecializingRebuilder extends SsaRebuilder { } // Get the class to specialize this operation to, if there is one def getSpecClass(oi: SsaApplyOp) -> RaClass { + if (oi.inputs.length == 0) return null; if (SsaParam.?(oi.input0())) { var param = SsaParam.!(oi.input0()); if (specs[param.index] != null) { @@ -333,7 +334,7 @@ component SubtypeUtil { specialized = true; // Terminal.put2("Specializing %q to %q\n", orig[i].render, spec[i].render); } else { - Terminal.put2("Mismatched types orig [%q] spec [%q]\n", orig[i].render, spec[i].render); + // Terminal.put2("Mismatched types orig [%q] spec [%q]\n", orig[i].render, spec[i].render); return false; } } @@ -363,10 +364,14 @@ class SsaSubtypeSpecializer { return false; } - // Currently we only specialize top-level methods - match (callers[0].instr.op.opcode) { - CallMethod(m) => ; - _ => return false; + for (i < callers.length) { + if (callers[i].instr == null) + continue; + // Currently we only specialize top-level methods + match (callers[i].instr.op.opcode) { + CallMethod(m) => break; + _ => return false; + } } return true; } @@ -478,6 +483,7 @@ class SsaSubtypeSpecializer { // Since we just specialized a method, we could've enabled more specializations // Add all the callees of the specialized method to the worklist def newCallees = callGraph.callerToCallee[specMethod]; + if (newCallees == null) continue; for (j < newCallees.length) { def callee = newCallees[j].callee; addToWorklist(callee, callGraph.calleeToCaller[callee]);