aboutsummaryrefslogtreecommitdiffstats
path: root/x86
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2018-06-01 16:52:02 +0200
committerXavier Leroy <xavier.leroy@inria.fr>2018-06-01 16:52:02 +0200
commitc58b421571b0354eea602adbdae674bd1f4847e3 (patch)
tree8c83d3d7428097523d8af00b9abdcf117532be30 /x86
parent24951d885fbadb8f2fa96ea44a6d3b2a397eab00 (diff)
downloadcompcert-kvx-c58b421571b0354eea602adbdae674bd1f4847e3.tar.gz
compcert-kvx-c58b421571b0354eea602adbdae674bd1f4847e3.zip
Model external calls as destroying all caller-save registers
The semantics of external function calls in LTL, Linear, Mach and Asm now consider that all caller-save registers are set to Vundef by the call. This models that fact that the external function can modify those registers arbitrarily. Update the proofs of the Allocation, Tunneling, Stacking and Asmgen passes accordingly.
Diffstat (limited to 'x86')
-rw-r--r--x86/Asm.v11
-rw-r--r--x86/Asmgenproof.v4
2 files changed, 12 insertions, 3 deletions
diff --git a/x86/Asm.v b/x86/Asm.v
index 8b873e48..7b4a29f4 100644
--- a/x86/Asm.v
+++ b/x86/Asm.v
@@ -1047,6 +1047,15 @@ Definition preg_of (r: mreg) : preg :=
| FP0 => ST0
end.
+(** Undefine all registers except SP and callee-save registers *)
+
+Definition undef_caller_save_regs (rs: regset) : regset :=
+ fun r =>
+ if preg_eq r SP
+ || In_dec preg_eq r (List.map preg_of (List.filter is_callee_save all_mregs))
+ then rs r
+ else Vundef.
+
(** Extract the values of the arguments of an external call.
We exploit the calling conventions from module [Conventions], except that
we use machine registers instead of locations. *)
@@ -1106,7 +1115,7 @@ Inductive step: state -> trace -> state -> Prop :=
Genv.find_funct_ptr ge b = Some (External ef) ->
extcall_arguments rs m (ef_sig ef) args ->
external_call ef ge args m t res m' ->
- rs' = (set_pair (loc_external_result (ef_sig ef)) res rs) #PC <- (rs RA) ->
+ rs' = (set_pair (loc_external_result (ef_sig ef)) res (undef_caller_save_regs rs)) #PC <- (rs RA) ->
step (State rs m) t (State rs' m').
End RELSEM.
diff --git a/x86/Asmgenproof.v b/x86/Asmgenproof.v
index 38816fd2..3aa87a4c 100644
--- a/x86/Asmgenproof.v
+++ b/x86/Asmgenproof.v
@@ -861,8 +861,8 @@ Transparent destroyed_at_function_entry.
apply plus_one. eapply exec_step_external; eauto.
eapply external_call_symbols_preserved; eauto. apply senv_preserved.
econstructor; eauto.
- unfold loc_external_result.
- apply agree_set_other; auto. apply agree_set_pair; auto.
+ unfold loc_external_result. apply agree_set_other; auto. apply agree_set_pair; auto.
+ apply agree_undef_caller_save_regs; auto.
- (* return *)
inv STACKS. simpl in *.