This PR sorts the declarations fed into ElimDeadBranches in increasing
size. This can improve performance when we are dealing with a lot of
iterations.
The motivation for this change is as follows. Currently the algorithm
for doing one step of abstract interpretation is:
```
for decl in scc do
interpDecl
if summaryChanged decl then
return true
return false
```
whenever we return true we run another step. Now suppose we are in a
situation where we have an SCC with one big decl in the front and then
`n` small ones afterwards. For each time that the small ones change
their summary, we will re-run analysis of the big one in the front.
Currently the ordering is basically at "random" based on how other
compilers inject things into the SCC. This change ensures the behavior
is consistent and at least somewhat intelligent. By putting the small
declarations first, whenever we trigger a rerun of the loop we bias
analyzing the small declarations first, thus decreasing run time.
Note that this change does not have much effect on the current pipeline
because: We usually construct the SCCs in a way such that small ones
happen to be in front anyways. However, with upcomping changes on
specialization this is about to change.
25 lines
952 B
Text
25 lines
952 B
Text
[Compiler.IR] [result]
|
|
def isSomeWithInstanceNat (x_1 : @& obj) : u8 :=
|
|
let x_2 : usize := 0;
|
|
let x_3 : tobj := Array.uget ◾ x_1 x_2 ◾;
|
|
let x_4 : u8 := MyOption.isSomeWithInstance._at_.isSomeWithInstanceNat.spec_0 x_3;
|
|
dec x_3;
|
|
ret x_4
|
|
def MyOption.isSomeWithInstance._at_.isSomeWithInstanceNat.spec_0 (x_1 : @& tobj) : u8 :=
|
|
case x_1 : tobj of
|
|
MyOption.none →
|
|
let x_2 : u8 := 0;
|
|
ret x_2
|
|
MyOption.some →
|
|
let x_3 : u8 := 1;
|
|
ret x_3
|
|
def isSomeWithInstanceNat._boxed (x_1 : obj) : tagged :=
|
|
let x_2 : u8 := isSomeWithInstanceNat x_1;
|
|
dec x_1;
|
|
let x_3 : tobj := box x_2;
|
|
ret x_3
|
|
def MyOption.isSomeWithInstance._at_.isSomeWithInstanceNat.spec_0._boxed (x_1 : tobj) : tagged :=
|
|
let x_2 : u8 := MyOption.isSomeWithInstance._at_.isSomeWithInstanceNat.spec_0 x_1;
|
|
dec x_1;
|
|
let x_3 : tobj := box x_2;
|
|
ret x_3
|