Open cesaref opened 2 years ago
Confirmed on x86_64 with this week top of trunk and the stack trace below (different from the reporter's) :
$ llc llvm-pr53164.ll
llc: /src/llvm/llvm/lib/IR/Type.cpp:313: static llvm::IntegerType* llvm::IntegerType::get(llvm::LLVMContext&, unsigned int): Assertion `NumBits <= MAX_INT_BITS && "bitwidth too large"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /build/llvm-gcc/bin/llc llvm-pr53164.ll
1. Running pass 'Function Pass Manager' on module 'llvm-pr53164.ll'.
2. Running pass 'CodeGen Prepare' on function '@tests__bigStack1'
#0 0x00007ffacccb4e07 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /src/llvm/llvm/lib/Support/Unix/Signals.inc:569:22
#1 0x00007ffacccb4eca PrintStackTraceSignalHandler(void*) /src/llvm/llvm/lib/Support/Unix/Signals.inc:636:1
#2 0x00007ffacccb2d93 llvm::sys::RunSignalHandlers() /src/llvm/llvm/lib/Support/Signals.cpp:103:20
#3 0x00007ffacccb4818 SignalHandler(int) /src/llvm/llvm/lib/Support/Unix/Signals.inc:407:1
#4 0x00007ffac568f750 __restore_rt (/lib64/libc.so.6+0x42750)
#5 0x00007ffac56dc84c __pthread_kill_implementation (/lib64/libc.so.6+0x8f84c)
#6 0x00007ffac568f6a6 gsignal (/lib64/libc.so.6+0x426a6)
#7 0x00007ffac56797d3 abort (/lib64/libc.so.6+0x2c7d3)
#8 0x00007ffac56796fb _nl_load_domain.cold (/lib64/libc.so.6+0x2c6fb)
#9 0x00007ffac5688396 (/lib64/libc.so.6+0x3b396)
#10 0x00007ffaccfffc81 llvm::IntegerType::get(llvm::LLVMContext&, unsigned int) /src/llvm/llvm/lib/IR/Type.cpp:316:3
#11 0x00007ffaccfff954 llvm::Type::getIntNTy(llvm::LLVMContext&, unsigned int) /src/llvm/llvm/lib/IR/Type.cpp:245:1
#12 0x00007ffacd16d551 splitMergedValStore(llvm::StoreInst&, llvm::DataLayout const&, llvm::TargetLowering const&) /src/llvm/llvm/lib/CodeGen/CodeGenPrepare.cpp:7585:73
#13 0x00007ffacd16f330 (anonymous namespace)::CodeGenPrepare::optimizeInst(llvm::Instruction*, bool&) /src/llvm/llvm/lib/CodeGen/CodeGenPrepare.cpp:7958:5
#14 0x00007ffacd16fde0 (anonymous namespace)::CodeGenPrepare::optimizeBlock(llvm::BasicBlock&, bool&) /src/llvm/llvm/lib/CodeGen/CodeGenPrepare.cpp:8092:16
#15 0x00007ffacd151800 (anonymous namespace)::CodeGenPrepare::runOnFunction(llvm::Function&) /src/llvm/llvm/lib/CodeGen/CodeGenPrepare.cpp:555:18
#16 0x00007ffaccf4211b llvm::FPPassManager::runOnFunction(llvm::Function&) /src/llvm/llvm/lib/IR/LegacyPassManager.cpp:1430:20
#17 0x00007ffaccf4238b llvm::FPPassManager::runOnModule(llvm::Module&) /src/llvm/llvm/lib/IR/LegacyPassManager.cpp:1476:13
#18 0x00007ffaccf427b2 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /src/llvm/llvm/lib/IR/LegacyPassManager.cpp:1545:20
#19 0x00007ffaccf3db8e llvm::legacy::PassManagerImpl::run(llvm::Module&) /src/llvm/llvm/lib/IR/LegacyPassManager.cpp:535:13
#20 0x00007ffaccf42fd7 llvm::legacy::PassManager::run(llvm::Module&) /src/llvm/llvm/lib/IR/LegacyPassManager.cpp:1673:1
#21 0x00000000002257d8 compileModule(char**, llvm::LLVMContext&) /src/llvm/llvm/tools/llc/llc.cpp:737:66
#22 0x00000000002233c4 main /src/llvm/llvm/tools/llc/llc.cpp:418:35
#23 0x00007ffac567a560 __libc_start_call_main (/lib64/libc.so.6+0x2d560)
#24 0x00007ffac567a60c __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x2d60c)
#25 0x0000000000222145 _start (/build/llvm-gcc/bin/llc+0x222145)
Aborted (core dumped)
If we alloca a large array and zero initialise it, we trigger an llc assertion. This fails on arm64 and x64, not sure about other targets. In addition, if we repeat with smaller arrays (say, 10,000 elements) the code generator produces a large number of stores which is slow to optimise.