[AVR] Always expand STDSPQRr & STDWSPQRr
authorPatryk Wychowaniec <pwychowaniec@pm.me>
Thu, 5 May 2022 03:07:41 +0000 (03:07 +0000)
committerBen Shi <ben.shi@streamcomputing.com>
Thu, 5 May 2022 03:10:59 +0000 (03:10 +0000)
commit6641c57aebc688b365587b990bb206c7f2e43c19
tree2c8c4bf46245dbbb3f1f9687dadfb88ea1304ceb
parent8bb10436ab9383cb226153128cac9329db29e2d5
[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
llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
llvm/lib/Target/AVR/AVRFrameLowering.cpp
llvm/test/CodeGen/AVR/stdwstk.ll [new file with mode: 0644]