1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[RISCV] Don't emit save-restore call if function is a interrupt handler

It has to save all caller-saved registers before a call in the handler.
So don't emit a call that save/restore registers.

Reviewed By: simoncook, luismarques, asb

Differential Revision: https://reviews.llvm.org/D100532
This commit is contained in:
Jim Lin 2021-04-16 12:50:51 +08:00
parent ae11cac4bb
commit 04ff5f4d15
2 changed files with 34 additions and 2 deletions

View File

@ -60,9 +60,10 @@ public:
bool useSaveRestoreLibCalls(const MachineFunction &MF) const {
// We cannot use fixed locations for the callee saved spill slots if the
// function uses a varargs save area.
// function uses a varargs save area, or is an interrupt handler.
return MF.getSubtarget<RISCVSubtarget>().enableSaveRestore() &&
VarArgsSaveSize == 0 && !MF.getFrameInfo().hasTailCall();
VarArgsSaveSize == 0 && !MF.getFrameInfo().hasTailCall() &&
!MF.getFunction().hasFnAttribute("interrupt");
}
uint64_t getRVVStackSize() const { return RVVStackSize; }

View File

@ -297,3 +297,34 @@ define void @alloca(i32 %n) nounwind {
call void @llvm.stackrestore(i8* %sp)
ret void
}
; Check that functions with interrupt attribute do not use save/restore code
declare i32 @foo(...)
define void @interrupt() nounwind "interrupt"="user" {
; RV32I-LABEL: interrupt:
; RV32I-NOT: call t0, __riscv_save
; RV32I-NOT: tail __riscv_restore
;
; RV64I-LABEL: interrupt:
; RV64I-NOT: call t0, __riscv_save
; RV64I-NOT: tail __riscv_restore
;
; RV32I-SR-LABEL: interrupt:
; RV32I-SR-NOT: call t0, __riscv_save
; RV32I-SR-NOT: tail __riscv_restore
;
; RV64I-SR-LABEL: interrupt:
; RV64I-SR-NOT: call t0, __riscv_save
; RV64I-SR-NOT: tail __riscv_restore
;
; RV32I-FP-SR-LABEL: interrupt:
; RV32I-FP-SR-NOT: call t0, __riscv_save
; RV32I-FP-SR-NOT: tail __riscv_restore
;
; RV64I-FP-SR-LABEL: interrupt:
; RV64I-FP-SR-NOT: call t0, __riscv_save
; RV64I-FP-SR-NOT: tail __riscv_restore
%call = call i32 bitcast (i32 (...)* @foo to i32 ()*)()
ret void
}