-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UpdateLLCTestChecks] Add support for isel debug output in update_llc…
…_test_checks.py Add a check on run lines to pick up isel options in llc commands and allow generating check lines of isel final output other than assembly. If llc command line contains -debug-only=isel, update_llc_test_checks.py will try to scrub isel output, otherwise, the script will fall back on default behaviour, which is try to scrub assembly output instead. The motivation of this change is to allow usage of update_llc_test_checks.py to autogenerate checks of instruction selection results. In this way, we can detect errors at an earlier stage before the compilation goes all the way to assembly. It is an example of having some transparency for the stages between IR and assembly. These generated tests are almost like "unit tests" of isel stage. This patch only implements the initial change to differentiate isel output from assembly output for Lanai. Other targets will not be supported for isel check generation at the moment. Although adding support for it will only require implementing the function regex and scrubber for corresponding targets. The Lanai implementation was chosen mainly for the simplicity of demonstrating the difference between isel checks and asm checks. This patch also do not include the implementation of function prefix, which is required for the generated isel checks to pass. I will put up a follow up revision for the function prefix change to complete isel support. Reviewed By: Flakebi Differential Revision: https://reviews.llvm.org/D119368
- Loading branch information
Showing
20 changed files
with
834 additions
and
30 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_asm.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa < %s | FileCheck %s | ||
|
||
define i64 @i64_test(i64 %i) nounwind readnone { | ||
%loc = alloca i64 | ||
%j = load i64, i64 * %loc | ||
%r = add i64 %i, %j | ||
ret i64 %r | ||
} | ||
|
||
define i64 @i32_test(i32 %i) nounwind readnone { | ||
%loc = alloca i32 | ||
%j = load i32, i32 * %loc | ||
%r = add i32 %i, %j | ||
%ext = zext i32 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i16_test(i16 %i) nounwind readnone { | ||
%loc = alloca i16 | ||
%j = load i16, i16 * %loc | ||
%r = add i16 %i, %j | ||
%ext = zext i16 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i8_test(i8 %i) nounwind readnone { | ||
%loc = alloca i8 | ||
%j = load i8, i8 * %loc | ||
%r = add i8 %i, %j | ||
%ext = zext i8 %r to i64 | ||
ret i64 %ext | ||
} |
56 changes: 56 additions & 0 deletions
56
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_asm.ll.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa < %s | FileCheck %s | ||
|
||
define i64 @i64_test(i64 %i) nounwind readnone { | ||
; CHECK-LABEL: i64_test: | ||
; CHECK: ; %bb.0: | ||
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; CHECK-NEXT: v_mov_b32_e32 v1, 0 | ||
; CHECK-NEXT: s_setpc_b64 s[30:31] | ||
%loc = alloca i64 | ||
%j = load i64, i64 * %loc | ||
%r = add i64 %i, %j | ||
ret i64 %r | ||
} | ||
|
||
define i64 @i32_test(i32 %i) nounwind readnone { | ||
; CHECK-LABEL: i32_test: | ||
; CHECK: ; %bb.0: | ||
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; CHECK-NEXT: v_mov_b32_e32 v0, 0 | ||
; CHECK-NEXT: v_mov_b32_e32 v1, 0 | ||
; CHECK-NEXT: s_setpc_b64 s[30:31] | ||
%loc = alloca i32 | ||
%j = load i32, i32 * %loc | ||
%r = add i32 %i, %j | ||
%ext = zext i32 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i16_test(i16 %i) nounwind readnone { | ||
; CHECK-LABEL: i16_test: | ||
; CHECK: ; %bb.0: | ||
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; CHECK-NEXT: v_mov_b32_e32 v0, 0 | ||
; CHECK-NEXT: v_mov_b32_e32 v1, 0 | ||
; CHECK-NEXT: s_setpc_b64 s[30:31] | ||
%loc = alloca i16 | ||
%j = load i16, i16 * %loc | ||
%r = add i16 %i, %j | ||
%ext = zext i16 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i8_test(i8 %i) nounwind readnone { | ||
; CHECK-LABEL: i8_test: | ||
; CHECK: ; %bb.0: | ||
; CHECK-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
; CHECK-NEXT: v_mov_b32_e32 v0, 0 | ||
; CHECK-NEXT: v_mov_b32_e32 v1, 0 | ||
; CHECK-NEXT: s_setpc_b64 s[30:31] | ||
%loc = alloca i8 | ||
%j = load i8, i8 * %loc | ||
%r = add i8 %i, %j | ||
%ext = zext i8 %r to i64 | ||
ret i64 %ext | ||
} |
32 changes: 32 additions & 0 deletions
32
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_isel.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -stop-after=finalize-isel -debug-only=isel -o /dev/null %s 2>&1 | FileCheck %s | ||
|
||
define i64 @i64_test(i64 %i) nounwind readnone { | ||
%loc = alloca i64 | ||
%j = load i64, i64 * %loc | ||
%r = add i64 %i, %j | ||
ret i64 %r | ||
} | ||
|
||
define i64 @i32_test(i32 %i) nounwind readnone { | ||
%loc = alloca i32 | ||
%j = load i32, i32 * %loc | ||
%r = add i32 %i, %j | ||
%ext = zext i32 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i16_test(i16 %i) nounwind readnone { | ||
%loc = alloca i16 | ||
%j = load i16, i16 * %loc | ||
%r = add i16 %i, %j | ||
%ext = zext i16 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i8_test(i8 %i) nounwind readnone { | ||
%loc = alloca i8 | ||
%j = load i8, i8 * %loc | ||
%r = add i8 %i, %j | ||
%ext = zext i8 %r to i64 | ||
ret i64 %ext | ||
} |
73 changes: 73 additions & 0 deletions
73
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/amdgpu_isel.ll.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=amdgcn-amd-amdhsa -stop-after=finalize-isel -debug-only=isel -o /dev/null %s 2>&1 | FileCheck %s | ||
|
||
define i64 @i64_test(i64 %i) nounwind readnone { | ||
; CHECK-LABEL: i64_test: | ||
; CHECK: SelectionDAG has 13 nodes: | ||
; CHECK-NEXT: t0: ch = EntryToken | ||
; CHECK-NEXT: t11: i64,ch = CopyFromReg t0, Register:i64 %2 | ||
; CHECK-NEXT: t13: ch,glue = CopyToReg t0, Register:i64 %3, t11 | ||
; CHECK-NEXT: t15: ch,glue = CopyToReg t13, Register:i32 $vgpr0, IMPLICIT_DEF:i32, t13:1 | ||
; CHECK-NEXT: t21: i32 = V_MOV_B32_e32 TargetConstant:i32<0> | ||
; CHECK-NEXT: t17: ch,glue = CopyToReg t15, Register:i32 $vgpr1, t21, t15:1 | ||
; CHECK-NEXT: t18: ch = S_SETPC_B64_return Register:i64 %3, Register:i32 $vgpr0, Register:i32 $vgpr1, t17, t17:1 | ||
; CHECK-EMPTY: | ||
%loc = alloca i64 | ||
%j = load i64, i64 * %loc | ||
%r = add i64 %i, %j | ||
ret i64 %r | ||
} | ||
|
||
define i64 @i32_test(i32 %i) nounwind readnone { | ||
; CHECK-LABEL: i32_test: | ||
; CHECK: SelectionDAG has 12 nodes: | ||
; CHECK-NEXT: t0: ch = EntryToken | ||
; CHECK-NEXT: t5: i32 = V_MOV_B32_e32 TargetConstant:i32<0> | ||
; CHECK-NEXT: t7: i64,ch = CopyFromReg t0, Register:i64 %1 | ||
; CHECK-NEXT: t9: ch,glue = CopyToReg t0, Register:i64 %2, t7 | ||
; CHECK-NEXT: t11: ch,glue = CopyToReg t9, Register:i32 $vgpr0, t5, t9:1 | ||
; CHECK-NEXT: t13: ch,glue = CopyToReg t11, Register:i32 $vgpr1, t5, t11:1 | ||
; CHECK-NEXT: t14: ch = S_SETPC_B64_return Register:i64 %2, Register:i32 $vgpr0, Register:i32 $vgpr1, t13, t13:1 | ||
; CHECK-EMPTY: | ||
%loc = alloca i32 | ||
%j = load i32, i32 * %loc | ||
%r = add i32 %i, %j | ||
%ext = zext i32 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i16_test(i16 %i) nounwind readnone { | ||
; CHECK-LABEL: i16_test: | ||
; CHECK: SelectionDAG has 12 nodes: | ||
; CHECK-NEXT: t0: ch = EntryToken | ||
; CHECK-NEXT: t5: i32 = V_MOV_B32_e32 TargetConstant:i32<0> | ||
; CHECK-NEXT: t7: i64,ch = CopyFromReg t0, Register:i64 %1 | ||
; CHECK-NEXT: t9: ch,glue = CopyToReg t0, Register:i64 %2, t7 | ||
; CHECK-NEXT: t11: ch,glue = CopyToReg t9, Register:i32 $vgpr0, t5, t9:1 | ||
; CHECK-NEXT: t13: ch,glue = CopyToReg t11, Register:i32 $vgpr1, t5, t11:1 | ||
; CHECK-NEXT: t14: ch = S_SETPC_B64_return Register:i64 %2, Register:i32 $vgpr0, Register:i32 $vgpr1, t13, t13:1 | ||
; CHECK-EMPTY: | ||
%loc = alloca i16 | ||
%j = load i16, i16 * %loc | ||
%r = add i16 %i, %j | ||
%ext = zext i16 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i8_test(i8 %i) nounwind readnone { | ||
; CHECK-LABEL: i8_test: | ||
; CHECK: SelectionDAG has 12 nodes: | ||
; CHECK-NEXT: t0: ch = EntryToken | ||
; CHECK-NEXT: t5: i32 = V_MOV_B32_e32 TargetConstant:i32<0> | ||
; CHECK-NEXT: t7: i64,ch = CopyFromReg t0, Register:i64 %1 | ||
; CHECK-NEXT: t9: ch,glue = CopyToReg t0, Register:i64 %2, t7 | ||
; CHECK-NEXT: t11: ch,glue = CopyToReg t9, Register:i32 $vgpr0, t5, t9:1 | ||
; CHECK-NEXT: t13: ch,glue = CopyToReg t11, Register:i32 $vgpr1, t5, t11:1 | ||
; CHECK-NEXT: t14: ch = S_SETPC_B64_return Register:i64 %2, Register:i32 $vgpr0, Register:i32 $vgpr1, t13, t13:1 | ||
; CHECK-EMPTY: | ||
%loc = alloca i8 | ||
%j = load i8, i8 * %loc | ||
%r = add i8 %i, %j | ||
%ext = zext i8 %r to i64 | ||
ret i64 %ext | ||
} |
32 changes: 32 additions & 0 deletions
32
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/lanai_asm.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; RUN: llc -mtriple=lanai < %s | FileCheck %s | ||
|
||
define i64 @i64_test(i64 %i) nounwind readnone { | ||
%loc = alloca i64 | ||
%j = load i64, i64 * %loc | ||
%r = add i64 %i, %j | ||
ret i64 %r | ||
} | ||
|
||
define i64 @i32_test(i32 %i) nounwind readnone { | ||
%loc = alloca i32 | ||
%j = load i32, i32 * %loc | ||
%r = add i32 %i, %j | ||
%ext = zext i32 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i16_test(i16 %i) nounwind readnone { | ||
%loc = alloca i16 | ||
%j = load i16, i16 * %loc | ||
%r = add i16 %i, %j | ||
%ext = zext i16 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i8_test(i8 %i) nounwind readnone { | ||
%loc = alloca i8 | ||
%j = load i8, i8 * %loc | ||
%r = add i8 %i, %j | ||
%ext = zext i8 %r to i64 | ||
ret i64 %ext | ||
} |
95 changes: 95 additions & 0 deletions
95
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/lanai_asm.ll.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
; RUN: llc -mtriple=lanai < %s | FileCheck %s | ||
|
||
define i64 @i64_test(i64 %i) nounwind readnone { | ||
; CHECK-LABEL: i64_test: | ||
; CHECK: ! %bb.0: | ||
; CHECK-NEXT: st %fp, [--%sp] | ||
; CHECK-NEXT: add %sp, 0x8, %fp | ||
; CHECK-NEXT: sub %sp, 0x10, %sp | ||
; CHECK-NEXT: ld 4[%fp], %r3 | ||
; CHECK-NEXT: ld 0[%fp], %r9 | ||
; CHECK-NEXT: sub %fp, 0x10, %r12 | ||
; CHECK-NEXT: or %r12, 0x4, %r12 | ||
; CHECK-NEXT: ld -16[%fp], %r13 | ||
; CHECK-NEXT: ld 0[%r12], %r12 | ||
; CHECK-NEXT: add %r9, %r13, %r13 | ||
; CHECK-NEXT: add %r3, %r12, %r9 | ||
; CHECK-NEXT: sub.f %r9, %r3, %r0 | ||
; CHECK-NEXT: sult %r3 | ||
; CHECK-NEXT: add %r13, %r3, %rv | ||
; CHECK-NEXT: ld -4[%fp], %pc ! return | ||
; CHECK-NEXT: add %fp, 0x0, %sp | ||
; CHECK-NEXT: ld -8[%fp], %fp | ||
%loc = alloca i64 | ||
%j = load i64, i64 * %loc | ||
%r = add i64 %i, %j | ||
ret i64 %r | ||
} | ||
|
||
define i64 @i32_test(i32 %i) nounwind readnone { | ||
; CHECK-LABEL: i32_test: | ||
; CHECK: ! %bb.0: | ||
; CHECK-NEXT: st %fp, [--%sp] | ||
; CHECK-NEXT: add %sp, 0x8, %fp | ||
; CHECK-NEXT: sub %sp, 0x10, %sp | ||
; CHECK-NEXT: ld 0[%fp], %r3 | ||
; CHECK-NEXT: ld -12[%fp], %r9 | ||
; CHECK-NEXT: add %r3, %r9, %r9 | ||
; CHECK-NEXT: or %r0, 0x0, %rv | ||
; CHECK-NEXT: ld -4[%fp], %pc ! return | ||
; CHECK-NEXT: add %fp, 0x0, %sp | ||
; CHECK-NEXT: ld -8[%fp], %fp | ||
%loc = alloca i32 | ||
%j = load i32, i32 * %loc | ||
%r = add i32 %i, %j | ||
%ext = zext i32 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i16_test(i16 %i) nounwind readnone { | ||
; CHECK-LABEL: i16_test: | ||
; CHECK: ! %bb.0: | ||
; CHECK-NEXT: st %fp, [--%sp] | ||
; CHECK-NEXT: add %sp, 0x8, %fp | ||
; CHECK-NEXT: sub %sp, 0x10, %sp | ||
; CHECK-NEXT: add %fp, 0x0, %r3 | ||
; CHECK-NEXT: or %r3, 0x2, %r3 | ||
; CHECK-NEXT: uld.h 0[%r3], %r3 | ||
; CHECK-NEXT: uld.h -10[%fp], %r9 | ||
; CHECK-NEXT: add %r3, %r9, %r3 | ||
; CHECK-NEXT: and %r3, 0xffff, %r9 | ||
; CHECK-NEXT: or %r0, 0x0, %rv | ||
; CHECK-NEXT: ld -4[%fp], %pc ! return | ||
; CHECK-NEXT: add %fp, 0x0, %sp | ||
; CHECK-NEXT: ld -8[%fp], %fp | ||
%loc = alloca i16 | ||
%j = load i16, i16 * %loc | ||
%r = add i16 %i, %j | ||
%ext = zext i16 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i8_test(i8 %i) nounwind readnone { | ||
; CHECK-LABEL: i8_test: | ||
; CHECK: ! %bb.0: | ||
; CHECK-NEXT: st %fp, [--%sp] | ||
; CHECK-NEXT: add %sp, 0x8, %fp | ||
; CHECK-NEXT: sub %sp, 0x10, %sp | ||
; CHECK-NEXT: add %fp, 0x0, %r3 | ||
; CHECK-NEXT: or %r3, 0x3, %r3 | ||
; CHECK-NEXT: uld.b 0[%r3], %r3 | ||
; CHECK-NEXT: uld.b -9[%fp], %r9 | ||
; CHECK-NEXT: add %r3, %r9, %r3 | ||
; CHECK-NEXT: mov 0xff, %r9 | ||
; CHECK-NEXT: and %r3, %r9, %r9 | ||
; CHECK-NEXT: or %r0, 0x0, %rv | ||
; CHECK-NEXT: ld -4[%fp], %pc ! return | ||
; CHECK-NEXT: add %fp, 0x0, %sp | ||
; CHECK-NEXT: ld -8[%fp], %fp | ||
%loc = alloca i8 | ||
%j = load i8, i8 * %loc | ||
%r = add i8 %i, %j | ||
%ext = zext i8 %r to i64 | ||
ret i64 %ext | ||
} |
32 changes: 32 additions & 0 deletions
32
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/lanai_isel.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
; RUN: llc -mtriple=lanai -stop-after=finalize-isel -debug-only=isel -o /dev/null %s 2>&1 | FileCheck %s | ||
|
||
define i64 @i64_test(i64 %i) nounwind readnone { | ||
%loc = alloca i64 | ||
%j = load i64, i64 * %loc | ||
%r = add i64 %i, %j | ||
ret i64 %r | ||
} | ||
|
||
define i64 @i32_test(i32 %i) nounwind readnone { | ||
%loc = alloca i32 | ||
%j = load i32, i32 * %loc | ||
%r = add i32 %i, %j | ||
%ext = zext i32 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i16_test(i16 %i) nounwind readnone { | ||
%loc = alloca i16 | ||
%j = load i16, i16 * %loc | ||
%r = add i16 %i, %j | ||
%ext = zext i16 %r to i64 | ||
ret i64 %ext | ||
} | ||
|
||
define i64 @i8_test(i8 %i) nounwind readnone { | ||
%loc = alloca i8 | ||
%j = load i8, i8 * %loc | ||
%r = add i8 %i, %j | ||
%ext = zext i8 %r to i64 | ||
ret i64 %ext | ||
} |
Oops, something went wrong.