aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--backend/CSE2.v48
-rw-r--r--backend/CSE2proof.v35
-rw-r--r--backend/Linearizeaux.ml5
-rwxr-xr-xconfigure2
4 files changed, 56 insertions, 34 deletions
diff --git a/backend/CSE2.v b/backend/CSE2.v
index dc206c75..cad740ba 100644
--- a/backend/CSE2.v
+++ b/backend/CSE2.v
@@ -262,33 +262,29 @@ Definition load (chunk: memory_chunk) (addr : addressing)
| None => load1 chunk addr dst args rel
end.
-(* NO LONGER NEEDED
-Fixpoint list_represents { X : Type } (l : list (positive*X)) (tr : PTree.t X) : Prop :=
- match l with
- | nil => True
- | (r,sv)::tail => (tr ! r) = Some sv /\ list_represents tail tr
+Fixpoint kill_builtin_res res rel :=
+ match res with
+ | BR r => kill_reg r rel
+ | _ => rel
end.
-Lemma elements_represent :
- forall { X : Type },
- forall tr : (PTree.t X),
- (list_represents (PTree.elements tr) tr).
-Proof.
- intros.
- generalize (PTree.elements_complete tr).
- generalize (PTree.elements tr).
- induction l; simpl; trivial.
- intro COMPLETE.
- destruct a as [ r sv ].
- split.
- {
- apply COMPLETE.
- left; reflexivity.
- }
- apply IHl; auto.
-Qed.
-*)
-
+Definition apply_external_call ef (rel : RELATION.t) : RELATION.t :=
+ match ef with
+ | EF_builtin name sg
+ | EF_runtime name sg =>
+ match Builtins.lookup_builtin_function name sg with
+ | Some bf => rel
+ | None => kill_mem rel
+ end
+ | EF_malloc (* FIXME *)
+ | EF_external _ _
+ | EF_vstore _
+ | EF_free (* FIXME *)
+ | EF_memcpy _ _ (* FIXME *)
+ | EF_inline_asm _ _ _ => kill_mem rel
+ | _ => rel
+ end.
+
Definition apply_instr instr (rel : RELATION.t) : RB.t :=
match instr with
| Inop _
@@ -298,7 +294,7 @@ Definition apply_instr instr (rel : RELATION.t) : RB.t :=
| Iop op args dst _ => Some (gen_oper op dst args rel)
| Iload trap chunk addr args dst _ => Some (load chunk addr dst args rel)
| Icall _ _ _ dst _ => Some (kill_reg dst (kill_mem rel))
- | Ibuiltin _ _ res _ => Some (RELATION.top) (* TODO (kill_builtin_res res x) *)
+ | Ibuiltin ef _ res _ => Some (kill_builtin_res res (apply_external_call ef rel))
| Itailcall _ _ _ | Ireturn _ => RB.bot
end.
diff --git a/backend/CSE2proof.v b/backend/CSE2proof.v
index 309ccce1..9e0ad909 100644
--- a/backend/CSE2proof.v
+++ b/backend/CSE2proof.v
@@ -1033,7 +1033,16 @@ Proof.
assumption.
}
intuition congruence.
-Qed.
+Qed.
+
+Lemma kill_builtin_res_sound:
+ forall res (m : mem) (rs : regset) vres (rel : RELATION.t)
+ (REL : sem_rel m rel rs),
+ (sem_rel m (kill_builtin_res res rel) (regmap_setres res vres rs)).
+Proof.
+ destruct res; simpl; intros; trivial.
+ apply kill_reg_sound; trivial.
+Qed.
End SOUNDNESS.
Definition match_prog (p tp: RTL.program) :=
@@ -1116,6 +1125,22 @@ Definition is_killed_in_fmap fmap pc res :=
| Some map => is_killed_in_map map pc res
end.
+Lemma external_call_sound:
+ forall ef (rel : RELATION.t) sp (m m' : mem) (rs : regset) vargs t vres
+ (REL : sem_rel fundef unit ge sp m rel rs)
+ (CALL : external_call ef ge vargs m t vres m'),
+ sem_rel fundef unit ge sp m' (apply_external_call ef rel) rs.
+Proof.
+ destruct ef; intros; simpl in *.
+ all: eauto using kill_mem_sound.
+ all: unfold builtin_or_external_sem in *.
+ 1, 2: destruct (Builtins.lookup_builtin_function name sg);
+ eauto using kill_mem_sound;
+ inv CALL; eauto using kill_mem_sound.
+ all: inv CALL.
+ all: eauto using kill_mem_sound.
+Qed.
+
Definition sem_rel_b' := sem_rel_b fundef unit ge.
Definition fmap_sem' := fmap_sem fundef unit ge.
Definition subst_arg_ok' := subst_arg_ok fundef unit ge.
@@ -1578,9 +1603,9 @@ Proof.
destruct (forward_map _) as [map |] eqn:MAP in *; trivial.
destruct (map # pc) as [mpc |] eqn:MPC in *; try contradiction.
- apply sem_rel_b_ge with (rb2 := Some RELATION.top).
+ apply sem_rel_b_ge with (rb2 := Some (kill_builtin_res res (apply_external_call ef mpc))).
{
- replace (Some RELATION.top) with (apply_instr' (fn_code f) pc (map # pc)).
+ replace (Some (kill_builtin_res res (apply_external_call ef mpc))) with (apply_instr' (fn_code f) pc (map # pc)).
{
eapply DS.fixpoint_solution with (code := fn_code f) (successors := successors_instr); try eassumption.
2: apply apply_instr'_bot.
@@ -1591,8 +1616,8 @@ Proof.
rewrite MPC.
reflexivity.
}
- apply top_ok.
-
+ apply kill_builtin_res_sound.
+ eapply external_call_sound with (m := m); eassumption.
(* cond *)
- econstructor; split.
diff --git a/backend/Linearizeaux.ml b/backend/Linearizeaux.ml
index 1381877b..9d5a5ba6 100644
--- a/backend/Linearizeaux.ml
+++ b/backend/Linearizeaux.ml
@@ -193,8 +193,9 @@ let forward_sequences code entry =
if get_some @@ PTree.get ifnot join_points then ([], [ifso; ifnot])
else let ln, rem = traverse_fallthrough code ifnot in (ln, [ifso] @ rem)
| Some true ->
- let errstr = Printf.sprintf ("Inconsistency detected in node %d: ifnot is not the preferred branch") (P.to_int node) in
- failwith errstr)
+ if get_some @@ PTree.get ifso join_points then ([], [ifso; ifnot])
+ else let ln, rem = traverse_fallthrough code ifso in (ln, [ifnot] @ rem)
+ )
| Ljumptable(_, ln) -> begin (* debug "STOP Ljumptable\n"; *) ([], ln) end
in ([node] @ ln, rem)
end
diff --git a/configure b/configure
index cb2f52ba..366ab847 100755
--- a/configure
+++ b/configure
@@ -575,7 +575,7 @@ case "$coq_ver" in
if $ignore_coq_version; then
echo "Warning: this version of Coq is unsupported, proceed at your own risks."
else
- echo "Error: CompCert requires one of the following Coq versions: 8.11.0, 8.10.2, 8.10.1, 8.10.0, 8.9.1, 8.9.0, 8.8.2, 8.8.1, 8.8.0"
+ echo "Error: CompCert requires one of the following Coq versions: 8.11.1, 8.11.0, 8.10.2, 8.10.1, 8.10.0, 8.9.1, 8.9.0"
missingtools=true
fi;;
"")