Cranelift AArch64: Fix the get_return_address lowering (#4851)
The previous implementation assumed that nothing had clobbered the LR register since the current function had started executing, so it would be incorrect for a non-leaf function, for example, that contains the `get_return_address` operation right after a call. The operation is valid only if the `preserve_frame_pointers` flag is enabled, which implies that the presence of a frame record on the stack is guaranteed. Copyright (c) 2022, Arm Limited.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
test compile precise-output
|
||||
set preserve_frame_pointers=true
|
||||
target aarch64 sign_return_address
|
||||
|
||||
function %fp() -> i64 {
|
||||
block0:
|
||||
v0 = get_frame_pointer.i64
|
||||
return v0
|
||||
}
|
||||
|
||||
; paciasp
|
||||
; stp fp, lr, [sp, #-16]!
|
||||
; mov fp, sp
|
||||
; block0:
|
||||
; mov x0, fp
|
||||
; ldp fp, lr, [sp], #16
|
||||
; autiasp ; ret
|
||||
|
||||
function %sp() -> i64 {
|
||||
block0:
|
||||
v0 = get_stack_pointer.i64
|
||||
return v0
|
||||
}
|
||||
|
||||
; paciasp
|
||||
; stp fp, lr, [sp, #-16]!
|
||||
; mov fp, sp
|
||||
; block0:
|
||||
; mov x0, sp
|
||||
; ldp fp, lr, [sp], #16
|
||||
; autiasp ; ret
|
||||
|
||||
function %return_address() -> i64 {
|
||||
block0:
|
||||
v0 = get_return_address.i64
|
||||
return v0
|
||||
}
|
||||
|
||||
; paciasp
|
||||
; stp fp, lr, [sp, #-16]!
|
||||
; mov fp, sp
|
||||
; block0:
|
||||
; ldr lr, [fp, #8]
|
||||
; xpaclri
|
||||
; mov x0, lr
|
||||
; ldp fp, lr, [sp], #16
|
||||
; autiasp ; ret
|
||||
@@ -37,7 +37,6 @@ block0:
|
||||
; stp fp, lr, [sp, #-16]!
|
||||
; mov fp, sp
|
||||
; block0:
|
||||
; mov x0, lr
|
||||
; ldr x0, [fp, #8]
|
||||
; ldp fp, lr, [sp], #16
|
||||
; ret
|
||||
|
||||
|
||||
Reference in New Issue
Block a user