llvm-project
llvm-project copied to clipboard
[AVR] llc aborts with "Attempting to emit STDPtrQRr" on AVRTiny cores
On AVRTiny cores, llc aborts in the AsmPrinter when a function spills an 8-bit value, or when a function without a frame pointer (or with a variable-sized alloca) passes a byte on the stack:
LLVM ERROR: Attempting to emit STDPtrQRr instruction but the Feature_HasNonTinyEncoding predicate(s) are not met
Every register allocator is affected, including the default one, and at -O0 a function with a single branch is enough.
Reproducers
declare void @foo()
declare void @bar(i8, i8, i8)
; Three bytes are live across the call, so one is spilled.
define void @spill(i8 %a, i8 %b, i8 %c) {
call void @foo()
call void @bar(i8 %a, i8 %b, i8 %c)
ret void
}
declare void @baz(i32, i16, i8)
; The i8 is passed on the stack.
define void @stack_arg(i8 %x) {
call void @baz(i32 0, i16 0, i8 %x)
ret void
}
llc -mtriple=avr -mcpu=attiny10 repro.ll -o /dev/null
Both fail at -O0 and -O2. llvm/test/CodeGen/AVR/cmp.ll also fails with -mcpu=attiny10 -regalloc=fast.
Notes
- Affected:
attiny4,attiny5,attiny9,attiny10,attiny20,attiny40,attiny102,attiny104and-mcpu=avrtiny. Cores with the full instruction set (e.g.atmega328p,avr2) are fine. - Builds without assertions do not abort; they silently emit
std/ldd(e.g.std Z+1, r24), which these cores do not support. attiny11fails differently (PUSHRr,Feature_HasSRAM); that is a separate issue.- Not a duplicate of #181504.
Reproduced on main at a39dccbd33e3.
Proposed patch: https://github.com/llvm/llvm-project/pull/234944
For devices without SRAM, avr-gcc only support assembly programming, so it is OK that llc also fails.