diff options
Diffstat (limited to 'lib/parsers/llvm-pass-dump-parser.ts')
-rw-r--r-- | lib/parsers/llvm-pass-dump-parser.ts | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/parsers/llvm-pass-dump-parser.ts b/lib/parsers/llvm-pass-dump-parser.ts index dc9ca637e..ecb62fed3 100644 --- a/lib/parsers/llvm-pass-dump-parser.ts +++ b/lib/parsers/llvm-pass-dump-parser.ts @@ -82,6 +82,8 @@ type SplitPassDump = { export class LlvmPassDumpParser { filters: RegExp[]; lineFilters: RegExp[]; + debugInfoFilters: RegExp[]; + debugInfoLineFilters: RegExp[]; irDumpHeader: RegExp; machineCodeDumpHeader: RegExp; functionDefine: RegExp; @@ -100,17 +102,23 @@ export class LlvmPassDumpParser { /^; ModuleID = '.+'$/, // module id line /^(source_filename|target datalayout|target triple) = ".+"$/, // module metadata /^; Function Attrs: .+$/, // function attributes - /^\s+call void @llvm.dbg.value.+$/, // dbg calls - /^\s+call void @llvm.dbg.declare.+$/, // dbg calls /^declare .+$/, // declare directives + /^attributes #\d+ = { .+ }$/, // attributes directive + ]; + this.lineFilters = [ + /,? #\d+((?=( {)?$))/, // attribute annotation + ]; + + // Additional filters conditionally enabled by `filterDebugInfo` + this.debugInfoFilters = [ + /^\s+call void @llvm.dbg.+$/, // dbg calls + /^\s+DBG_.+$/, // dbg pseudo-instructions /^(!\d+) = (?:distinct )?!DI([A-Za-z]+)\(([^)]+?)\)/, // meta /^(!\d+) = (?:distinct )?!{.*}/, // meta /^(![.A-Z_a-z-]+) = (?:distinct )?!{.*}/, // meta - /^attributes #\d+ = { .+ }$/, // attributes directive ]; - this.lineFilters = [ + this.debugInfoLineFilters = [ /,? ![\dA-Za-z]+((?=( {)?$))/, // debug annotation - /,? #\d+((?=( {)?$))/, // attribute annotation ]; // Ir dump headers look like "*** IR Dump After XYZ ***" @@ -435,18 +443,26 @@ export class LlvmPassDumpParser { } process(ir: ResultLine[], _: ParseFilters, llvmOptPipelineOptions: LLVMOptPipelineBackendOptions) { + // Additional filters conditionally enabled by `filterDebugInfo` + let filters = this.filters; + let lineFilters = this.lineFilters; + if (llvmOptPipelineOptions.filterDebugInfo) { + filters = filters.concat(this.debugInfoFilters); + lineFilters = lineFilters.concat(this.debugInfoLineFilters); + } + // Filter a lot of junk before processing const preprocessed_lines = ir .slice( ir.findIndex(line => line.text.match(this.irDumpHeader) || line.text.match(this.machineCodeDumpHeader)), ) - .filter(line => this.filters.every(re => line.text.match(re) === null)) // apply filters + .filter(line => filters.every(re => line.text.match(re) === null)) // apply filters .map(_line => { let line = _line.text; // eslint-disable-next-line no-constant-condition while (true) { let newLine = line; - for (const re of this.lineFilters) { + for (const re of lineFilters) { newLine = newLine.replace(re, ''); } if (newLine === line) { |