[llvm] 0361c41 - [utils] avoid splitting pass names with spaces (#97371)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 5 00:59:40 PDT 2024


Author: Henrik G. Olsson
Date: 2024-08-05T09:59:36+02:00
New Revision: 0361c415e17f45b480be5befdb12175e8899357d

URL: https://github.com/llvm/llvm-project/commit/0361c415e17f45b480be5befdb12175e8899357d
DIFF: https://github.com/llvm/llvm-project/commit/0361c415e17f45b480be5befdb12175e8899357d.diff

LOG: [utils] avoid splitting pass names with spaces (#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.

Added: 
    

Modified: 
    llvm/utils/chunk-print-before-all.py

Removed: 
    


################################################################################
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