riscv64: add CFI_REMEMBER_STATE macro and use it.
Test: lunch aosp_riscv64-userdebug && m
Bug: b/271573990
Change-Id: I74d64ace77897ee77f29d54c83bc68c95be1a635
diff --git a/runtime/arch/riscv64/asm_support_riscv64.S b/runtime/arch/riscv64/asm_support_riscv64.S
index 2c02581..99e4080 100644
--- a/runtime/arch/riscv64/asm_support_riscv64.S
+++ b/runtime/arch/riscv64/asm_support_riscv64.S
@@ -52,8 +52,14 @@
.endm
+.macro CFI_REMEMBER_STATE
+ .cfi_remember_state
+.endm
+
+
// The spec is not clear whether the CFA is part of the saved state and tools differ in the
// behaviour, so explicitly set the CFA to avoid any ambiguity.
+// The restored CFA state should match the CFA state during CFI_REMEMBER_STATE.
.macro CFI_RESTORE_STATE_AND_DEF_CFA reg, offset
.cfi_restore_state
.cfi_def_cfa \reg, \offset
diff --git a/runtime/arch/riscv64/quick_entrypoints_riscv64.S b/runtime/arch/riscv64/quick_entrypoints_riscv64.S
index a94b661..49289df 100644
--- a/runtime/arch/riscv64/quick_entrypoints_riscv64.S
+++ b/runtime/arch/riscv64/quick_entrypoints_riscv64.S
@@ -362,7 +362,7 @@
// Tear down the alloca.
mv sp, fp
- .cfi_remember_state
+ CFI_REMEMBER_STATE
.cfi_def_cfa_register sp
LOAD_RUNTIME_INSTANCE a1
@@ -531,7 +531,7 @@
ld a2, THREAD_EXCEPTION_OFFSET(xSELF)
bnez a2, .Lexception_in_proxy // success if no exception is pending
- .cfi_remember_state
+ CFI_REMEMBER_STATE
RESTORE_SAVE_REFS_AND_ARGS_FRAME // Restore frame
fmv.d.x fa0, a0 // Store result in fa0 in case it was float or double
ret // return on success
@@ -568,9 +568,8 @@
mv a2, xSELF
mv a3, sp
call artQuickResolutionTrampoline
-
+ CFI_REMEMBER_STATE
beqz a0, 1f
- .cfi_remember_state
mv t0, a0 // Remember returned code pointer in t0.
ld a0, (sp) // artQuickResolutionTrampoline puts called method in *sp.