Skip to content

Commit a8a89c7

Browse files
committed
[utils] Reflow asm check generation to tolerate blank lines
This change introduces two fixes. The second fix allows to generate a test to check the first fix. - Output `CHECK-EMPTY` prefix for an empty line in ASM output. Before that fix `update_llc_test_checks.py` incorrectly emits `CHECK-NEXT: <space>` prefix. - Fix the `ASM_FUNCTION_MIPS_RE` regex to stop on a real function epilogue not on an inline assembler prologue and include inline assembler code into a test. Differential Revision: https://reviews.llvm.org/D47192
1 parent 6221767 commit a8a89c7

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

llvm/test/CodeGen/Mips/inlineasm-constraint-reg64.ll

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
12
;
23
; Register constraint "r" shouldn't take long long unless
34
; The target is 64 bit.
@@ -7,13 +8,25 @@
78

89

910
define i32 @main() nounwind {
11+
; CHECK-LABEL: main:
12+
; CHECK: # %bb.0: # %entry
13+
; CHECK-NEXT: daddiu $1, $zero, 7
14+
; CHECK-NEXT: #APP
15+
; CHECK-NEXT: .set push
16+
; CHECK-NEXT: .set at
17+
; CHECK-NEXT: .set macro
18+
; CHECK-NEXT: .set reorder
19+
; CHECK-EMPTY:
20+
; CHECK-NEXT: addiu $1, $1, 3
21+
; CHECK-EMPTY:
22+
; CHECK-NEXT: .set pop
23+
; CHECK-NEXT: #NO_APP
24+
; CHECK-NEXT: jr $ra
25+
; CHECK-NEXT: addiu $2, $zero, 0
1026
entry:
1127

1228

1329
; r with long long
14-
;CHECK: #APP
15-
;CHECK: addiu ${{[0-9]+}}, ${{[0-9]+}}, 3
16-
;CHECK: #NO_APP
1730
tail call i64 asm sideeffect "addiu $0, $1, $2", "=r,r,i"(i64 7, i64 3) nounwind
1831
ret i32 0
1932
}

llvm/utils/UpdateTestChecks/asm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class string:
5353
r'^_?(?P<func>[^:]+):[ \t]*#+[ \t]*@(?P=func)\n[^:]*?' # f: (name of func)
5454
r'(?:^[ \t]+\.(frame|f?mask|set).*?\n)+' # Mips+LLVM standard asm prologue
5555
r'(?P<body>.*?)\n' # (body of the function)
56-
r'(?:^[ \t]+\.(set|end).*?\n)+' # Mips+LLVM standard asm epilogue
56+
# Mips+LLVM standard asm epilogue
57+
r'(?:(^[ \t]+\.set[^\n]*?\n)*^[ \t]+\.end.*?\n)'
5758
r'(\$|\.L)func_end[0-9]+:\n', # $func_end0: (mips32 - O32) or
5859
# .Lfunc_end0: (mips64 - NewABI)
5960
flags=(re.M | re.S))

llvm/utils/UpdateTestChecks/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,10 @@ def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name,
260260
if is_asm:
261261
output_lines.append('%s %s: %s' % (comment_marker, checkprefix, func_body[0]))
262262
for func_line in func_body[1:]:
263-
output_lines.append('%s %s-NEXT: %s' % (comment_marker, checkprefix, func_line))
263+
if func_line.strip() == '':
264+
output_lines.append('%s %s-EMPTY:' % (comment_marker, checkprefix))
265+
else:
266+
output_lines.append('%s %s-NEXT: %s' % (comment_marker, checkprefix, func_line))
264267
break
265268

266269
# For IR output, change all defs to FileCheck variables, so we're immune

0 commit comments

Comments
 (0)