| Issue |
124092
|
| Summary |
Crash when compiling variadic functions for PTX
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
TheNewJavaman
|
I am performing research involving running simpled embedded arm binaries on cuda.
Here is my current minimal workflow:
- Compile a sample aarch64 binary with statically linked musl libc
- Lift aarch64 to LLVM IR using [remill](https://github.com/lifting-bits/remill)
- Retarget LLVM IR to PTX using llc
The crash occurs in the last step with llc. Interestingly, this crash goes away when I dynamically link glibc instead of musl; maybe something in musl isn't correctly lifted by remill or compiled by llc. Either way, it's unexpected for llc to crash the way it did.
Please let me know how I can improve this report. Reproduce it by downloading `libsample.ll` (may be named `libsample.txt` from the GitHub upload) and running: `llc -march=nvptx64 -mcpu=sm_60 -o libsample.ptx libsample.ll`
<details>
<summary>sample.c</summary>
```c
int sample_div_zero(int num, int denom) {
return num / denom;
}
```
</details>
[libsample.ll](https://github.com/user-attachments/files/18518168/libsample.txt)
<details>
<summary>Crash backtrace</summary>
```
$ llc -march=nvptx64 -mcpu=sm_60 -o workspace/libsample.ptx workspace/libsample.ll
LLVM ERROR: Support for variadic functions (unsized array parameter) introduced in PTX ISA version 6.0 and requires target sm_30.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llc -march=nvptx64 -mcpu=sm_60 -o workspace/libsample.ptx workspace/libsample.ll
1. Running pass 'Function Pass Manager' on module 'workspace/libsample.ll'.
2. Running pass 'NVPTX DAG->DAG Pattern Instruction Selection' on function '@deregister_tm_clones_3'
#0 0x000072f9944ad12f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Unix/Signals.inc:723:13
#1 0x000072f9944aae39 llvm::sys::RunSignalHandlers() build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Signals.cpp:106:18
#2 0x000072f9944ad880 SignalHandler build-llvm/tools/clang/stage2-bins/llvm/lib/Support/Unix/Signals.inc:413:1
#3 0x000072f992e45250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250)
#4 0x000072f992ea3f1c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x000072f992ea3f1c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x000072f992ea3f1c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x000072f992e4519e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x000072f992e28902 abort ./stdlib/abort.c:81:7
#9 0x000072f994402fd4 llvm::report_fatal_error(llvm::Twine const&, bool) build-llvm/tools/clang/stage2-bins/llvm/lib/Support/ErrorHandling.cpp:125:5
#10 0x000072f994402e0d (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.1+0xe02e0d)
#11 0x000072f996f5c4df LowerCall build-llvm/tools/clang/stage2-bins/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp:0:0
#12 0x000072f994ce8bbe llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:0:15
#13 0x000072f994d052e7 getNode build-llvm/tools/clang/stage2-bins/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:159:36
#14 0x000072f994d052e7 llvm::SelectionDAGBuilder::lowerInvokable(llvm::TargetLowering::CallLoweringInfo&, llvm::BasicBlock const*) build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:8691:22
#15 0x000072f994cefd64 getNode build-llvm/tools/clang/stage2-bins/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:159:36
#16 0x000072f994cefd64 llvm::SelectionDAGBuilder::LowerCallTo(llvm::CallBase const&, llvm::SDValue, bool, bool, llvm::BasicBlock const*, llvm::TargetLowering::PtrAuthInfo const*) build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:8833:20
#17 0x000072f994cdc951 llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:0:5
#18 0x000072f994cd2970 getValueID build-llvm/tools/clang/stage2-bins/llvm/include/llvm/IR/Value.h:533:12
#19 0x000072f994cd2970 getOpcode build-llvm/tools/clang/stage2-bins/llvm/include/llvm/IR/Instruction.h:274:39
#20 0x000072f994cd2970 isTerminator build-llvm/tools/clang/stage2-bins/llvm/include/llvm/IR/Instruction.h:277:51
#21 0x000072f994cd2970 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:1348:10
#22 0x000072f994d6e4a9 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true, llvm::BasicBlock>, false, true>, bool&) build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:0:12
#23 0x000072f994d6d7f3 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1624:8
#24 0x000072f994d6bf9c llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:0:3
#25 0x000072f994d6a9d2 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:374:20
#26 0x000072f9948a7dc9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) build-llvm/tools/clang/stage2-bins/llvm/lib/CodeGen/MachineFunctionPass.cpp:94:13
#27 0x000072f994605e12 llvm::FPPassManager::runOnFunction(llvm::Function&) build-llvm/tools/clang/stage2-bins/llvm/lib/IR/LegacyPassManager.cpp:1440:27
#28 0x000072f99460ba84 llvm::FPPassManager::runOnModule(llvm::Module&) build-llvm/tools/clang/stage2-bins/llvm/lib/IR/LegacyPassManager.cpp:1486:13
#29 0x000072f9946065bf runOnModule build-llvm/tools/clang/stage2-bins/llvm/lib/IR/LegacyPassManager.cpp:0:27
#30 0x000072f9946065bf llvm::legacy::PassManagerImpl::run(llvm::Module&) build-llvm/tools/clang/stage2-bins/llvm/lib/IR/LegacyPassManager.cpp:541:44
#31 0x00005e058a468b82 compileModule build-llvm/tools/clang/stage2-bins/llvm/tools/llc/llc.cpp:0:8
#32 0x00005e058a46667f main build-llvm/tools/clang/stage2-bins/llvm/tools/llc/llc.cpp:409:13
#33 0x000072f992e2a3b8 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#34 0x000072f992e2a47b call_init ./csu/../csu/libc-start.c:128:20
#35 0x000072f992e2a47b __libc_start_main ./csu/../csu/libc-start.c:347:5
#36 0x00005e058a462e45 _start (/usr/lib/llvm-19/bin/llc+0x11e45)
Aborted (core dumped)
```
</details>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs