summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-05-17 11:37:39 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-05-17 11:37:39 +0000
commita3f1744823d6dbeaf400812de86263fb615bbbba (patch)
treeff1ed0a68fe2dceb19bb768cec89912344ea1ef6 /backend
parent61f6aed04b846b174126d4b1cec28f6f1da20e52 (diff)
Add option -fno-tailcalls to turn off tailcall elimination (causes problem with some static analysis tools).
*/PrintAsm.ml: don't cfa_adjust at Pfreeframe, as more code from the function can appear after (in case of tailcalls). git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2256 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'backend')
-rw-r--r--backend/Tailcall.v7
-rw-r--r--backend/Tailcallproof.v10
2 files changed, 11 insertions, 6 deletions
diff --git a/backend/Tailcall.v b/backend/Tailcall.v
index 917ec83..26beb34 100644
--- a/backend/Tailcall.v
+++ b/backend/Tailcall.v
@@ -95,10 +95,13 @@ Definition transf_instr (f: function) (pc: node) (instr: instruction) :=
end.
(** A function is transformed only if its stack block is empty,
- as explained above. *)
+ as explained above. Moreover, we can turn tail calls off
+ using a compilation option. *)
+
+Parameter eliminate_tailcalls: unit -> bool.
Definition transf_function (f: function) : function :=
- if zeq f.(fn_stacksize) 0
+ if zeq f.(fn_stacksize) 0 && eliminate_tailcalls tt
then RTL.transf_function (transf_instr f) f
else f.
diff --git a/backend/Tailcallproof.v b/backend/Tailcallproof.v
index 02a6ca9..77725cf 100644
--- a/backend/Tailcallproof.v
+++ b/backend/Tailcallproof.v
@@ -181,10 +181,12 @@ Lemma transf_instr_lookup:
f.(fn_code)!pc = Some i ->
exists i', (transf_function f).(fn_code)!pc = Some i' /\ transf_instr_spec f i i'.
Proof.
- intros. unfold transf_function. destruct (zeq (fn_stacksize f) 0).
+ intros. unfold transf_function.
+ destruct (zeq (fn_stacksize f) 0). destruct (eliminate_tailcalls tt).
simpl. rewrite PTree.gmap. rewrite H. simpl.
exists (transf_instr f pc i); split. auto. apply transf_instr_charact; auto.
exists i; split. auto. constructor.
+ exists i; split. auto. constructor.
Qed.
(** * Semantic properties of the code transformation *)
@@ -260,14 +262,14 @@ Lemma sig_preserved:
forall f, funsig (transf_fundef f) = funsig f.
Proof.
destruct f; auto. simpl. unfold transf_function.
- destruct (zeq (fn_stacksize f) 0); auto.
+ destruct (zeq (fn_stacksize f) 0 && eliminate_tailcalls tt); auto.
Qed.
Lemma stacksize_preserved:
forall f, fn_stacksize (transf_function f) = fn_stacksize f.
Proof.
unfold transf_function. intros.
- destruct (zeq (fn_stacksize f) 0); auto.
+ destruct (zeq (fn_stacksize f) 0 && eliminate_tailcalls tt); auto.
Qed.
Lemma find_function_translated:
@@ -553,7 +555,7 @@ Proof.
assert (fn_stacksize (transf_function f) = fn_stacksize f /\
fn_entrypoint (transf_function f) = fn_entrypoint f /\
fn_params (transf_function f) = fn_params f).
- unfold transf_function. destruct (zeq (fn_stacksize f) 0); auto.
+ unfold transf_function. destruct (zeq (fn_stacksize f) 0 && eliminate_tailcalls tt); auto.
destruct H0 as [EQ1 [EQ2 EQ3]].
left. econstructor; split.
simpl. eapply exec_function_internal; eauto. rewrite EQ1; eauto.