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:
15
cranelift/filetests/filetests/isa/aarch64/leaf.clif
Normal file
15
cranelift/filetests/filetests/isa/aarch64/leaf.clif
Normal 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
|
||||
|
||||
@@ -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
|
||||
|
||||
20
cranelift/filetests/filetests/isa/x64/leaf.clif
Normal file
20
cranelift/filetests/filetests/isa/x64/leaf.clif
Normal 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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user