Commit 132f7e8
authored
[wasm-split] Remove dead globals (WebAssembly#8505)
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 dead
items for other module items (memories, tables, and tags) but it is not
necessary for wasm-split to run, and they can be handled later in DCE.
Fixes
WebAssembly#8442 (comment).1 parent 82c0c99 commit 132f7e8
File tree
4 files changed
+30
-4
lines changed- src/ir
- test
- example
- lit/wasm-split
4 files changed
+30
-4
lines changed| 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 | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
49 | | - | |
50 | 48 | | |
51 | 49 | | |
52 | 50 | | |
| |||
| 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