Additional opt-pipeline optimization (#8876)

In an attempt to address #8583.
Also fix the opt-pipeline timing measurement.
This commit is contained in:
Ofek
2026-06-30 22:26:08 +03:00
committed by GitHub
parent 2d074f870b
commit f7602b4360
2 changed files with 16 additions and 6 deletions

View File

@@ -1596,7 +1596,6 @@ export class BaseCompiler {
optPipelineOptions,
this.compiler.debugPatched,
);
const parseEnd = performance.now();
if (optPipelineOptions.demangle) {
// apply demangles after parsing, would otherwise greatly complicate the parsing of the passes
@@ -1611,13 +1610,13 @@ export class BaseCompiler {
return {
results: await demangler.demangleLLVMPasses(optPipeline),
compileTime: compileEnd - compileStart,
parseTime: parseEnd - parseStart,
parseTime: performance.now() - parseStart,
};
}
return {
results: optPipeline,
compileTime: compileEnd - compileStart,
parseTime: parseEnd - parseStart,
parseTime: performance.now() - parseStart,
};
} catch (e: any) {
return {

View File

@@ -75,13 +75,24 @@ export class LLVMIRDemangler {
protected processPassOutput(passOutput: OptPipelineResults, translations: [string, string][]) {
if (translations.length > 0) {
const tree = new PrefixTree(translations);
// Pass dumps are hugely redundant: `before[N+1]` is usually identical to `after[N]`, and the same IR
// lines repeat across dozens/hundreds of passes. Demangle each unique string once and reuse the result.
const cache = new Map<string, string>();
const demangle = (text: string) => {
let demangled = cache.get(text);
if (demangled === undefined) {
demangled = tree.replaceAllText(text);
cache.set(text, demangled);
}
return demangled;
};
for (const [functionName, passes] of Object.entries(passOutput)) {
const demangledFunctionName = tree.replaceAllText(functionName);
const demangledFunctionName = demangle(functionName);
for (const pass of passes) {
pass.name = tree.replaceAllText(pass.name); // needed at least for full module mode
pass.name = demangle(pass.name); // needed at least for full module mode
for (const dump of [pass.before, pass.after]) {
for (const line of dump) {
line.text = tree.replaceAllText(line.text);
line.text = demangle(line.text);
}
}
}