[llvm] [utils] avoid splitting pass names with spaces (PR #97371)

Henrik G. Olsson via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 18:34:54 PDT 2024


https://github.com/hnrklssn created https://github.com/llvm/llvm-project/pull/97371

Machine function pass names can contain spaces but have an alternative CLI friendly name within parentheses. This changes chunk-print-before-all.py to use this name instead of only the first word in the pretty printed name.

>From d2e664b3de12c92740ff78dd88c2f94f3595daa0 Mon Sep 17 00:00:00 2001
From: "Henrik G. Olsson" <h_olsson at apple.com>
Date: Mon, 1 Jul 2024 17:15:39 -0700
Subject: [PATCH] [utils] avoid splitting pass names with spaces

Machine function pass names can contain spaces but have an alternative
CLI friendly name within parentheses. This changes
chunk-print-before-all.py to use this name instead of only the first
word in the pretty printed name.
---
 llvm/utils/chunk-print-before-all.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/llvm/utils/chunk-print-before-all.py b/llvm/utils/chunk-print-before-all.py
index fef8eb64c5403..6ad126e4dff09 100755
--- a/llvm/utils/chunk-print-before-all.py
+++ b/llvm/utils/chunk-print-before-all.py
@@ -10,10 +10,20 @@
 import re
 
 chunk_id = 0
+pass_regex = re.compile(r"\(([\w-]+)\)")
 
 # This function gets the pass name from the following line:
 # *** IR Dump Before/After PASS_NAME... ***
 def get_pass_name(line, prefix):
+    # avoid accidentally parsing function name in e.g.
+    # "*** IR Dump Before InlinerPass on (foo) ***"
+    line = line.split(" on ")[0]
+    non_pretty_pass_name = pass_regex.search(line)
+    # machine function pass names can contain spaces,
+    # but have a CLI friendly name also, e.g.:
+    # "*** IR Dump Before Stack Frame Layout Analysis (stack-frame-layout) ***"
+    if non_pretty_pass_name:
+        return non_pretty_pass_name.group(1)
     short_line = line[line.find(prefix) + len(prefix) + 1 :]
     return re.split(" |<", short_line)[0]
 



More information about the llvm-commits mailing list