Skip to content

Commit

Permalink
Merge pull request #520 from AbsInt/value-analysis-IU
Browse files Browse the repository at this point in the history
More precise value analysis for "known integer or Vundef" results
  • Loading branch information
xavierleroy committed Aug 22, 2024
2 parents af83e9a + f3f1dc2 commit d351f4b
Show file tree
Hide file tree
Showing 11 changed files with 175 additions and 69 deletions.
2 changes: 1 addition & 1 deletion aarch64/ConstpropOp.vp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Require SelectOp.

Definition const_for_result (a: aval) : option operation :=
match a with
| I n => Some(Ointconst n)
| I n | IU n => Some(Ointconst n)
| L n => Some(Olongconst n)
| F n => if Compopts.generate_float_constants tt then Some(Ofloatconst n) else None
| FS n => if Compopts.generate_float_constants tt then Some(Osingleconst n) else None
Expand Down
2 changes: 2 additions & 0 deletions aarch64/ConstpropOpproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ Proof.
unfold const_for_result; intros; destruct a; inv H; SimplVM.
- (* integer *)
exists (Vint n); auto.
- (* integer or undef *)
exists (Vint n); split; auto. inv H0; auto.
- (* long *)
exists (Vlong n); auto.
- (* float *)
Expand Down
2 changes: 1 addition & 1 deletion arm/ConstpropOp.vp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Require Import ValueDomain ValueAOp.

Definition const_for_result (a: aval) : option operation :=
match a with
| I n => Some(Ointconst n)
| I n | IU n => Some(Ointconst n)
| F n => if Compopts.generate_float_constants tt then Some(Ofloatconst n) else None
| FS n => if Compopts.generate_float_constants tt then Some(Osingleconst n) else None
| Ptr(Gl id ofs) => Some (Oaddrsymbol id ofs)
Expand Down
2 changes: 2 additions & 0 deletions arm/ConstpropOpproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ Proof.
destruct a; inv H; SimplVM.
- (* integer *)
exists (Vint n); auto.
- (* integer or undef *)
exists (Vint n); split; auto. inv H0; auto.
- (* float *)
destruct (generate_float_constants tt); inv H2. exists (Vfloat f); auto.
- (* single *)
Expand Down
224 changes: 160 additions & 64 deletions backend/ValueDomain.v

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion powerpc/ConstpropOp.vp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Require Import ValueDomain ValueAOp.

Definition const_for_result (a: aval) : option operation :=
match a with
| I n => Some(Ointconst n)
| I n | IU n => Some(Ointconst n)
| L n => if Archi.ppc64 then Some (Olongconst n) else None
| F n => if Compopts.generate_float_constants tt then Some(Ofloatconst n) else None
| FS n => if Compopts.generate_float_constants tt then Some(Osingleconst n) else None
Expand Down
2 changes: 2 additions & 0 deletions powerpc/ConstpropOpproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ Proof.
destruct a; inv H; SimplVM.
- (* integer *)
exists (Vint n); auto.
- (* integer or undef *)
exists (Vint n); split; auto. inv H0; auto.
- (* long *)
destruct (Archi.ppc64); inv H2. exists (Vlong n); auto.
- (* float *)
Expand Down
2 changes: 1 addition & 1 deletion riscV/ConstpropOp.vp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Require Import ValueDomain.

Definition const_for_result (a: aval) : option operation :=
match a with
| I n => Some(Ointconst n)
| I n | IU n => Some(Ointconst n)
| L n => if Archi.ptr64 then Some(Olongconst n) else None
| F n => if Compopts.generate_float_constants tt then Some(Ofloatconst n) else None
| FS n => if Compopts.generate_float_constants tt then Some(Osingleconst n) else None
Expand Down
2 changes: 2 additions & 0 deletions riscV/ConstpropOpproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Proof.
destruct a; inv H; SimplVM.
- (* integer *)
exists (Vint n); auto.
- (* integer or undef *)
exists (Vint n); split; auto. inv H0; auto.
- (* long *)
destruct ptr64; inv H2. exists (Vlong n); auto.
- (* float *)
Expand Down
2 changes: 1 addition & 1 deletion x86/ConstpropOp.vp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Definition Olea_ptr (a: addressing) := if Archi.ptr64 then Oleal a else Olea a.

Definition const_for_result (a: aval) : option operation :=
match a with
| I n => Some(Ointconst n)
| I n | IU n => Some(Ointconst n)
| L n => if Archi.ptr64 then Some(Olongconst n) else None
| F n => if Compopts.generate_float_constants tt then Some(Ofloatconst n) else None
| FS n => if Compopts.generate_float_constants tt then Some(Osingleconst n) else None
Expand Down
2 changes: 2 additions & 0 deletions x86/ConstpropOpproof.v
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ Proof.
destruct a; inv H; SimplVM.
- (* integer *)
exists (Vint n); auto.
- (* integer or undef *)
exists (Vint n); split; auto. inv H0; auto.
- (* long *)
destruct ptr64; inv H2. exists (Vlong n); auto.
- (* float *)
Expand Down

0 comments on commit d351f4b

Please sign in to comment.