Commit 6f53541
authored
Fix minimal-bundle splitting to avoid infinite loops. (#220)
This PR reworks minimal-bundle logic to be consistent between property
computation and splitting, and overall simpler.
To recap: a "minimal bundle" is an allocation bundle that is as small as
possible. Because RA2 does backtracking, i.e., can kick a bundle out of
an allocation to make way for another, and because it can split, i.e.
create more work for itself, we need to ensure the algorithm "bottoms
out" somewhere to ensure termination. The way we do this is by defining
a "minimal bundle": this is a bundle that cannot be split further. A
minimal bundle is never evicted, and any allocatable input (set of
uses/defs with constraints), when split into minimal bundles, should
result in no conflicts. We thus want to define minimal bundles as
*minimally* as possible so that we have the maximal solving capacity.
For a long time, we defined minimal bundles as those spanning a single
instruction (before- and after- progpoints) -- because we cannot insert
moves in the middle of an instruction. In #214, we updated
minimal-bundle splitting to avoid putting two different unrelated uses
in a single-instruction bundle, beacuse doing so and calling it
"minimal" (unsplittable) can artificially extend the liverange of a use
with a fixed-reg constraint at the before-point into the after-point,
causing an unsolveable conflict. This was triggered by new and tighter
constraints on callsites in Cranelift after
bytecodealliance/wasmtime#10502 (merging retval defs into calls) landed.
Unfortunately this also resulted in an infinite allocation loop, because
the definition of "minimal bundle" did not agree between the
split-into-minimal-bundles fallback/last-ditch code, and the bundle
property computation. The splitter was splitting as far as it was
willing to go, but our predicate didn't consider those bundles minimal,
so we continued to re-attempt splitting indefinitely.
While investigating this, I found that the minimal-bundle concept had
accumulated significant cruft ("the detritus of dead fuzzbugs") and this
tech-debt was making things more confusing than not -- so I started by
clearly defining what a minimal bundle *is*. Precisely:
- A single use, within a single LiveRange;
- With that LiveRange having a program-point span consistent with the
use:
- Early def: whole instruction (must live past Late point so it can
reach its uses; moves not possible within inst);
- Late def: Late point only;
- Early use: Early point only;
- Late use: whole instruction (must be live starting at Early so the
value can reach this use; moves not possible within inst).
This is made easier and simpler than what we have before largely because
the minimal-bundle splitter aggressively puts spans of LiveRange without
uses into the spill bundle, and because we support overlapping
LiveRanges for a vreg now (thanks Trevor!), so we can rely on having
*some* connectivity between the def and its uses even if we aggressively
trim LiveRanges in the minimal bundles down to just their defs/uses.
The split-at-program-point splitter (i.e., not the fallback
split-into-minimal-bundles splitter) also got a small fix related to
this: it has a mode that was intended to "split off one use" if we enter
with a split-point at the start of the bundle, but this was really
splitting off all uses at the program point (if there are multiple of
the same vreg at the same program point). In the case that we still need
to split these apart, this just falls back to the minimal-bundle
splitter now.
Fixes #218, #219.1 parent f90a03b commit 6f53541
2 files changed
+82
-84
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
100 | 103 | | |
101 | 104 | | |
102 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
304 | 312 | | |
305 | 313 | | |
306 | 314 | | |
| |||
430 | 438 | | |
431 | 439 | | |
432 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
433 | 457 | | |
434 | | - | |
435 | | - | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
436 | 461 | | |
437 | 462 | | |
438 | 463 | | |
| |||
762 | 787 | | |
763 | 788 | | |
764 | 789 | | |
765 | | - | |
| 790 | + | |
766 | 791 | | |
767 | 792 | | |
768 | 793 | | |
| |||
804 | 829 | | |
805 | 830 | | |
806 | 831 | | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
812 | 832 | | |
813 | 833 | | |
814 | 834 | | |
815 | 835 | | |
816 | | - | |
817 | | - | |
818 | 836 | | |
819 | 837 | | |
820 | 838 | | |
| |||
825 | 843 | | |
826 | 844 | | |
827 | 845 | | |
828 | | - | |
829 | 846 | | |
830 | 847 | | |
831 | | - | |
| 848 | + | |
832 | 849 | | |
833 | 850 | | |
834 | 851 | | |
| |||
848 | 865 | | |
849 | 866 | | |
850 | 867 | | |
851 | | - | |
852 | | - | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
853 | 872 | | |
854 | 873 | | |
855 | 874 | | |
856 | 875 | | |
857 | 876 | | |
858 | | - | |
859 | | - | |
860 | | - | |
861 | | - | |
862 | | - | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | | - | |
902 | | - | |
903 | | - | |
904 | | - | |
905 | | - | |
906 | | - | |
907 | | - | |
908 | | - | |
909 | | - | |
910 | | - | |
| 877 | + | |
| 878 | + | |
911 | 879 | | |
912 | 880 | | |
913 | 881 | | |
| |||
936 | 904 | | |
937 | 905 | | |
938 | 906 | | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | 907 | | |
947 | 908 | | |
948 | 909 | | |
| |||
1363 | 1324 | | |
1364 | 1325 | | |
1365 | 1326 | | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
0 commit comments