-
Notifications
You must be signed in to change notification settings - Fork 864
[wasm-split] Remove unnecessary global exports #8832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aheejin
merged 13 commits into
WebAssembly:main
from
aheejin:wasm_split_global_transitive_fix
Jun 16, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6d4b1aa
[wasm-split] Remove unnecessary global exports
aheejin 27041c2
clang-format
aheejin 5dea293
Apply suggestions from code review
aheejin e1248fc
Merge branch 'main' into wasm_split_global_transitive_fix
aheejin 0957b7b
Remove an unnecessary include
aheejin 8558f24
Remove remaining usage of users
aheejin c75f24d
Fix a compilation error
aheejin 0b3f7b4
More use of if (UsedNames* owner = ...)
aheejin b490f2a
Improve comments
aheejin 7aacfd7
Merge branch 'main' into wasm_split_global_transitive_fix
aheejin 407072c
Fix transitive global scanning
aheejin 89124ee
Fix comment
aheejin 3cfa538
Remove unnecessary include
aheejin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | ||
| ;; RUN: wasm-split %s -all -g -o1 %t.1.wasm -o2 %t.2.wasm --keep-funcs=keep | ||
| ;; RUN: wasm-dis %t.1.wasm | filecheck %s --check-prefix PRIMARY | ||
| ;; RUN: wasm-dis %t.2.wasm | filecheck %s --check-prefix SECONDARY | ||
|
|
||
| (module | ||
| ;; PRIMARY: (type $0 (func)) | ||
|
|
||
| ;; PRIMARY: (import "env" "g" (global $g funcref)) | ||
| (import "env" "g" (global $g funcref)) | ||
|
|
||
| ;; A table used by both $keep and $split. | ||
| ;; The table stays in PRIMARY. $g should stay in PRIMARY and NOT be | ||
| ;; exported/imported. | ||
| ;; PRIMARY: (table $t 1 1 funcref (global.get $g)) | ||
| (table $t 1 1 funcref (global.get $g)) | ||
|
|
||
| ;; PRIMARY: (export "table" (table $t)) | ||
|
|
||
| ;; PRIMARY: (func $keep | ||
| ;; PRIMARY-NEXT: (drop | ||
| ;; PRIMARY-NEXT: (table.get $t | ||
| ;; PRIMARY-NEXT: (i32.const 0) | ||
| ;; PRIMARY-NEXT: ) | ||
| ;; PRIMARY-NEXT: ) | ||
| ;; PRIMARY-NEXT: ) | ||
| (func $keep | ||
| (drop | ||
| (table.get $t | ||
| (i32.const 0) | ||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| ;; SECONDARY: (type $0 (func)) | ||
|
|
||
| ;; SECONDARY: (import "primary" "table" (table $t 1 1 funcref)) | ||
|
|
||
| ;; SECONDARY: (func $split | ||
| ;; SECONDARY-NEXT: (drop | ||
| ;; SECONDARY-NEXT: (table.get $t | ||
| ;; SECONDARY-NEXT: (i32.const 0) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) | ||
| (func $split | ||
| (drop | ||
| (table.get $t | ||
| (i32.const 0) | ||
| ) | ||
| ) | ||
| ) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | ||
| ;; RUN: wasm-split -all -g --multi-split %s --manifest %s.manifest --out-prefix=%t -o %t.wasm | ||
| ;; RUN: wasm-dis %t.wasm | filecheck %s --check-prefix PRIMARY | ||
| ;; RUN: wasm-dis %t1.wasm | filecheck %s --check-prefix SECONDARY1 | ||
| ;; RUN: wasm-dis %t2.wasm | filecheck %s --check-prefix SECONDARY2 | ||
|
|
||
| ;; Because global $e is used in both module1 ($split1) and module2 ($split2), $e | ||
| ;; will be exported / imported, but we don't need to export $f. | ||
|
|
||
| (module | ||
| ;; PRIMARY: (type $0 (func)) | ||
|
|
||
| ;; PRIMARY: (global $f i32 (i32.const 42)) | ||
| (global $f i32 (i32.const 42)) | ||
| ;; PRIMARY: (global $e i32 (global.get $f)) | ||
| (global $e i32 (global.get $f)) | ||
|
|
||
| ;; PRIMARY: (export "global" (global $e)) | ||
|
|
||
| ;; PRIMARY: (func $keep | ||
| ;; PRIMARY-NEXT: (nop) | ||
| ;; PRIMARY-NEXT: ) | ||
| (func $keep | ||
| (nop) | ||
| ) | ||
|
|
||
| ;; SECONDARY1: (type $0 (func)) | ||
|
|
||
| ;; SECONDARY1: (import "primary" "global" (global $e i32)) | ||
|
|
||
| ;; SECONDARY1: (func $split1 | ||
| ;; SECONDARY1-NEXT: (drop | ||
| ;; SECONDARY1-NEXT: (global.get $e) | ||
| ;; SECONDARY1-NEXT: ) | ||
| ;; SECONDARY1-NEXT: ) | ||
| (func $split1 | ||
| (drop (global.get $e)) | ||
| ) | ||
|
|
||
| ;; SECONDARY2: (type $0 (func)) | ||
|
|
||
| ;; SECONDARY2: (import "primary" "global" (global $e i32)) | ||
|
|
||
| ;; SECONDARY2: (func $split2 | ||
| ;; SECONDARY2-NEXT: (drop | ||
| ;; SECONDARY2-NEXT: (global.get $e) | ||
| ;; SECONDARY2-NEXT: ) | ||
| ;; SECONDARY2-NEXT: ) | ||
| (func $split2 | ||
| (drop (global.get $e)) | ||
| ) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| 1: | ||
| split1 | ||
|
|
||
| 2: | ||
| split2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| ;; RUN: wasm-split %s -all -g -o1 %t.1.wasm -o2 %t.2.wasm --split-funcs=split | ||
| ;; RUN: wasm-dis -all %t.1.wasm | filecheck %s --check-prefix PRIMARY | ||
| ;; RUN: wasm-dis -all %t.2.wasm | filecheck %s --check-prefix SECONDARY | ||
|
|
||
| ;; The dependence chain is $g4->$g3->$g2->$g1, and because $g4 is used in the | ||
| ;; primary module, all four globals should end up in the primary module. Only | ||
| ;; $g2 needs to be exported to the secondary module, not $g1. | ||
|
|
||
| (module | ||
| (global $g1 i32 (i32.const 42)) | ||
| (global $g2 i32 (global.get $g1)) | ||
| (global $g3 i32 (global.get $g2)) | ||
| (global $g4 i32 (global.get $g3)) | ||
|
|
||
| (func $keep | ||
| (drop (global.get $g4)) | ||
| ) | ||
|
|
||
| (func $split | ||
| (drop (global.get $g2)) | ||
| ) | ||
| ) | ||
|
|
||
| ;; PRIMARY: (module | ||
| ;; PRIMARY-NEXT: (type $0 (func)) | ||
| ;; PRIMARY-NEXT: (global $g1 i32 (i32.const 42)) | ||
| ;; PRIMARY-NEXT: (global $g2 i32 (global.get $g1)) | ||
| ;; PRIMARY-NEXT: (global $g3 i32 (global.get $g2)) | ||
| ;; PRIMARY-NEXT: (global $g4 i32 (global.get $g3)) | ||
| ;; PRIMARY-NEXT: (export "global" (global $g2)) | ||
| ;; PRIMARY-NEXT: (func $keep (type $0) | ||
| ;; PRIMARY-NEXT: (drop | ||
| ;; PRIMARY-NEXT: (global.get $g4) | ||
| ;; PRIMARY-NEXT: ) | ||
| ;; PRIMARY-NEXT: ) | ||
| ;; PRIMARY-NEXT: ) | ||
|
|
||
| ;; SECONDARY: (module | ||
| ;; SECONDARY-NEXT: (type $0 (func)) | ||
| ;; SECONDARY-NEXT: (import "primary" "global" (global $g2 i32)) | ||
| ;; SECONDARY-NEXT: (func $split (type $0) | ||
| ;; SECONDARY-NEXT: (drop | ||
| ;; SECONDARY-NEXT: (global.get $g2) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) | ||
| ;; SECONDARY-NEXT: ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.