Closed
Description
Description
The following code crashes aarch64 backend with SDAG.
However, it's interesting to note that it compiles successfully when using -global-isel on AArch64, or on x86_64 and ARM architectures.
Minimal Reproduction
https://godbolt.org/z/7WeaTdrhe
Code
define i32 @f(ptr %A, ptr %G3) {
BB:
%G2 = getelementptr i8, ptr %G3, i64 168
%0 = ptrtoint ptr %G2 to i64
%CastPtrToI2 = trunc i64 %0 to i1
store bfloat 0xR0000, ptr %G2, align 2
store i1 %CastPtrToI2, ptr %A, align 1
ret i32 0
}
Stack Trace
LLVM ERROR: Cannot select: 0x9687300: i64,ch = store<(store (s16) into %ir.G2), <pre-inc>> 0x9602f28, ConstantFP:bf16<APFloat(0)>, 0x96871b0, Constant:i64<168>
0x9687370: bf16 = ConstantFP<APFloat(0)>
0x96871b0: i64,ch = CopyFromReg 0x9602f28, Register:i64 %1
0x9687140: i64 = Register %1
0x9687220: i64 = Constant<168>
In function: f
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=aarch64 <source>
1. Running pass 'Function Pass Manager' on module '<source>'.
2. Running pass 'AArch64 Instruction Selection' on function '@f'
#0 0x0000000003749078 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x3749078)
#1 0x0000000003746a1c SignalHandler(int) Signals.cpp:0:0
#2 0x00007aa282042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007aa2820969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007aa282042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007aa2820287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000000000072d846 llvm::UniqueStringSaver::save(llvm::StringRef) (.cold) StringSaver.cpp:0:0
#7 0x000000000350c47c llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/llc+0x350c47c)
#8 0x00000000035138a5 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/llc+0x35138a5)
#9 0x0000000000ad925b (anonymous namespace)::AArch64DAGToDAGISel::Select(llvm::SDNode*) AArch64ISelDAGToDAG.cpp:0:0
#10 0x00000000035099e4 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/llc+0x35099e4)
#11 0x0000000003518bf1 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/llc+0x3518bf1)
#12 0x000000000351b649 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x351b649)
#13 0x000000000351d5b4 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x351d5b4)
#14 0x000000000350d291 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x350d291)
#15 0x000000000284919b llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#16 0x0000000002d83d22 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2d83d22)
#17 0x0000000002d83ea1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2d83ea1)
#18 0x0000000002d85b50 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/llc+0x2d85b50)
#19 0x000000000084a9c4 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#20 0x00000000007403c6 main (/opt/compiler-explorer/clang-trunk/bin/llc+0x7403c6)
#21 0x00007aa282029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#22 0x00007aa282029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#23 0x000000000084260e _start (/opt/compiler-explorer/clang-trunk/bin/llc+0x84260e)
Program terminated with signal: SIGSEGV
Compiler returned: 139