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:
Anton Kirilov
2022-09-07 19:09:22 +01:00
committed by GitHub
parent e977f6a79d
commit dd07e354b4
7 changed files with 97 additions and 11 deletions

View File

@@ -743,6 +743,15 @@ macro_rules! isle_prelude_methods {
}
}
#[inline]
fn preserve_frame_pointers(&mut self) -> Option<()> {
if self.flags.preserve_frame_pointers() {
Some(())
} else {
None
}
}
#[inline]
fn func_ref_data(&mut self, func_ref: FuncRef) -> (SigRef, ExternalName, RelocDistance) {
let funcdata = &self.lower_ctx.dfg().ext_funcs[func_ref];