[llvm] [RISCV] Prefer Zcmp push/pop instead of save-restore calls. (PR #66046)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 12 02:01:41 PDT 2023
================
@@ -131,27 +129,26 @@ define i32 @pushpopret0(i32 signext %size){
;
; RV32IZCMP-SR-LABEL: pushpopret0:
; RV32IZCMP-SR: # %bb.0: # %entry
-; RV32IZCMP-SR-NEXT: call t0, __riscv_save_1
+; RV32IZCMP-SR-NEXT: cm.push {ra, s0}, -16
; RV32IZCMP-SR-NEXT: .cfi_def_cfa_offset 16
-; RV32IZCMP-SR-NEXT: .cfi_offset ra, -4
-; RV32IZCMP-SR-NEXT: .cfi_offset s0, -8
----------------
Xinlong-Wu wrote:
It seems be a problem,
the func of `__riscv_save_1` is
```
FUNC_BEGIN (__riscv_save_1)
.cfi_startproc
# __riscv_save_* routine use t0/x5 as return address
.cfi_return_column 5
addi sp, sp, -16
.cfi_def_cfa_offset 16
sd s0, 0(sp)
.cfi_offset 8, -16
sd ra, 8(sp)
.cfi_offset 1, -8
jr t0
.cfi_endproc
FUNC_END (__riscv_save_1)
```
while, I think the inst `cm.push {ra, s0}, -16` will execute following insts as[ Zc Spec](https://github.com/riscv/riscv-code-size-reduction/releases) has mentioned.
```
sd s0, -8(sp)
sd ra, -16(sp)
addi sp, sp, -16
```
That's why I think `.cfi_offset` should be
```
.cfi_offset ra, -4
.cfi_offset s0, -8
```
https://github.com/llvm/llvm-project/pull/66046
More information about the llvm-commits
mailing list