Files
clang-p2996/llvm/test/CodeGen/AVR/stdwstk.ll
Patryk Wychowaniec 6641c57aeb [AVR] Always expand STDSPQRr & STDWSPQRr
Currently, STDSPQRr and STDWSPQRr are expanded only during
AVRFrameLowering - this means that if any of those instructions happen
to appear _outside_ of the typical FrameSetup / FrameDestroy
context, they wouldn't get substituted, eventually leading to a crash:

```
LLVM ERROR: Not supported instr: <MCInst XXX <MCOperand Reg:1>
<MCOperand Imm:15> <MCOperand Reg:53>>
```

This commit fixes this issue by moving expansion of those two opcodes
into AVRExpandPseudo.

This bug was originally discovered due to the Rust compiler_builtins
library. Its 0.1.37 release contained a 128-bit software
division/remainder routine that exercised this buggy branch in the code.

Reviewed By: benshi001

Differential Revision: https://reviews.llvm.org/D123528
2022-05-05 03:10:59 +00:00

16 lines
462 B
LLVM

; RUN: llc < %s -march=avr -mcpu=atmega328 -O1 | FileCheck %s
; CHECK-NOT: stdwstk
; Checks that we expand STDWSPQRr always - even if it appears outside of the
; FrameSetup/FrameDestroy context.
declare { } @foo(i128, i128) addrspace(1)
define i128 @bar(i128 %a, i128 %b) addrspace(1) {
%b_neg = icmp slt i128 %b, 0
%divisor = select i1 %b_neg, i128 0, i128 %b
%result = tail call fastcc addrspace(1) { } @foo(i128 undef, i128 %divisor)
ret i128 0
}