diff options
author | Anirudh Sundar Subramaniam <quic_sanirudh@quicinc.com> | 2024-01-09 03:02:45 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-08 15:32:45 -0600 |
commit | c3f8f8665bde9844828f953d069c2344ca81cb7c (patch) | |
tree | 4769968a81fb74e614a19ec75dca7020fad46855 | |
parent | d81101336384a3e8d507076d5bf43cf95d844716 (diff) | |
download | compiler-explorer-gh-10067.tar.gz compiler-explorer-gh-10067.zip |
Handle ir and machine functions separately in OptPipeline (#5902)gh-10067
This patch makes a small change in how functions are handled while
parsing LLVM opt pipeline output. Specifically, it differentiates
between IR function and machine function, and while checking for the
close of function, it only checks if the corresponding function is open.
This was needed because in some targets like hexagon, the machine
functions could contain `BUNDLE`s as part of the dump and `BUNDLE`s are
also represented with opening and closing braces ({}). This was causing
assertion because the close brace for a BUNDLE was considered to be a IR
function close statement.
-rw-r--r-- | CONTRIBUTORS.md | 1 | ||||
-rw-r--r-- | lib/parsers/llvm-pass-dump-parser.ts | 14 |
2 files changed, 12 insertions, 3 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a058d5f9a..aafec5ce1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -141,3 +141,4 @@ From oldest to newest contributor, we would like to thank: - [Rupert Tombs](https://github.com/Rupt) - [Andrew Brey](https://github.com/andrewbrey) - [Weile Wei](https://github.com/weilewei) +- [Anirudh Sundar Subramaniam](https://github.com/quic-sanirudh) diff --git a/lib/parsers/llvm-pass-dump-parser.ts b/lib/parsers/llvm-pass-dump-parser.ts index e26a05efe..97419aeef 100644 --- a/lib/parsers/llvm-pass-dump-parser.ts +++ b/lib/parsers/llvm-pass-dump-parser.ts @@ -76,6 +76,7 @@ export class LlvmPassDumpParser { functionDefine: RegExp; machineFunctionBegin: RegExp; functionEnd: RegExp; + machineFunctionEnd: RegExp; //label: RegExp; //instruction: RegExp; @@ -126,8 +127,10 @@ export class LlvmPassDumpParser { // `define internal void @__cxx_global_var_init.1() #0 section ".text.startup" {` this.functionDefine = /^define .+ @([\w.]+|"[^"]+")\(.+$/; this.machineFunctionBegin = /^# Machine code for function ([\w$.]+):.*$/; - // Functions end with either a closing brace or "# End machine code for function _Z3fooi." - this.functionEnd = /^(?:}|# End machine code for function ([\w$.]+).)$/; + // IR Functions end with either a closing brace + this.functionEnd = /^}$/; + // Machine functions end like "# End machine code for function _Z3fooi." + this.machineFunctionEnd = /^# End machine code for function ([\w$.]+).$/; // Either "123:" with a possible comment or something like "bb.3 (%ir-block.13):" //this.label = /^(?:\d+:(\s+;.+)?|\w+.+:)$/; //this.instruction = /^\s+.+$/; @@ -194,6 +197,7 @@ export class LlvmPassDumpParser { name: string; lines: ResultLine[]; } | null = null; + let isMachineFunctionOpen: boolean = false; for (const line of dump.lines) { const irFnMatch = line.text.match(this.functionDefine); const machineFnMatch = line.text.match(this.machineFunctionBegin); @@ -206,6 +210,7 @@ export class LlvmPassDumpParser { name: (irFnMatch || machineFnMatch)![1], lines: [line], // include the current line }; + isMachineFunctionOpen = !!machineFnMatch; } else if (line.text.startsWith('; Preheader:')) { // loop dump // every line in this dump should be part of the loop, exit condition will be end of the for loop @@ -216,7 +221,10 @@ export class LlvmPassDumpParser { }; } else { // close function - if (this.functionEnd.test(line.text.trim())) { + if ( + (!isMachineFunctionOpen && this.functionEnd.test(line.text.trim())) || + (isMachineFunctionOpen && this.machineFunctionEnd.test(line.text.trim())) + ) { // if not currently in a function assert(func); const {name, lines} = func; |