Issue 56051
Summary SIOptimizeExecMaskingPreRA does not preserve LiveIntervals
Labels backend:AMDGPU
Assignees
Reporter jayfoad
    See https://reviews.llvm.org/D127731 WIP: [MachineVerifier] Try harder to verify analyses

If I apply just the MachineVerifier part of this patch then I get see a couple of AMDGPU CodeGen tests failing with `Bad machine code: Multiple connected components in live interval`:
```
FAIL: LLVM :: CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir (1460 of 2843)
******************** TEST 'LLVM :: CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir' FAILED ********************
Script:
--
: 'RUN: at line 1';   /home/jayfoad2/llvm-release/bin/llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs -run-pass=si-optimize-exec-masking-pre-ra -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir | /home/jayfoad2/llvm-release/bin/FileCheck -check-prefix=GCN /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir
: 'RUN: at line 2';   /home/jayfoad2/llvm-release/bin/llc -march=amdgcn -mcpu=gfx1100 -verify-machineinstrs -run-pass=si-optimize-exec-masking-pre-ra -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir | /home/jayfoad2/llvm-release/bin/FileCheck -check-prefix=GCN /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir
--
Exit Code: 2

Command Output (stderr):
--
+ : 'RUN: at line 1'
+ /home/jayfoad2/llvm-release/bin/llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs -run-pass=si-optimize-exec-masking-pre-ra -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir
+ /home/jayfoad2/llvm-release/bin/FileCheck -check-prefix=GCN /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir

# After SI optimize exec mask operations pre-RA
********** INTERVALS **********
VCC_LO_LO16 [80r,96r:0) 0@80r
VCC_LO_HI16 [80r,96r:0) 0@80r
%0 [16r,32r:0) 0@16r  weight:0.000000e+00
%1 [32r,48r:0) 0@32r  weight:0.000000e+00
%2 [48r,48d:1)[64r,80r:0) 0@64r 1@48r  weight:0.000000e+00
RegMasks:
********** MACHINEINSTRS **********
# Machine code for function negated_cond_vop3_redef_cmp: NoPHIs

0B	bb.0:
	; predecessors: %bb.1
	  successors: %bb.2(0x40000000), %bb.1(0x40000000); %bb.2(50.00%), %bb.1(50.00%)

16B	  %0:sgpr_32 = IMPLICIT_DEF
32B	  %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0:sgpr_32, implicit $exec
48B	  dead %2:sgpr_32 = V_CMP_NE_U32_e64 %1:vgpr_32, 1, implicit $exec
64B	  %2:sgpr_32 = COPY $sgpr0
80B	  $vcc_lo = S_AND_B32 %2:sgpr_32, $exec_lo, implicit-def dead $scc
96B	  S_CBRANCH_VCCNZ %bb.2, implicit $vcc
112B	  S_BRANCH %bb.1

128B	bb.1:
	; predecessors: %bb.0
	  successors: %bb.0(0x80000000); %bb.0(100.00%)

144B	  S_BRANCH %bb.0

160B	bb.2:
	; predecessors: %bb.0

176B	  S_ENDPGM 0

# End machine code for function negated_cond_vop3_redef_cmp.

*** Bad machine code: Multiple connected components in live interval ***
- function:    negated_cond_vop3_redef_cmp
- interval:    %2 [48r,48d:1)[64r,80r:0) 0@64r 1@48r  weight:0.000000e+00
0: valnos 0
1: valnos 1
LLVM ERROR: Found 1 machine code errors.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/jayfoad2/llvm-release/bin/llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs -run-pass=si-optimize-exec-masking-pre-ra -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir
1.	Running pass 'Function Pass Manager' on module '/home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir'.
2.	Running pass 'Verify generated machine code' on function '@negated_cond_vop3_redef_cmp'
 #0 0x0000000005682ed3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/jayfoad2/llvm-release/bin/llc+0x5682ed3)
 #1 0x0000000005680bfe llvm::sys::RunSignalHandlers() (/home/jayfoad2/llvm-release/bin/llc+0x5680bfe)
 #2 0x000000000568325f SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fdcc0a92420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fdcc052500b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007fdcc0504859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00000000055e9b63 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/jayfoad2/llvm-release/bin/llc+0x55e9b63)
 #7 0x0000000004a1fdef (/home/jayfoad2/llvm-release/bin/llc+0x4a1fdef)
 #8 0x0000000004959c5e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/jayfoad2/llvm-release/bin/llc+0x4959c5e)
 #9 0x0000000004dd5b38 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/jayfoad2/llvm-release/bin/llc+0x4dd5b38)
#10 0x0000000004ddc378 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/jayfoad2/llvm-release/bin/llc+0x4ddc378)
#11 0x0000000004dd61e7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/jayfoad2/llvm-release/bin/llc+0x4dd61e7)
#12 0x000000000311d3de main (/home/jayfoad2/llvm-release/bin/llc+0x311d3de)
#13 0x00007fdcc0506083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#14 0x000000000311a96e _start (/home/jayfoad2/llvm-release/bin/llc+0x311a96e)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/jayfoad2/llvm-release/bin/FileCheck -check-prefix=GCN /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking-wave32.mir

--

********************
FAIL: LLVM :: CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir (2162 of 2843)
******************** TEST 'LLVM :: CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir' FAILED ********************
Script:
--
: 'RUN: at line 1';   /home/jayfoad2/llvm-release/bin/llc -march=amdgcn -verify-machineinstrs -run-pass=si-optimize-exec-masking-pre-ra -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir | /home/jayfoad2/llvm-release/bin/FileCheck -check-prefix=GCN /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir
--
Exit Code: 2

Command Output (stderr):
--
+ : 'RUN: at line 1'
+ /home/jayfoad2/llvm-release/bin/FileCheck -check-prefix=GCN /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir
+ /home/jayfoad2/llvm-release/bin/llc -march=amdgcn -verify-machineinstrs -run-pass=si-optimize-exec-masking-pre-ra -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir

# After SI optimize exec mask operations pre-RA
********** INTERVALS **********
VCC_LO_LO16 [80r,96r:0) 0@80r
VCC_LO_HI16 [80r,96r:0) 0@80r
VCC_HI_LO16 [80r,96r:0) 0@80r
VCC_HI_HI16 [80r,96r:0) 0@80r
%0 [16r,32r:0) 0@16r  weight:0.000000e+00
%1 [32r,32d:1)[48r,64r:0) 0@48r 1@32r  weight:0.000000e+00
%2 [64r,80r:0) 0@64r  weight:0.000000e+00
RegMasks:
********** MACHINEINSTRS **********
# Machine code for function negated_cond_vop3_redef_sel: NoPHIs

0B	bb.0:
	; predecessors: %bb.1
	  successors: %bb.2(0x40000000), %bb.1(0x40000000); %bb.2(50.00%), %bb.1(50.00%)

16B	  %0:sreg_64_xexec = IMPLICIT_DEF
32B	  dead %1:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %0:sreg_64_xexec, implicit $exec
48B	  %1:vgpr_32 = COPY $vgpr0
64B	  %2:sreg_64_xexec = V_CMP_NE_U32_e64 %1:vgpr_32, 1, implicit $exec
80B	  $vcc = S_AND_B64 %2:sreg_64_xexec, $exec, implicit-def dead $scc
96B	  S_CBRANCH_VCCNZ %bb.2, implicit $vcc
112B	  S_BRANCH %bb.1

128B	bb.1:
	; predecessors: %bb.0
	  successors: %bb.0(0x80000000); %bb.0(100.00%)

144B	  S_BRANCH %bb.0

160B	bb.2:
	; predecessors: %bb.0

176B	  S_ENDPGM 0

# End machine code for function negated_cond_vop3_redef_sel.

*** Bad machine code: Multiple connected components in live interval ***
- function:    negated_cond_vop3_redef_sel
- interval:    %1 [32r,32d:1)[48r,64r:0) 0@48r 1@32r  weight:0.000000e+00
0: valnos 0
1: valnos 1
LLVM ERROR: Found 1 machine code errors.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/jayfoad2/llvm-release/bin/llc -march=amdgcn -verify-machineinstrs -run-pass=si-optimize-exec-masking-pre-ra -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir
1.	Running pass 'Function Pass Manager' on module '/home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir'.
2.	Running pass 'Verify generated machine code' on function '@negated_cond_vop3_redef_sel'
 #0 0x0000000005682ed3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/jayfoad2/llvm-release/bin/llc+0x5682ed3)
 #1 0x0000000005680bfe llvm::sys::RunSignalHandlers() (/home/jayfoad2/llvm-release/bin/llc+0x5680bfe)
 #2 0x000000000568325f SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f34f324d420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f34f2ce000b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f34f2cbf859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00000000055e9b63 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/jayfoad2/llvm-release/bin/llc+0x55e9b63)
 #7 0x0000000004a1fdef (/home/jayfoad2/llvm-release/bin/llc+0x4a1fdef)
 #8 0x0000000004959c5e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/jayfoad2/llvm-release/bin/llc+0x4959c5e)
 #9 0x0000000004dd5b38 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/jayfoad2/llvm-release/bin/llc+0x4dd5b38)
#10 0x0000000004ddc378 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/jayfoad2/llvm-release/bin/llc+0x4ddc378)
#11 0x0000000004dd61e7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/jayfoad2/llvm-release/bin/llc+0x4dd61e7)
#12 0x000000000311d3de main (/home/jayfoad2/llvm-release/bin/llc+0x311d3de)
#13 0x00007f34f2cc1083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#14 0x000000000311a96e _start (/home/jayfoad2/llvm-release/bin/llc+0x311a96e)
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/jayfoad2/llvm-release/bin/FileCheck -check-prefix=GCN /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/AMDGPU/optimize-negated-cond-exec-masking.mir

--

********************
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to