| Issue |
179991
|
| Summary |
[AVR] Assembly backend crashing
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
sourcery-zone
|
## Description
The AVR backend crashes with a segmentation fault when compiling a function in `addrspace(1)` calls `@llvm.returnaddress(i32 0)`. I'm not knowledgeable about LLVM, but given the situation I experienced from my source program in Zig (details reported on [Zig issue tracker](https://codeberg.org/ziglang/zig/issues/31127)), I guess data type of other numeric values suffer the same issue.
## Minimal Reproduction
`reduced.ll`:
```llvm
; ModuleID = 'reduced.bc'
target datalayout = "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8"
target triple = "avr-unknown-unknown-unknown"
define fastcc ptr @"debug.FullPanic((function 'defaultPanic')).integerOutOfBounds"() addrspace(1) {
Entry:
%0 = call addrspace(0) ptr @llvm.returnaddress(i32 0)
ret ptr %0
}
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare ptr @llvm.returnaddress(i32 immarg) addrspace(0) #0
attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
```
Command:
```sh
llc reduced.ll -mtriple=avr -mcpu=atmega2560 -o test.s
```
## Actual Behavior
```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llc reduced.ll -mtriple=avr -mcpu=atmega2560 -o test.s
1. Running pass 'Function Pass Manager' on module 'reduced.ll'.
2. Running pass 'AVR Assembly Printer' on function '@"debug.FullPanic((function 'defaultPanic')).integerOutOfBounds"'
#0 0x00007fd1e2341b2b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/nix/store/swch85kls1srlrji1i0g28wpa4y607hk-llvm-21.1.2-lib/lib/libLLVM.so.21.1+0xd41b2b)
#1 0x00007fd1e233e9ba SignalHandler(int, siginfo_t*, void*) (/nix/store/swch85kls1srlrji1i0g28wpa4y607hk-llvm-21.1.2-lib/lib/libLLVM.so.21.1+0xd3e9ba)
#2 0x00007fd1e0e419c0 __restore_rt (/nix/store/xx7cm72qy2c0643cm1ipngd87aqwkcdp-glibc-2.40-66/lib/libc.so.6+0x419c0)
#3 0x00007fd1e3167edb llvm::AsmPrinter::GetBlockAddressSymbol(llvm::BlockAddress const*) const (/nix/store/swch85kls1srlrji1i0g28wpa4y607hk-llvm-21.1.2-lib/lib/libLLVM.so.21.1+0x1b67edb)
#4 0x00007fd1e61b8b84 llvm::AVRMCInstLower::lowerInstruction(llvm::MachineInstr const&, llvm::MCInst&) const (/nix/store/swch85kls1srlrji1i0g28wpa4y607hk-llvm-21.1.2-lib/lib/libLLVM.so.21.1+0x4bb8b84)
#5 0x00007fd1e6190e5c (anonymous namespace)::AVRAsmPrinter::emitInstruction(llvm::MachineInstr const*) (/nix/store/swch85kls1srlrji1i0g28wpa4y607hk-llvm-21.1.2-lib/lib/libLLVM.so.21.1+0x4b90e5c)
...
```
## Expected Behavior
Successful compilation to AVR assembly.
- LLVM version: 21.1.2 (also reproduces on LLVM 20.1)
- OS: Linux
## Extra Context
This I faced with when compiling my Zig code targeting AVR in Debug mode. Full information from Zig point of view is listed [here](https://codeberg.org/ziglang/zig/issues/31127). The short term workaround to avoid this issue, was to use optimization for release, or use wrapped arithmetic operations.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs