llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
26.75k stars 10.96k forks source link

Endless loop in AArch64 Legalizer #72154

Open tschuett opened 7 months ago

tschuett commented 7 months ago

https://discourse.llvm.org/t/aarch64-calling-convention-for-small-vectors/74880

bar.ll:

define <2 x i3> @vector_add_2_3(<2 x i3> %a, <2 x i3> %b) {
    %c = add <2 x i3> %a, %b
    ret <2 x i3> %c
}
bin/llc --march=aarch64  -O0 --global-isel -stop-after=irtranslator bar.ll -o -
bin/llc --march=aarch64  -O0 --global-isel -stop-after=legalizer bar.ll -o -
regehr commented 7 months ago

just a note that the hanging behavior is observed for llc 17, for top of tree just now I get an assertion violation:

regehr@john-home:~/tmp$ ~/llvm-project/for-alive/bin/llc --march=aarch64  -O0 --global-isel -stop-after=legalizer test_2_3.aarch64.ll -o -
llc: /home/regehr/llvm-project/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp:245: llvm::MachineInstrBuilder llvm::MachineIRBuilder::buildPadVectorWithUndefElements(const llvm::DstOp&, const llvm::SrcOp&): Assertion `(ResTy.getElementType() == Op0Ty.getElementType()) && "Different vector element types"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.  Program arguments: /home/regehr/llvm-project/for-alive/bin/llc --march=aarch64 -O0 --global-isel -stop-after=legalizer test_2_3.aarch64.ll -o -
1.  Running pass 'Function Pass Manager' on module 'test_2_3.aarch64.ll'.
2.  Running pass 'IRTranslator' on function '@vector_add_2_3'
 #0 0x00007f45573fe8e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSupport.so.18git+0x1fe8e0)
 #1 0x00007f45573fb8ef llvm::sys::RunSignalHandlers() (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMSupport.so.18git+0x1fb8ef)
 #2 0x00007f45573fba45 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f4556a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f4556a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f4556a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f4556a969fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f4556a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f4556a287f3 abort ./stdlib/abort.c:81:7
 #9 0x00007f4556a2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007f4556a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007f455697ae1f llvm::MachineIRBuilder::buildPadVectorWithUndefElements(llvm::DstOp const&, llvm::SrcOp const&) (/home/regehr/llvm-project/for-alive/bin/../lib/../lib/libLLVMGlobalISel.so.18git+0x154e1f)
#12 0x00007f455f4bdf4b llvm::AArch64CallLowering::lowerReturn(llvm::MachineIRBuilder&, llvm::Value const*, llvm::ArrayRef<llvm::Register>, llvm::FunctionLoweringInfo&, llvm::Register) const (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMAArch64CodeGen.so.18git+0xbdf4b)
#13 0x00007f45568e598f llvm::IRTranslator::translateRet(llvm::User const&, llvm::MachineIRBuilder&) (/home/regehr/llvm-project/for-alive/bin/../lib/../lib/libLLVMGlobalISel.so.18git+0xbf98f)
#14 0x00007f45568f621a llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&) (/home/regehr/llvm-project/for-alive/bin/../lib/../lib/libLLVMGlobalISel.so.18git+0xd021a)
#15 0x00007f455940c642 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMCodeGen.so.18git+0x40c642)
#16 0x00007f45578d5de6 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMCore.so.18git+0x2d5de6)
#17 0x00007f45578d6029 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMCore.so.18git+0x2d6029)
#18 0x00007f45578d68c2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/regehr/llvm-project/for-alive/bin/../lib/libLLVMCore.so.18git+0x2d68c2)
#19 0x00005643a39a8a91 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#20 0x00005643a399d2e4 main (/home/regehr/llvm-project/for-alive/bin/llc+0x132e4)
#21 0x00007f4556a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#22 0x00007f4556a29e40 call_init ./csu/../csu/libc-start.c:128:20
#23 0x00007f4556a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#24 0x00005643a399d7f5 _start (/home/regehr/llvm-project/for-alive/bin/llc+0x137f5)
Aborted (core dumped)
regehr@john-home:~/tmp$ 
tschuett commented 7 months ago

There is an issue in AArch64CallLowering::lowerReturn.

llvmbot commented 4 months ago

@llvm/issue-subscribers-backend-aarch64

Author: Thorsten Schütt (tschuett)

https://discourse.llvm.org/t/aarch64-calling-convention-for-small-vectors/74880 bar.ll: ``` define <2 x i3> @vector_add_2_3(<2 x i3> %a, <2 x i3> %b) { %c = add <2 x i3> %a, %b ret <2 x i3> %c } ``` ``` bin/llc --march=aarch64 -O0 --global-isel -stop-after=irtranslator bar.ll -o - bin/llc --march=aarch64 -O0 --global-isel -stop-after=legalizer bar.ll -o - ```