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

[AArch64] Crash in call lowering for function taking vector of non-p2 integer type on big endian #103032

Closed
alexrp opened this issue Aug 13, 2024 · 8 comments · Fixed by #103310
Closed

Comments

@alexrp
Copy link
Member

alexrp commented Aug 13, 2024

target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64_be-unknown-linux-musl"

define fastcc void @foo(<4 x i6> %0) {
  ret void
}
llc -version
LLVM (http://llvm.org/):
  LLVM version 18.1.8llc -O0 reduced.ll
llc: /home/alexrp/Source/tests/llvm-project-18/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp:497: void buildCopyFromRegs(llvm::MachineIRBuilder&, llvm::ArrayRef<llvm::Register>, llvm::ArrayRef<llvm::Register>, llvm::LLT, llvm::LLT, llvm::ISD::ArgFlagsTy): Assertion `(SrcEltTy.getSizeInBits() % OriginalEltTy.getSizeInBits()) == 0' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc -O0 reduced.ll
1.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.      Running pass 'IRTranslator' on function '@foo'
 #0 0x00007e9ecc75d8e2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xd5d8e2)
 #1 0x00007e9ecc75a8ff llvm::sys::RunSignalHandlers() (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xd5a8ff)
 #2 0x00007e9ecc75aa45 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007e9ecb242990 (/lib/x86_64-linux-gnu/libc.so.6+0x42990)
 #4 0x00007e9ecb299a1b __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007e9ecb299a1b __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007e9ecb299a1b pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007e9ecb2428e6 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007e9ecb2268b7 abort ./stdlib/abort.c:81:7
 #9 0x00007e9ecb2267db _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007e9ecb239206 (/lib/x86_64-linux-gnu/libc.so.6+0x39206)
#11 0x00007e9ecd5e12a9 buildCopyFromRegs(llvm::MachineIRBuilder&, llvm::ArrayRef<llvm::Register>, llvm::ArrayRef<llvm::Register>, llvm::LLT, llvm::LLT, llvm::ISD::ArgFlagsTy) CallLowering.cpp:0:0
#12 0x00007e9ecd5e4ed7 llvm::CallLowering::handleAssignments(llvm::CallLowering::ValueHandler&, llvm::SmallVectorImpl<llvm::CallLowering::ArgInfo>&, llvm::CCState&, llvm::SmallVectorImpl<llvm::CCValAssign>&, llvm::MachineIRBuilder&, llvm::ArrayRef<llvm::Register>) const (/opt/llvm/bin/../lib/libLLVM.so.18.1+0x1be4ed7)
#13 0x00007e9ecf3ae0ba llvm::AArch64CallLowering::lowerFormalArguments(llvm::MachineIRBuilder&, llvm::Function const&, llvm::ArrayRef<llvm::ArrayRef<llvm::Register>>, llvm::FunctionLoweringInfo&) const (/opt/llvm/bin/../lib/libLLVM.so.18.1+0x39ae0ba)
#14 0x00007e9ecd64d8d5 llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0x1c4d8d5)
#15 0x00007e9eccd271f6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#16 0x00007e9ecc94f4d1 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xf4f4d1)
#17 0x00007e9ecc94f8e1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xf4f8e1)
#18 0x00007e9ecc950207 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xf50207)
#19 0x0000654acacfc896 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#20 0x0000654acacf1117 main (/opt/llvm/bin/llc+0x12117)
#21 0x00007e9ecb228150 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#22 0x00007e9ecb228209 call_init ./csu/../csu/libc-start.c:128:20
#23 0x00007e9ecb228209 __libc_start_main ./csu/../csu/libc-start.c:347:5
#24 0x0000654acacf1e15 _start (/opt/llvm/bin/llc+0x12e15)
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 13, 2024

@llvm/issue-subscribers-backend-aarch64

Author: Alex Rønne Petersen (alexrp)

```llvm target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "aarch64_be-unknown-linux-musl"

define fastcc void @foo(<4 x i6> %0) {
ret void
}


```console
❯ llc -version
LLVM (http://llvm.org/):
  LLVM version 18.1.8
❯ llc -O0 reduced.ll
llc: /home/alexrp/Source/tests/llvm-project-18/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp:497: void buildCopyFromRegs(llvm::MachineIRBuilder&amp;, llvm::ArrayRef&lt;llvm::Register&gt;, llvm::ArrayRef&lt;llvm::Register&gt;, llvm::LLT, llvm::LLT, llvm::ISD::ArgFlagsTy): Assertion `(SrcEltTy.getSizeInBits() % OriginalEltTy.getSizeInBits()) == 0' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc -O0 reduced.ll
1.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.      Running pass 'IRTranslator' on function '@<!-- -->foo'
 #<!-- -->0 0x00007e9ecc75d8e2 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xd5d8e2)
 #<!-- -->1 0x00007e9ecc75a8ff llvm::sys::RunSignalHandlers() (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xd5a8ff)
 #<!-- -->2 0x00007e9ecc75aa45 SignalHandler(int) Signals.cpp:0:0
 #<!-- -->3 0x00007e9ecb242990 (/lib/x86_64-linux-gnu/libc.so.6+0x42990)
 #<!-- -->4 0x00007e9ecb299a1b __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #<!-- -->5 0x00007e9ecb299a1b __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #<!-- -->6 0x00007e9ecb299a1b pthread_kill ./nptl/pthread_kill.c:89:10
 #<!-- -->7 0x00007e9ecb2428e6 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #<!-- -->8 0x00007e9ecb2268b7 abort ./stdlib/abort.c:81:7
 #<!-- -->9 0x00007e9ecb2267db _nl_load_domain ./intl/loadmsgcat.c:1177:9
#<!-- -->10 0x00007e9ecb239206 (/lib/x86_64-linux-gnu/libc.so.6+0x39206)
#<!-- -->11 0x00007e9ecd5e12a9 buildCopyFromRegs(llvm::MachineIRBuilder&amp;, llvm::ArrayRef&lt;llvm::Register&gt;, llvm::ArrayRef&lt;llvm::Register&gt;, llvm::LLT, llvm::LLT, llvm::ISD::ArgFlagsTy) CallLowering.cpp:0:0
#<!-- -->12 0x00007e9ecd5e4ed7 llvm::CallLowering::handleAssignments(llvm::CallLowering::ValueHandler&amp;, llvm::SmallVectorImpl&lt;llvm::CallLowering::ArgInfo&gt;&amp;, llvm::CCState&amp;, llvm::SmallVectorImpl&lt;llvm::CCValAssign&gt;&amp;, llvm::MachineIRBuilder&amp;, llvm::ArrayRef&lt;llvm::Register&gt;) const (/opt/llvm/bin/../lib/libLLVM.so.18.1+0x1be4ed7)
#<!-- -->13 0x00007e9ecf3ae0ba llvm::AArch64CallLowering::lowerFormalArguments(llvm::MachineIRBuilder&amp;, llvm::Function const&amp;, llvm::ArrayRef&lt;llvm::ArrayRef&lt;llvm::Register&gt;&gt;, llvm::FunctionLoweringInfo&amp;) const (/opt/llvm/bin/../lib/libLLVM.so.18.1+0x39ae0ba)
#<!-- -->14 0x00007e9ecd64d8d5 llvm::IRTranslator::runOnMachineFunction(llvm::MachineFunction&amp;) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0x1c4d8d5)
#<!-- -->15 0x00007e9eccd271f6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&amp;) (.part.0) MachineFunctionPass.cpp:0:0
#<!-- -->16 0x00007e9ecc94f4d1 llvm::FPPassManager::runOnFunction(llvm::Function&amp;) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xf4f4d1)
#<!-- -->17 0x00007e9ecc94f8e1 llvm::FPPassManager::runOnModule(llvm::Module&amp;) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xf4f8e1)
#<!-- -->18 0x00007e9ecc950207 llvm::legacy::PassManagerImpl::run(llvm::Module&amp;) (/opt/llvm/bin/../lib/libLLVM.so.18.1+0xf50207)
#<!-- -->19 0x0000654acacfc896 compileModule(char**, llvm::LLVMContext&amp;) llc.cpp:0:0
#<!-- -->20 0x0000654acacf1117 main (/opt/llvm/bin/llc+0x12117)
#<!-- -->21 0x00007e9ecb228150 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#<!-- -->22 0x00007e9ecb228209 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->23 0x00007e9ecb228209 __libc_start_main ./csu/../csu/libc-start.c:347:5
#<!-- -->24 0x0000654acacf1e15 _start (/opt/llvm/bin/llc+0x12e15)

@tschuett
Copy link
Member

BE is not supported for AArch64 and GlobalIsel, Please use little endian.

@davemgreen
Copy link
Collaborator

We should be falling back to SDAG before we get to the point of crashing. We already fall back, but it continues on getting as far as loweringArguments. #103310 will make sure we bail out earlier and is one fix until the crashes are fixed.

@tschuett
Copy link
Member

Yourare not running the current toolchain. The repo has no assert at:
CodeGen/GlobalISel/CallLowering.cpp:497

@tschuett
Copy link
Member

I tried your example with a current toolchain:

Assertion failed: ((SrcEltTy.getSizeInBits() % OriginalEltTy.getSizeInBits()) == 0), function buildCopyFromRegs, file CallLowering.cpp, line 529.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: bin/llc -O0 reduced.ll
1.	Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.	Running pass 'IRTranslator' on function '@foo'

The assert is indeed in upstream:

assert((SrcEltTy.getSizeInBits() % OriginalEltTy.getSizeInBits()) == 0);

Maybe BE was just a teaser and the real issue is the odd parameter.

@alexrp
Copy link
Member Author

alexrp commented Aug 13, 2024

I definitely can't speak to the internals of GlobalISel, but fwiw, the repro above works fine if you change it to LE (E -> e, aarch64_be -> aarch64).

davemgreen added a commit that referenced this issue Aug 19, 2024
If we continue through the function we can currently hit crashes. We can
bail out early and fall back to SDAG.

Fixes #103032
@davemgreen davemgreen added this to the LLVM 19.X Release milestone Aug 19, 2024
@davemgreen davemgreen reopened this Aug 19, 2024
@davemgreen
Copy link
Collaborator

/cherry-pick 05d17a1

llvmbot pushed a commit to llvmbot/llvm-project that referenced this issue Aug 19, 2024
If we continue through the function we can currently hit crashes. We can
bail out early and fall back to SDAG.

Fixes llvm#103032

(cherry picked from commit 05d17a1)
@llvmbot llvmbot closed this as completed Aug 19, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 19, 2024

/pull-request #104823

tru pushed a commit to llvmbot/llvm-project that referenced this issue Aug 20, 2024
If we continue through the function we can currently hit crashes. We can
bail out early and fall back to SDAG.

Fixes llvm#103032

(cherry picked from commit 05d17a1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

6 participants