Skip to content

Commit 2d34e04

Browse files
committed
Remove extra indentation from MIR check lines
1 parent 1e97c19 commit 2d34e04

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/x86_asm_mir_mixed.ll.expected

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ define i64 @test1(i64 %i) nounwind readnone {
88
; ASM-NEXT: movq %rdi, %rax
99
; ASM-NEXT: addq -{{[0-9]+}}(%rsp), %rax
1010
; ASM-NEXT: retq
11-
; MIR-LABEL: name: test1
12-
; MIR: bb.0 (%ir-block.0):
13-
; MIR-NEXT: liveins: $rdi
14-
; MIR-NEXT: {{ $}}
15-
; MIR-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rdi
16-
; MIR-NEXT: [[ADD64rm:%[0-9]+]]:gr64 = ADD64rm [[COPY]], %stack.0.loc, 1, $noreg, 0, $noreg, implicit-def dead $eflags :: (dereferenceable load (s64) from %ir.loc)
17-
; MIR-NEXT: $rax = COPY [[ADD64rm]]
18-
; MIR-NEXT: RET 0, $rax
11+
; MIR-LABEL: name: test1
12+
; MIR: bb.0 (%ir-block.0):
13+
; MIR-NEXT: liveins: $rdi
14+
; MIR-NEXT: {{ $}}
15+
; MIR-NEXT: [[COPY:%[0-9]+]]:gr64 = COPY $rdi
16+
; MIR-NEXT: [[ADD64rm:%[0-9]+]]:gr64 = ADD64rm [[COPY]], %stack.0.loc, 1, $noreg, 0, $noreg, implicit-def dead $eflags :: (dereferenceable load (s64) from %ir.loc)
17+
; MIR-NEXT: $rax = COPY [[ADD64rm]]
18+
; MIR-NEXT: RET 0, $rax
1919
%loc = alloca i64
2020
%j = load i64, i64 * %loc
2121
%r = add i64 %i, %j
@@ -28,15 +28,15 @@ define i64 @test2(i32 %i) nounwind readnone {
2828
; ASM-NEXT: movl %edi, %eax
2929
; ASM-NEXT: addl -{{[0-9]+}}(%rsp), %eax
3030
; ASM-NEXT: retq
31-
; MIR-LABEL: name: test2
32-
; MIR: bb.0 (%ir-block.0):
33-
; MIR-NEXT: liveins: $edi
34-
; MIR-NEXT: {{ $}}
35-
; MIR-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi
36-
; MIR-NEXT: [[ADD32rm:%[0-9]+]]:gr32 = ADD32rm [[COPY]], %stack.0.loc, 1, $noreg, 0, $noreg, implicit-def dead $eflags :: (dereferenceable load (s32) from %ir.loc)
37-
; MIR-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gr64 = SUBREG_TO_REG 0, killed [[ADD32rm]], %subreg.sub_32bit
38-
; MIR-NEXT: $rax = COPY [[SUBREG_TO_REG]]
39-
; MIR-NEXT: RET 0, $rax
31+
; MIR-LABEL: name: test2
32+
; MIR: bb.0 (%ir-block.0):
33+
; MIR-NEXT: liveins: $edi
34+
; MIR-NEXT: {{ $}}
35+
; MIR-NEXT: [[COPY:%[0-9]+]]:gr32 = COPY $edi
36+
; MIR-NEXT: [[ADD32rm:%[0-9]+]]:gr32 = ADD32rm [[COPY]], %stack.0.loc, 1, $noreg, 0, $noreg, implicit-def dead $eflags :: (dereferenceable load (s32) from %ir.loc)
37+
; MIR-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gr64 = SUBREG_TO_REG 0, killed [[ADD32rm]], %subreg.sub_32bit
38+
; MIR-NEXT: $rax = COPY [[SUBREG_TO_REG]]
39+
; MIR-NEXT: RET 0, $rax
4040
%loc = alloca i32
4141
%j = load i32, i32 * %loc
4242
%r = add i32 %i, %j

llvm/utils/UpdateTestChecks/common.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2549,6 +2549,7 @@ def add_mir_checks_for_function(
25492549
print_fixed_stack,
25502550
first_check_is_next,
25512551
at_the_function_name,
2552+
check_indent=None,
25522553
):
25532554
printed_prefixes = set()
25542555
for run in run_list:
@@ -2571,6 +2572,7 @@ def add_mir_checks_for_function(
25712572
func_dict[prefix][func_name],
25722573
print_fixed_stack,
25732574
first_check_is_next,
2575+
check_indent,
25742576
)
25752577
break
25762578
else:
@@ -2590,6 +2592,7 @@ def add_mir_check_lines(
25902592
func_info,
25912593
print_fixed_stack,
25922594
first_check_is_next,
2595+
check_indent=None,
25932596
):
25942597
func_body = str(func_info).splitlines()
25952598
if single_bb:
@@ -2606,7 +2609,11 @@ def add_mir_check_lines(
26062609
first_line = func_body[0]
26072610
indent = len(first_line) - len(first_line.lstrip(" "))
26082611
# A check comment, indented the appropriate amount
2609-
check = "{:>{}}; {}".format("", indent, prefix)
2612+
# If check_indent is provided, use it; otherwise, auto-detect from MIR body
2613+
if check_indent is not None:
2614+
check = "{}; {}".format(check_indent, prefix)
2615+
else:
2616+
check = "{:>{}}; {}".format("", indent, prefix)
26102617

26112618
output_lines.append("{}-LABEL: name: {}".format(check, func_name))
26122619

llvm/utils/update_llc_test_checks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ def update_test(ti: common.TestInfo):
261261
print_fixed_stack=False, # Don't print fixed stack (ASM tests don't need it).
262262
first_check_is_next=False, # First check is LABEL, not NEXT.
263263
at_the_function_name=False, # Use "name:" not "@name".
264+
check_indent="", # No indentation for IR files (not MIR files).
264265
)
265266

266267
is_in_function_start = False

0 commit comments

Comments
 (0)