diff options
| author | Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr> | 2013-06-03 04:34:19 +0000 |
|---|---|---|
| committer | Fabrice Le Fessant <Fabrice.Le_fessant@inria.fr> | 2013-06-03 04:34:19 +0000 |
| commit | 12722845d4cd648fe9446208e6296a819ced774e (patch) | |
| tree | 84c09beb4985c22f8f654f5bf3e0c376b5aa3bc3 /asmcomp/amd64/emit.mlp | |
| parent | 52b6c69951c0fb97549f406d36ed2f6157cc80a5 (diff) | |
| download | ocaml-with-frame-pointers.tar.gz | |
Add -with-frame-pointers to ./configurewith-frame-pointers
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/with-frame-pointers@13729 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'asmcomp/amd64/emit.mlp')
| -rw-r--r-- | asmcomp/amd64/emit.mlp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp index 447f63d6e3..2b598dbea9 100644 --- a/asmcomp/amd64/emit.mlp +++ b/asmcomp/amd64/emit.mlp @@ -23,6 +23,8 @@ open Emitaux let macosx = (Config.system = "macosx") let mingw64 = (Config.system = "mingw64") +let fp() = Config.with_frame_pointers + (* Tradeoff between code size and code speed *) let fastcode_flag = ref true @@ -32,12 +34,13 @@ let stack_offset = ref 0 (* Layout of the stack frame *) let frame_required () = - !contains_calls || num_stack_slots.(0) > 0 || num_stack_slots.(1) > 0 + fp() || !contains_calls || num_stack_slots.(0) > 0 || num_stack_slots.(1) > 0 let frame_size () = (* includes return address *) if frame_required() then begin let sz = - (!stack_offset + 8 * (num_stack_slots.(0) + num_stack_slots.(1)) + 8) + (!stack_offset + 8 * (num_stack_slots.(0) + num_stack_slots.(1)) + 8 + + (if fp() then 8 else 0) ) in Misc.align sz 16 end else !stack_offset + 8 @@ -107,13 +110,13 @@ let emit_reg = function let reg_low_8_name = [| "%al"; "%bl"; "%dil"; "%sil"; "%dl"; "%cl"; "%r8b"; "%r9b"; - "%r12b"; "%r13b"; "%bpl"; "%r10b"; "%r11b" |] + "%r12b"; "%r13b"; "%r10b"; "%r11b"; "%bpl" |] let reg_low_16_name = [| "%ax"; "%bx"; "%di"; "%si"; "%dx"; "%cx"; "%r8w"; "%r9w"; - "%r12w"; "%r13w"; "%bp"; "%r10w"; "%r11w" |] + "%r12w"; "%r13w"; "%r10w"; "%r11w"; "%bp" |] let reg_low_32_name = [| "%eax"; "%ebx"; "%edi"; "%esi"; "%edx"; "%ecx"; "%r8d"; "%r9d"; - "%r12d"; "%r13d"; "%ebp"; "%r10d"; "%r11d" |] + "%r12d"; "%r13d"; "%r10d"; "%r11d"; "%ebp" |] let emit_subreg tbl r = match r.loc with @@ -316,9 +319,12 @@ let emit_float_test cmp neg arg lbl = let output_epilogue f = if frame_required() then begin - let n = frame_size() - 8 in + let n = frame_size() - 8 - (if fp() then 8 else 0) in ` addq ${emit_int n}, %rsp\n`; cfi_adjust_cfa_offset (-n); + if fp() then begin + ` popq %rbp\n` + end; f (); (* reset CFA back cause function body may continue *) cfi_adjust_cfa_offset n @@ -696,7 +702,8 @@ let emit_profile () = need to preserve other regs. We do need to initialize rbp like mcount expects it, though. *) ` pushq %r10\n`; - ` movq %rsp, %rbp\n`; + if not Config.with_frame_pointers then + ` movq %rsp, %rbp\n`; ` {emit_call "mcount"}\n`; ` popq %r10\n` | _ -> @@ -724,9 +731,14 @@ let fundecl fundecl = `{emit_symbol fundecl.fun_name}:\n`; emit_debug_info fundecl.fun_dbg; cfi_startproc (); + if fp() then begin + ` pushq %rbp\n`; + cfi_adjust_cfa_offset 8; + ` movq %rsp, %rbp\n`; + end; if !Clflags.gprofile then emit_profile(); if frame_required() then begin - let n = frame_size() - 8 in + let n = frame_size() - 8 - (if fp() then 8 else 0) in ` subq ${emit_int n}, %rsp\n`; cfi_adjust_cfa_offset n; end; |
