cranelift: Add a flag for preserving frame pointers (#4469)

Preserving frame pointers -- even inside leaf functions -- makes it easy to
capture the stack of a running program, without requiring any side tables or
metadata (like `.eh_frame` sections). Many sampling profilers and similar tools
walk frame pointers to capture stacks. Enabling this option will play nice with
those tools.
This commit is contained in:
Nick Fitzgerald
2022-07-20 08:02:21 -07:00
committed by GitHub
parent 6e099720af
commit 22d91a7c84
8 changed files with 96 additions and 7 deletions

View File

@@ -0,0 +1,15 @@
;; Test compilation of leaf functions without preserving frame pointers.
test compile precise-output
set unwind_info=false
set preserve_frame_pointers=false
target aarch64
function %leaf(i64) -> i64 {
block0(v0: i64):
return v0
}
; block0:
; ret

View File

@@ -0,0 +1,18 @@
;; Test compilation of leaf functions while preserving frame pointers.
test compile precise-output
set unwind_info=false
set preserve_frame_pointers=true
target aarch64
function %leaf(i64) -> i64 {
block0(v0: i64):
return v0
}
; stp fp, lr, [sp, #-16]!
; mov fp, sp
; block0:
; ldp fp, lr, [sp], #16
; ret

View File

@@ -0,0 +1,20 @@
;; Test compilation of leaf functions without preserving frame pointers.
test compile precise-output
set unwind_info=false
set preserve_frame_pointers=false
target x86_64
function %leaf(i64) -> i64 {
block0(v0: i64):
return v0
}
; pushq %rbp
; movq %rsp, %rbp
; block0:
; movq %rdi, %rax
; movq %rbp, %rsp
; popq %rbp
; ret

View File

@@ -0,0 +1,20 @@
;; Test compilation of leaf functions while preserving frame pointers.
test compile precise-output
set unwind_info=false
set preserve_frame_pointers=true
target x86_64
function %leaf(i64) -> i64 {
block0(v0: i64):
return v0
}
; pushq %rbp
; movq %rsp, %rbp
; block0:
; movq %rdi, %rax
; movq %rbp, %rsp
; popq %rbp
; ret