Skip to content

Commit 0361c41

Browse files
authored
[utils] avoid splitting pass names with spaces (llvm#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.
1 parent 86f7374 commit 0361c41

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@
1010
import re
1111

1212
chunk_id = 0
13+
pass_regex = re.compile(r"\(([\w-]+)\)")
1314

1415
# This function gets the pass name from the following line:
1516
# *** IR Dump Before/After PASS_NAME... ***
1617
def get_pass_name(line, prefix):
18+
# avoid accidentally parsing function name in e.g.
19+
# "*** IR Dump Before InlinerPass on (foo) ***"
20+
line = line.split(" on ")[0]
21+
non_pretty_pass_name = pass_regex.search(line)
22+
# machine function pass names can contain spaces,
23+
# but have a CLI friendly name also, e.g.:
24+
# "*** IR Dump Before Stack Frame Layout Analysis (stack-frame-layout) ***"
25+
if non_pretty_pass_name:
26+
return non_pretty_pass_name.group(1)
1727
short_line = line[line.find(prefix) + len(prefix) + 1 :]
1828
return re.split(" |<", short_line)[0]
1929

0 commit comments

Comments
 (0)