Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HexagonExpandCondsets does not preserve LiveIntervals #56050

Closed
jayfoad opened this issue Jun 15, 2022 · 3 comments
Closed

HexagonExpandCondsets does not preserve LiveIntervals #56050

jayfoad opened this issue Jun 15, 2022 · 3 comments

Comments

@jayfoad
Copy link
Contributor

jayfoad commented Jun 15, 2022

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 see a couple of Hexagon CodeGen tests failing with Bad machine code: Multiple connected components in live interval:

FAIL: LLVM :: CodeGen/Hexagon/expand-condsets-same-inputs.mir (1247 of 1248)
******************** TEST 'LLVM :: CodeGen/Hexagon/expand-condsets-same-inputs.mir' FAILED ********************
Script:
--
: 'RUN: at line 1';   /home/jayfoad2/llvm-release/bin/llc -march=hexagon -run-pass expand-condsets -expand-condsets-coa-limit=0 -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-same-inputs.mir -verify-machineinstrs | /home/jayfoad2/llvm-release/bin/FileCheck /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-same-inputs.mir
--
Exit Code: 2

Command Output (stderr):
--
+ : 'RUN: at line 1'
+ /home/jayfoad2/llvm-release/bin/llc -march=hexagon -run-pass expand-condsets -expand-condsets-coa-limit=0 -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-same-inputs.mir -verify-machineinstrs
+ /home/jayfoad2/llvm-release/bin/FileCheck /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-same-inputs.mir

# After Hexagon Expand Condsets
********** INTERVALS **********
R0 [0B,0d:0)[96r,96d:1) 0@0B-phi 1@96r
R1 [0B,48r:0) 0@0B-phi
R2 [0B,0d:0) 0@0B-phi
P0~P3_0 [0B,0d:0) 0@0B-phi
%0 [16r,16d:1)[32r,32d:0) 0@32r 1@16r  weight:0.000000e+00
%1 [48r,64r:0) 0@48r  weight:0.000000e+00
%2 [64r,80r:0) 0@64r  weight:0.000000e+00
%3 [80r,96r:0) 0@80r  weight:0.000000e+00
RegMasks:
********** MACHINEINSTRS **********
# Machine code for function fred: NoPHIs, TracksLiveness

0B	bb.0:
	  liveins: $r0, $r1, $r2, $p0
16B	  dead %0:predregs = COPY $p0
32B	  dead %0:predregs = COPY $p0
48B	  %1:intregs = COPY $r1
64B	  %2:intregs = A2_addi %1:intregs, 1
80B	  %3:intregs = COPY killed %2:intregs
96B	  $r0 = COPY killed %3:intregs

# End machine code for function fred.

*** Bad machine code: Multiple connected components in live interval ***
- function:    fred
- interval:    %0 [16r,16d:1)[32r,32d:0) 0@32r 1@16r  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=hexagon -run-pass expand-condsets -expand-condsets-coa-limit=0 -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-same-inputs.mir -verify-machineinstrs
1.	Running pass 'Function Pass Manager' on module '/home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-same-inputs.mir'.
2.	Running pass 'Verify generated machine code' on function '@fred'
 #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 0x00007fa744fd9420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fa744a6c00b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007fa744a4b859 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 0x00007fa744a4d083 __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 /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-same-inputs.mir

--

********************
FAIL: LLVM :: CodeGen/Hexagon/expand-condsets-def-undef.mir (1248 of 1248)
******************** TEST 'LLVM :: CodeGen/Hexagon/expand-condsets-def-undef.mir' FAILED ********************
Script:
--
: 'RUN: at line 1';   /home/jayfoad2/llvm-release/bin/llc -march=hexagon -run-pass expand-condsets -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-def-undef.mir -verify-machineinstrs | /home/jayfoad2/llvm-release/bin/FileCheck /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-def-undef.mir
--
Exit Code: 2

Command Output (stderr):
--
+ : 'RUN: at line 1'
+ /home/jayfoad2/llvm-release/bin/llc -march=hexagon -run-pass expand-condsets -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-def-undef.mir -verify-machineinstrs
+ /home/jayfoad2/llvm-release/bin/FileCheck /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-def-undef.mir

# After Hexagon Expand Condsets
********** INTERVALS **********
R0 [0B,48r:0) 0@0B-phi
R1 [0B,48r:0) 0@0B-phi
P0~P3_0 [0B,0d:0) 0@0B-phi
%0 [16r,88r:0) 0@16r  weight:0.000000e+00
%1 [32r,76r:0) 0@32r  weight:0.000000e+00
%2 [48r,64r:1)[76r,84r:0)[84r,88r:3)[88r,88d:2) 0@76r 1@48r 2@88r 3@84r  L0000000000000002 [48r,48d:1)[76r,76d:0) 0@76r 1@48r  L0000000000000001 [48r,64r:2)[84r,88r:1)[88r,88d:0) 0@88r 1@84r 2@48r  weight:0.000000e+00
%3 [64r,84r:0) 0@64r  weight:0.000000e+00
RegMasks:
********** MACHINEINSTRS **********
# Machine code for function fred: NoPHIs, TracksLiveness
Function Live Ins: $p0 in %0, $r0 in %1, $d0 in %2

0B	bb.0:
	  liveins: $r0, $d0, $p0
16B	  %0:predregs = COPY $p0
32B	  %1:intregs = COPY $r0
48B	  %2:doubleregs = COPY $d0
64B	  %3:intregs = A2_addi %2.isub_hi:doubleregs, 1
76B	  dead undef %2.isub_lo:doubleregs = A2_tfrf %0:predregs, killed %1:intregs
84B	  %2.isub_hi:doubleregs = A2_tfrt %0:predregs, killed %3:intregs
88B	  dead %2.isub_hi:doubleregs = C2_cmoveif killed %0:predregs, 0, implicit %2.isub_hi:doubleregs(tied-def 0)

# End machine code for function fred.

*** Bad machine code: Multiple connected components in live interval ***
- function:    fred
- interval:    %2 [48r,64r:1)[76r,84r:0)[84r,88r:3)[88r,88d:2) 0@76r 1@48r 2@88r 3@84r  L0000000000000002 [48r,48d:1)[76r,76d:0) 0@76r 1@48r  L0000000000000001 [48r,64r:2)[84r,88r:1)[88r,88d:0) 0@88r 1@84r 2@48r  weight:0.000000e+00
0: valnos 0 2 3
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=hexagon -run-pass expand-condsets -o - /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-def-undef.mir -verify-machineinstrs
1.	Running pass 'Function Pass Manager' on module '/home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-def-undef.mir'.
2.	Running pass 'Verify generated machine code' on function '@fred'
 #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 0x00007f0e95827420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f0e952ba00b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f0e95299859 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 0x00007f0e9529b083 __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 /home/jayfoad2/git/llvm-project/llvm/test/CodeGen/Hexagon/expand-condsets-def-undef.mir

--

********************
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 15, 2022

@llvm/issue-subscribers-backend-hexagon

@jayfoad
Copy link
Contributor Author

jayfoad commented Jul 26, 2022

See https://reviews.llvm.org/D127731 WIP: [MachineVerifier] Try harder to verify analyses

Superseded by https://reviews.llvm.org/D129208 [MachineVerifier] Try harder to verify LiveIntervals

@jayfoad
Copy link
Contributor Author

jayfoad commented Aug 19, 2022

Works for me, thanks!

thilinarmtb pushed a commit to nomp-org/llvm-project that referenced this issue Aug 24, 2022
dfukalov added a commit that referenced this issue Sep 2, 2022
Each dead def of the same virtual register is required to be split into multiple
virtual registers with separate live intervals to avoid MachineVerifier error.

Partially fixes #56050 and
#56051

Reviewed By: qcolombet

Differential Revision: https://reviews.llvm.org/D130477
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants