Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
28b7b96
initial working port of events
AndrewTolmach Nov 10, 2023
45d476c
a fairly clean version
AndrewTolmach Nov 10, 2023
8fb5bb5
Start removing the cross-compartment calls. Remove all compartments f…
jeremyThibault Nov 16, 2023
2d16557
[Compartment model] Continue generalizing the compartment model
jeremyThibault Nov 20, 2023
cb74dc2
[Compartments] Continue fixing the compartment model, with changes in…
jeremyThibault Nov 23, 2023
051e5c6
[Compartments] Fix Selectionproof.v and modify RTL.v
jeremyThibault Nov 24, 2023
769c0e2
[Compartments] Restore two instances removed by mistake
jeremyThibault Nov 26, 2023
8edd816
[Compartments] Fix RTLgenproof.v
jeremyThibault Nov 26, 2023
30dbad3
[Compartments] Fix Tailcall pass
jeremyThibault Nov 26, 2023
d85d37e
[Compartments] Fix Inlining pass
jeremyThibault Nov 26, 2023
363a5af
[Compartments] Fixers to RTLtyping, Renumber pass, and Cop/Ctypes
jeremyThibault Nov 26, 2023
4754b08
[Compartments] Various fixes in Allocation, Tunneling, Unusedglob, Cs…
jeremyThibault Nov 26, 2023
7f7516f
[Compartments] Fix RTL optimizations passes (except ValueAnalysis) an…
jeremyThibault Nov 27, 2023
004144f
[Compartments] Fix Tunneling pass
jeremyThibault Nov 27, 2023
5baf152
[Compartments] Partially fix proofs for Linear level. Break for lunch
jeremyThibault Nov 27, 2023
f094b52
[Compartments] Fix Mach generation pass and fix Asm language
jeremyThibault Nov 27, 2023
5173743
[Compartments] Fix the compilation process from start to end
jeremyThibault Nov 30, 2023
e28fdea
[Compartments] Little fixes
jeremyThibault Dec 4, 2023
24d938f
[Compartments] Integrate a functional, not-verified version of the ba…
jeremyThibault Dec 6, 2023
9120825
[Compartments] Fix proof in ValueAnalysis
jeremyThibault Dec 6, 2023
c497ce3
[Compartments] Clean-up the compartment model
jeremyThibault Dec 6, 2023
64ed87e
[Compartments] Clean a bit
jeremyThibault Dec 6, 2023
5057a98
[Compartments] Remove recomposition file
jeremyThibault Dec 6, 2023
8a9f2d9
Import testing code from old branch
argsv Dec 7, 2023
4e9bb22
Update extraction to fix build issues
argsv Dec 7, 2023
bf394cb
Dump clight to file and compile entire file
argsv Dec 7, 2023
26843d8
Make sure that main function has correct name
argsv Dec 7, 2023
a13a04a
Generate and test larger ASM program skeletons (it fails)
argsv Dec 8, 2023
6bb2d8a
Only allow var_args in calling convention if at least one argument is…
argsv Dec 8, 2023
38eecfa
Use subprocess to compile dumped C code to ensure correct usage and s…
argsv Dec 8, 2023
81f538f
Move printing functions to new module
argsv Dec 8, 2023
d1e7918
Improve Makefile
argsv Dec 8, 2023
a09a862
Generate non-empty bundle-traces for backtranslation (tests fail)
argsv Dec 8, 2023
7082fae
Generate no calling convention with cc_unproto = true
argsv Dec 8, 2023
cdd8a96
Fix special floating point values and missing includes for generated …
argsv Dec 8, 2023
c702831
[Compiler] Fix the compilation process and add instructions to test c…
jeremyThibault Dec 8, 2023
f5f567e
Ensure that global variables are defined before usage
argsv Dec 11, 2023
a61f2ea
Clean up output
argsv Dec 11, 2023
fbf6ede
Implement generation of builtins in bundle_trace (tests fail)
argsv Dec 11, 2023
e99b733
Add non-trivial memory deltas to the trace events (tests fail)
argsv Dec 11, 2023
61baedb
Make all runs of tests deterministic and reproducible
argsv Dec 13, 2023
c99987b
Extract export of clight programs to compilable c files in custom module
argsv Dec 13, 2023
afb99de
Implement output functions for memory_deltas
argsv Dec 13, 2023
b7c9f87
Add global variables to the context and the ASM program
argsv Dec 15, 2023
0734131
Ensure that all global variables are void* to avoid "incomplete type"…
argsv Dec 15, 2023
6e9fea4
Fix renaming to float constants in math.h
argsv Dec 15, 2023
b9e2d4a
Only use identifiers of global vars in generatied mem_deltas
argsv Dec 15, 2023
5b70457
Mark global variables as public in ASM program
argsv Dec 15, 2023
dabf3c8
Find block for each global var to ensure the inversion in BT works
argsv Dec 18, 2023
59912cb
Avoid linker errors for external symbols
argsv Dec 18, 2023
9128c30
Improve exporting/post-processing to fix more errors
argsv Dec 18, 2023
5449c07
Always print a global root seed for reproducibility
argsv Dec 18, 2023
fb628b9
Ensure that pointer values in mem_deltas refer to valid global vars
argsv Dec 18, 2023
5fe8f22
Ensure that we only write to non-const global variables
argsv Dec 18, 2023
1d92355
Fix type errors with more post-processing
argsv Dec 18, 2023
7bf3f17
Fix warning (tests now work also for non-empty memory deltas)
argsv Dec 18, 2023
6a3e70b
Make tests work with some external functions (external, builtin and r…
argsv Dec 19, 2023
c5c3323
Improve usability for multiple ASM progs/traces
argsv Dec 19, 2023
dfadf6a
Harden against kill/abort signals for long runs
argsv Jan 12, 2024
5723447
Collect and output some statistics about the generated values
argsv Jan 15, 2024
d50388a
Introduce "test" and "reproduction mode" to precisely reproduce possi…
argsv Jan 15, 2024
2fe2fc1
Explain test and reproduction mode in help
argsv Jan 15, 2024
0516e3e
Add "-out_file" to redirect output into a file
argsv Jan 15, 2024
fd5627a
Add additional information to stat output
argsv Jan 15, 2024
ed9d07d
Add results.txt from first long run on server
argsv Jan 18, 2024
b86f425
Add unique suffix to identifier to avoid name clashes
argsv Jan 18, 2024
047dd3d
Implement generation for missing variants of external functions
argsv Jan 18, 2024
00be091
Support annotations and value annotations as external function
argsv Jan 18, 2024
bdbcf29
[Common] Fix axioms for commutativity of injections and external calls
jeremyThibault Jan 11, 2024
164f434
[Backtranslation] Uncomment proofs
jeremyThibault Jan 18, 2024
3d6903d
[common] Fix dependent proof with Arthur
jeremyThibault Jan 18, 2024
200da97
Merge remote-tracking branch 'origin/cross-external-call-removal-test…
jeremyThibault Jan 18, 2024
167b68e
Support vstore and vload as external functions
argsv Jan 19, 2024
0269bd7
[common] Fix proofs in linking
jeremyThibault Jan 19, 2024
2e6904f
[Backtranslation] Fix some proofs, readd one axiom about external cal…
jeremyThibault Jan 21, 2024
6051560
[Backtranslation] WIP fixing backtranslation
jeremyThibault Jan 22, 2024
184f10d
[Backtranslation] Progress integrating backtranslation proof
jeremyThibault Jan 23, 2024
132733e
[Backtranslation] Checkpoint
jeremyThibault Jan 23, 2024
2b0c34d
Add results02.txt from second and improved long run on server
argsv Jan 25, 2024
189773e
Cleanup
jeremyThibault Jan 28, 2024
c5862ac
Merge remote-tracking branch 'origin/cross-external-call-removal-test…
jeremyThibault Jan 28, 2024
8063983
Merge remote-tracking branch 'origin/apt_io_events' into ccs-submission
jeremyThibault Jan 28, 2024
0223a9d
Small fix
jeremyThibault Jan 29, 2024
5efe296
Small fix again
jeremyThibault Jan 29, 2024
93bf5e4
Comments on technical lemmas
jeremyThibault Jan 29, 2024
4fca9b2
Fix
jeremyThibault Jan 29, 2024
494a6f2
Fix correctness
jeremyThibault Feb 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ CFRONTEND=Ctypes.v Cop.v Csyntax.v Csem.v Ctyping.v Cstrategy.v Cexec.v \

# Security proof (in security/)

SECURITY=RSC.v Split.v Blame.v
SECURITY= Split.v Tactics.v MemoryWeak.v MemoryDelta.v BtBasics.v BtInfoAsm.v BtInfoAsmBound.v Backtranslation.v BacktranslationAux.v BacktranslationProof.v

# Parser

Expand Down
44 changes: 35 additions & 9 deletions backend/Allocation.v
Original file line number Diff line number Diff line change
Expand Up @@ -1008,13 +1008,13 @@ Definition kind_second_word := if Archi.big_endian then Low else High.
equations that must hold "before" these instructions, or [None] if
impossible. *)

(* FIXME A [Genv.type_of_call]-like function that closely mimics it but does not
take a global environment as a parameter and only distinguishes between
cross-compartment calls and everything else. Can be made cleaner. *)
Definition is_external_call (cp: compartment) (cp': compartment): bool :=
if Pos.eqb cp cp' then false
else if Pos.eqb cp' default_compartment then false
else true.
(* (* FIXME A [Genv.type_of_call]-like function that closely mimics it but does not *)
(* take a global environment as a parameter and only distinguishes between *)
(* cross-compartment calls and everything else. Can be made cleaner. *) *)
(* Definition is_external_call (cp: compartment) (cp': compartment): bool := *)
(* if Pos.eqb cp cp' then false *)
(* else if Pos.eqb cp' default_compartment then false *)
(* else true. *)

Definition transfer_aux (f: RTL.function) (env: regenv)
(shape: block_shape) (e: eqs) : option eqs :=
Expand Down Expand Up @@ -1120,7 +1120,7 @@ Definition transfer_aux (f: RTL.function) (env: regenv)
assertion (can_undef (destroyed_by_builtin ef) e2);
do e3 <-
match ef with
| EF_debug _ _ _ _ => add_equations_debug_args env args args' e2
| EF_debug _ _ _ => add_equations_debug_args env args args' e2
| _ => add_equations_builtin_args env args args' e2
end;
track_moves env mv1 e3
Expand Down Expand Up @@ -1365,7 +1365,7 @@ Definition check_function (rtl: RTL.function) (ltl: LTL.function) (env: regenv):
match analyze rtl env bsh with
| None => Error (msg "allocation analysis diverges")
| Some a =>
if eq_compartment rtl.(RTL.fn_comp) ltl.(LTL.fn_comp) then
if cp_eq_dec rtl.(RTL.fn_comp) ltl.(LTL.fn_comp) then
check_entrypoints rtl ltl env bsh a
else Error (msg "register allocation changed the function compartment")
end.
Expand All @@ -1390,6 +1390,32 @@ Definition transf_function (f: RTL.function) : res LTL.function :=
Definition transf_fundef (fd: RTL.fundef) : res LTL.fundef :=
AST.transf_partial_fundef transf_function fd.

#[global] Instance comp_transf_function: has_comp_transl_partial transf_function.
Proof.
unfold transf_function, check_function.
intros f ? H.
destruct type_function; try easy.
destruct regalloc; try easy.
destruct analyze; try easy.
destruct cp_eq_dec as [e|?]; try easy.
monadInv H.
exact e.
Qed.

#[global] Instance comp_transf_fundef: has_comp_transl_partial transf_fundef.
Proof.
unfold transf_fundef, transf_partial_fundef, transf_function, check_function.
intros f ? H.
destruct f.
- destruct type_function; try easy.
destruct regalloc; try easy.
destruct analyze; try easy.
destruct cp_eq_dec as [e|?]; try easy.
monadInv H. monadInv EQ.
exact e.
- now inv H.
Qed.

Definition transf_program (p: RTL.program) : res LTL.program :=
transform_partial_program transf_fundef p.

64 changes: 19 additions & 45 deletions backend/Allocproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,6 @@ Require Import Allocation.
Definition match_prog (p: RTL.program) (tp: LTL.program) :=
match_program (fun _ f tf => transf_fundef f = OK tf) eq p tp.

#[global]
Instance comp_transf_function: has_comp_transl_partial transf_function.
Proof.
unfold transf_function, check_function.
intros f ? H.
destruct type_function; try easy.
destruct regalloc; try easy.
destruct analyze; try easy.
destruct eq_compartment as [e|?]; try easy.
monadInv H.
exact e.
Qed.

#[global]
Instance comp_transf_fundef: has_comp_transl_partial transf_fundef.
Proof.
unfold transf_fundef, transf_partial_fundef, transf_function, check_function.
intros f ? H.
destruct f.
- destruct type_function; try easy.
destruct regalloc; try easy.
destruct analyze; try easy.
destruct eq_compartment as [e|?]; try easy.
monadInv H. monadInv EQ.
exact e.
- now inv H.
Qed.

Lemma transf_program_match:
forall p tp, transf_program p = OK tp -> match_prog p tp.
Proof.
Expand Down Expand Up @@ -2297,20 +2269,20 @@ Proof.
Qed.

Lemma add_equations_builtin_eval:
forall ef env args args' e1 e2 m1 m1' rs ls (ge: RTL.genv) sp vargs t vres m2,
forall ef cp env args args' e1 e2 m1 m1' rs ls (ge: RTL.genv) sp vargs t vres m2,
wt_regset env rs ->
match ef with
| EF_debug _ _ _ _ => add_equations_debug_args env args args' e1
| EF_debug _ _ _ => add_equations_debug_args env args args' e1
| _ => add_equations_builtin_args env args args' e1
end = Some e2 ->
Mem.extends m1 m1' ->
satisf rs ls e2 ->
eval_builtin_args ge (fun r => rs # r) sp m1 args vargs ->
external_call ef ge vargs m1 t vres m2 ->
external_call ef ge cp vargs m1 t vres m2 ->
satisf rs ls e1 /\
exists vargs' vres' m2',
eval_builtin_args ge ls sp m1' args' vargs'
/\ external_call ef ge vargs' m1' t vres' m2'
/\ external_call ef ge cp vargs' m1' t vres' m2'
/\ Val.lessdef vres vres'
/\ Mem.extends m2 m2'.
Proof.
Expand All @@ -2319,7 +2291,7 @@ Proof.
satisf rs ls e1 /\
exists vargs' vres' m2',
eval_builtin_args ge ls sp m1' args' vargs'
/\ external_call ef ge vargs' m1' t vres' m2'
/\ external_call ef ge cp vargs' m1' t vres' m2'
/\ Val.lessdef vres vres'
/\ Mem.extends m2 m2').
{
Expand Down Expand Up @@ -2428,7 +2400,7 @@ Proof.
destruct (check_function f f0 env) as [] eqn:?; inv H.
unfold check_function in Heqr.
destruct (analyze f env (pair_codes f tf)) as [an|] eqn:?; try discriminate.
destruct eq_compartment as [e|]; try discriminate.
destruct cp_eq_dec as [e|]; try discriminate.
monadInv Heqr.
destruct (check_entrypoints_aux f tf env x) as [y|] eqn:?; try discriminate.
unfold check_entrypoints_aux, pair_entrypoints in Heqo0. MonadInv.
Expand Down Expand Up @@ -2551,9 +2523,9 @@ Qed.

Lemma find_comp_translated:
forall vf,
Genv.find_comp ge vf = Genv.find_comp tge vf.
Genv.find_comp_in_genv ge vf = Genv.find_comp_in_genv tge vf.
Proof.
eapply (Genv.match_genvs_find_comp TRANSF).
eapply (Genv.match_genvs_find_comp_in_genv TRANSF).
Qed.

Lemma exec_moves:
Expand Down Expand Up @@ -2653,15 +2625,15 @@ Inductive match_states: RTL.state -> LTL.state -> Prop :=
match_states (RTL.State s f sp pc rs m)
(LTL.State ts tf sp pc ls m')
| match_states_call:
forall s f args m ts tf ls m'
forall s f args m ts tf ls m' cp
(STACKS: match_stackframes s ts (funsig tf))
(FUN: transf_fundef f = OK tf)
(ARGS: Val.lessdef_list args (map (fun p => Locmap.getpair p ls) (loc_arguments (funsig tf))))
(AG: agree_callee_save (parent_locset ts) ls)
(MEM: Mem.extends m m')
(WTARGS: Val.has_type_list args (sig_args (funsig tf))),
match_states (RTL.Callstate s f args m)
(LTL.Callstate ts tf (funsig tf) ls m')
match_states (RTL.Callstate s f args m cp)
(LTL.Callstate ts tf (funsig tf) ls m' cp)
| match_states_return:
forall s res m ts ls m' sg cp
(STACKS: match_stackframes s ts sg)
Expand Down Expand Up @@ -2864,7 +2836,7 @@ Proof.
exploit eval_addressing_lessdef. eexact LD3.
eapply eval_offset_addressing; eauto; apply Archi.splitlong_ptr32; auto.
intros [a2' [F2 G2]].
assert (LOADX: exists v2'', Mem.loadv Mint32 m' a2' (Some (comp_of f)) = Some v2'' /\ Val.lessdef v2' v2'').
assert (LOADX: exists v2'', Mem.loadv Mint32 m' a2' (comp_of f) = Some v2'' /\ Val.lessdef v2' v2'').
{ discriminate || (eapply Mem.loadv_extends; [eauto|eexact LOAD2|eexact G2]). }
destruct LOADX as (v2'' & LOAD2' & LD4).
set (ls4 := Locmap.set (R dst2') v2'' (undef_regs (destroyed_by_load Mint32 addr2) ls3)).
Expand Down Expand Up @@ -2935,7 +2907,7 @@ Proof.
exploit eval_addressing_lessdef. eexact LD1.
eapply eval_offset_addressing; eauto; apply Archi.splitlong_ptr32; auto.
intros [a1' [F1 G1]].
assert (LOADX: exists v2'', Mem.loadv Mint32 m' a1' (Some (comp_of f)) = Some v2'' /\ Val.lessdef v2' v2'').
assert (LOADX: exists v2'', Mem.loadv Mint32 m' a1' (comp_of f) = Some v2'' /\ Val.lessdef v2' v2'').
{ discriminate || (eapply Mem.loadv_extends; [eauto|eexact LOAD2|eexact G1]). }
destruct LOADX as (v2'' & LOAD2' & LD2).
set (ls2 := Locmap.set (R dst') v2'' (undef_regs (destroyed_by_load Mint32 addr2) ls1)).
Expand Down Expand Up @@ -3173,7 +3145,7 @@ Proof.
}
traceEq. traceEq.
exploit analyze_successors; eauto. simpl. left; eauto. intros [enext [U V]].
rewrite <- SIG.
rewrite <- SIG. rewrite comp_transf_function; eauto.
econstructor; eauto.
{
econstructor; eauto.
Expand Down Expand Up @@ -3210,7 +3182,7 @@ Proof.
rewrite <- comp_transf_function; eauto.
destruct (transf_function_inv _ _ FUN); auto.
eauto. traceEq.
rewrite <- SIG'.
rewrite <- SIG'. rewrite comp_transf_function; eauto.
econstructor; eauto.
eapply match_stackframes_change_sig; eauto. rewrite SIG'. rewrite e0. decEq.
destruct (transf_function_inv _ _ FUN); auto.
Expand All @@ -3234,8 +3206,9 @@ Proof.
eapply star_trans. eexact A1.
eapply star_left. econstructor.
eapply eval_builtin_args_preserved with (ge1 := ge); eauto. exact symbols_preserved.
rewrite <- comp_transf_function; eauto.
eapply external_call_symbols_preserved. apply senv_preserved. eauto.
eauto. rewrite <- comp_transf_function; eauto.
eauto.
eapply star_right. eexact A3.
econstructor.
reflexivity. reflexivity. reflexivity. traceEq.
Expand Down Expand Up @@ -3395,7 +3368,7 @@ Proof.
intros. inv H.
exploit function_ptr_translated; eauto. intros [tf [FIND TR]].
exploit sig_function_translated; eauto. intros SIG.
exists (LTL.Callstate nil tf signature_main (Locmap.init Vundef) m0); split.
exists (LTL.Callstate nil tf signature_main (Locmap.init Vundef) m0 top); split.
econstructor; eauto.
eapply (Genv.init_mem_transf_partial TRANSF); eauto.
rewrite symbols_preserved.
Expand Down Expand Up @@ -3438,6 +3411,7 @@ Proof.
set (ms := fun s s' => wt_state s /\ match_states s s').
eapply forward_simulation_plus with (match_states := ms).
- apply senv_preserved.
- apply senv_preserved.
- intros. exploit initial_states_simulation; eauto. intros [st2 [A B]].
exists st2; split; auto. split; auto.
apply wt_initial_state with (p := prog); auto. exact wt_prog.
Expand Down
18 changes: 9 additions & 9 deletions backend/Asmexpandaux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let emit i = current_code := i :: !current_code

(* Generation of fresh labels *)

let dummy_function = { fn_comp = privileged_compartment; fn_code = []; fn_sig = signature_main }
let dummy_function = { fn_comp = COMP.top; fn_code = []; fn_sig = signature_main }
let current_function = ref dummy_function
let next_label = ref (None: label option)

Expand Down Expand Up @@ -95,10 +95,10 @@ let translate_annot sp preg_to_dwarf annot =
| [] -> None
| a::_ -> aux a)

let builtin_nop cp =
let builtin_nop =
let signature ={sig_args = []; sig_res = Tvoid; sig_cc = cc_default} in
let name = coqstring_of_camlstring "__builtin_nop" in
Pbuiltin(EF_builtin(cp,name,signature),[],BR_none)
Pbuiltin(EF_builtin(name,signature),[],BR_none)

let rec lbl_follows = function
| Pbuiltin (EF_debug _, _, _):: rest ->
Expand All @@ -115,7 +115,7 @@ let expand_debug id sp preg simple l =
| Some lbl -> lbl in
let rec aux lbl scopes = function
| [] -> ()
| (Pbuiltin(EF_debug (_cp,kind,txt,_x),args,_) as i)::rest ->
| (Pbuiltin(EF_debug (kind,txt,_x),args,_) as i)::rest ->
let kind = (P.to_int kind) in
begin
match kind with
Expand Down Expand Up @@ -152,16 +152,16 @@ let expand_debug id sp preg simple l =
| _ ->
aux None scopes rest
end
| (Pbuiltin(EF_annot (cp, kind, _, _),_,_) as annot)::rest ->
| (Pbuiltin(EF_annot (kind, _, _),_,_) as annot)::rest ->
simple annot;
if P.to_int kind = 2 && lbl_follows rest then
simple (builtin_nop cp);
simple (builtin_nop);
aux None scopes rest
| (Plabel lbl)::rest -> simple (Plabel lbl); aux (Some lbl) scopes rest
| i::rest -> simple i; aux None scopes rest in
(* We need to move all closing debug annotations before the last real statement *)
let rec move_debug acc bcc = function
| (Pbuiltin(EF_debug (_cp,kind,_,_),_,_) as i)::rest ->
| (Pbuiltin(EF_debug (kind,_,_),_,_) as i)::rest ->
let kind = (P.to_int kind) in
if kind = 1 then
move_debug acc (i::bcc) rest (* Do not move debug line *)
Expand All @@ -173,10 +173,10 @@ let expand_debug id sp preg simple l =

let expand_simple simple l =
let rec aux = function
| (Pbuiltin(EF_annot (cp, kind, _, _),_,_) as annot)::rest ->
| (Pbuiltin(EF_annot (kind, _, _),_,_) as annot)::rest ->
simple annot;
if P.to_int kind = 2 && lbl_follows rest then
simple (builtin_nop cp);
simple (builtin_nop);
aux rest
| i::rest -> simple i; aux rest
| [] -> () in
Expand Down
4 changes: 2 additions & 2 deletions backend/Asmgenproof0.v
Original file line number Diff line number Diff line change
Expand Up @@ -929,11 +929,11 @@ Lemma exec_straight_steps_1:
forall s c rs m c' rs' m',
exec_straight c rs m c' rs' m' ->
list_length_z (fn_code fn) <= Ptrofs.max_unsigned ->
forall b ofs,
forall b ofs cp,
rs#PC = Vptr b ofs ->
Genv.find_funct_ptr ge b = Some (Internal fn) ->
code_tail (Ptrofs.unsigned ofs) (fn_code fn) c ->
plus step ge (State s rs m) E0 (State s rs' m').
plus step ge (State s rs m cp) E0 (State s rs' m' (comp_of fn)).
Proof.
induction 1; intros.
apply plus_one.
Expand Down
21 changes: 15 additions & 6 deletions backend/CSE.v
Original file line number Diff line number Diff line change
Expand Up @@ -471,16 +471,16 @@ Definition transfer (f: function) (approx: PMap.t VA.t) (pc: node) (before: numb
empty_numbering
| Ibuiltin ef args res s =>
match ef with
| EF_external _ _ _ | EF_runtime _ _ _ | EF_malloc _ | EF_free _ | EF_inline_asm _ _ _ _ =>
| EF_external _ _ | EF_runtime _ _ | EF_malloc | EF_free | EF_inline_asm _ _ _ =>
empty_numbering
| EF_vstore _ _ =>
| EF_vstore _ =>
set_res_unknown (kill_all_loads before) res
| EF_builtin cp name sg =>
match lookup_builtin_function name cp sg with
| EF_builtin name sg =>
match lookup_builtin_function name sg with
| Some bf => set_res_unknown before res
| None => set_res_unknown (kill_all_loads before) res
end
| EF_memcpy _ sz al =>
| EF_memcpy sz al =>
match args with
| dst :: src :: nil =>
let app := approx!!pc in
Expand All @@ -491,7 +491,7 @@ Definition transfer (f: function) (approx: PMap.t VA.t) (pc: node) (before: numb
| _ =>
empty_numbering
end
| EF_vload _ _ | EF_annot _ _ _ _ | EF_annot_val _ _ _ _ | EF_debug _ _ _ _ =>
| EF_vload _ | EF_annot _ _ _ | EF_annot_val _ _ _ | EF_debug _ _ _ =>
set_res_unknown before res
end
| Icond cond args ifso ifnot =>
Expand Down Expand Up @@ -574,6 +574,15 @@ Definition transf_function (rm: romem) (f: function) : res function :=
f.(fn_entrypoint))
end.

#[global] Instance comp_transf_function rm:
has_comp_transl_partial (transf_function rm).
Proof.
unfold transf_function.
intros f ? H.
destruct analyze; try easy.
now inv H.
Qed.

Definition transf_fundef (rm: romem) (f: fundef) : res fundef :=
AST.transf_partial_fundef (transf_function rm) f.

Expand Down
Loading