Commit e87a153
committed
[wasm-split] Remove dead globals
Currently dead module items are not split and just end up remaining in
the primary module. Usually a user runs DCE before or after the
splitting, and the goal of wasm-split is not DCE, so from the
optimization perspective it shouldn't be a problem.
But after WebAssembly#8441, this can be a problem because a dead global's
initializer can refer to another global that is moved to a secondary
module:
```wast
;; Primary
(global.get $dead i32 (global.get $a))
;; Secondary
(global $a i32 (...))
```
This PR just removes those dead globals. We leave it and do some post
processing to make it work but that's more complicated, or we can move
it to the same secondary module but this requires scanning of the
reverse mapping. Removing it seems the simplest. We can remove those
dead items for other module items (memories, tables, and tags) but they
are not necessary for wasm-split to run, and they can be handled later
in DCE.1 parent 4ee183b commit e87a153
3 files changed
Lines changed: 30 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1182 | 1182 | | |
1183 | 1183 | | |
1184 | 1184 | | |
1185 | | - | |
1186 | | - | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
1187 | 1197 | | |
1188 | 1198 | | |
1189 | 1199 | | |
| |||
1213 | 1223 | | |
1214 | 1224 | | |
1215 | 1225 | | |
| 1226 | + | |
1216 | 1227 | | |
1217 | 1228 | | |
1218 | 1229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
56 | 68 | | |
57 | 69 | | |
58 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 | | |
38 | 43 | | |
39 | 44 | | |
| |||
0 commit comments