Commit b84d351
committed
cranelift: fix cubic compile time for modules with many allocating globals
The alias-analysis worklist is drained LIFO, which redoes the whole tail of the
function each time it comes back to the other side of a branch, so a long chain
of diamonds -- a Wasm module's initializer for N allocating globals, say --
visits each block O(N) times and walks O(N) alias regions per visit. Reverse
postorder converges in a single pass instead. For N=2000, compiling goes from
67.0s to 0.22s.
The pass is still quadratic in the number of alias regions; that is left for a
separate change. Visit order also affects precision, hence the disas test update.
Refs bytecodealliance#14210
Assisted-by: Claude Code:claude-opus-51 parent 0ac37df commit b84d351
2 files changed
Lines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
708 | 709 | | |
709 | 710 | | |
710 | 711 | | |
711 | | - | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
712 | 721 | | |
713 | 722 | | |
714 | | - | |
| 723 | + | |
715 | 724 | | |
716 | 725 | | |
717 | | - | |
| 726 | + | |
718 | 727 | | |
719 | 728 | | |
720 | 729 | | |
| |||
747 | 756 | | |
748 | 757 | | |
749 | 758 | | |
750 | | - | |
| 759 | + | |
751 | 760 | | |
752 | 761 | | |
753 | 762 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | 110 | | |
113 | 111 | | |
114 | 112 | | |
| |||
0 commit comments