llvm / llvm/llvm-project

[AArch64] crashes when converting long double to __bf16 on AArch64

Open
#172,400 7 comments 0 reactions 0 assignees View on GitHub
backend:AArch64 crash
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Reproducer:
https://godbolt.org/z/no5fv4zK9

Backtrace:
```console
llc: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:985: void {anonymous}::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*): Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -x86-asm-syntax=intel
1. Running pass 'Function Pass Manager' on module ''.
2. Running pass 'AArch64 Instruction Selection' on function '@tf_to_bf'
#0 0x000000000421fb68 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x421fb68)
#1 0x000000000421ca14 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#2 0x00007714a4042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007714a40969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007714a4042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007714a40287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x00007714a402871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x00007714a4039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x0000000003e93a17 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) (.part.0) LegalizeDAG.cpp:0:0
#9 0x0000000003e95e1e llvm::SelectionDAG::Legalize() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3e95e1e)
#10 0x0000000003fb6262 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3fb6262)
#11 0x0000000003fb95b8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3fb95b8)
#12 0x0000000003fbb03c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3fbb03c)
#13 0x0000000003fa683f llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3fa683f)
#14 0x00000000030f5fd9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000003750ab6 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3750ab6)
#16 0x0000000003750e61 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3750e61)
#17 0x00000000037516cf llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37516cf)
#18 0x00000000008fe384 compileModule(char**, llvm::LLVMContext&, std::__cxx11::basic_string, std::allocator>&) llc.cpp:0:0
#19 0x00000000007c88f9 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x7c88f9)
#20 0x00007714a4029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007714a4029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x00000000008f3585 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x8f3585)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```

This comes from the following C reproducer:
```c
extern __bf16 bf;
extern long double tf;

void tf_to_bf () { bf = tf; }
```

Contributor guide

Open the contributing guide

Research direction

Start with the Compiler Explorer C reproducer and run llc through the AArch64 Instruction Selection pass. Inspect SelectionDAGLegalize::LegalizeOp around llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:985, focusing on the illegal type reached by the long-double to __bf16 conversion. Done means the reproducer no longer triggers the assertion or crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.