[all-commits] [llvm/llvm-project] d6a48a: [RISCV] Fix the CFI offset for callee-saved regist...
Jim Lin via All-commits
all-commits at lists.llvm.org
Tue Aug 1 22:09:35 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d6a48a348ad0096e1e97dadaa6dcbeaf49db718b
https://github.com/llvm/llvm-project/commit/d6a48a348ad0096e1e97dadaa6dcbeaf49db718b
Author: Jim Lin <jim at andestech.com>
Date: 2023-08-02 (Wed, 02 Aug 2023)
Changed paths:
M llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
M llvm/test/CodeGen/RISCV/push-pop-popret.ll
Log Message:
-----------
[RISCV] Fix the CFI offset for callee-saved registers stored by Zcmp push.
Issue mentioned: https://github.com/riscv/riscv-code-size-reduction/issues/182
The order of callee-saved registers stored by Zcmp push in memory is reversed.
Pseudo code for cm.push in https://github.com/riscv/riscv-code-size-reduction/releases/download/v1.0.4-1/Zc.1.0.4-1.pdf
```
if (XLEN==32) bytes=4; else bytes=8;
addr=sp-bytes;
for(i in 27,26,25,24,23,22,21,20,19,18,9,8,1) {
//if register i is in xreg_list
if (xreg_list[i]) {
switch(bytes) {
4: asm("sw x[i], 0(addr)");
8: asm("sd x[i], 0(addr)");
}
addr-=bytes;
}
}
```
The placement order for push is s11, s10, ..., ra.
CFI offset should be calculed as reversed order for correct stack unwinding.
Reviewed By: fakepaper56, kito-cheng
Differential Revision: https://reviews.llvm.org/D156437
More information about the All-commits
mailing list