-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasm-merge: Sort globals to ensure proper validation (#6221)
If the first module has a global that reads from a global that appears in a later module, then we need to reorder the globals, because if we just append the globals from the later module we'd end up with a global reading from another that is not before it. Changes to the existing renamings test are just due to the global sorting pass that now runs (it not only fixes up validation errors but also tries to sort in a more optimal order for size). Fixes #6220
- Loading branch information
Showing
5 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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,30 @@ | ||
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | ||
|
||
;; RUN: wasm-merge %s first %s.second second -all -S -o - | filecheck %s | ||
|
||
;; After the merge this module's global will read a value from a global that is | ||
;; appended after it, from the second module. Those must be reordered so that | ||
;; we validate, as a global can only read from previous ones. | ||
|
||
(module | ||
(import "second" "second.global.export" (global i32)) | ||
|
||
;; CHECK: (type $0 (func (result i32))) | ||
|
||
;; CHECK: (global $second.global i32 (i32.const 42)) | ||
|
||
;; CHECK: (global $first.global (mut i32) (global.get $second.global)) | ||
(global $first.global (mut i32) (global.get 0)) | ||
|
||
;; CHECK: (export "run" (func $run)) | ||
|
||
;; CHECK: (export "second.global.export" (global $second.global)) | ||
|
||
;; CHECK: (func $run (type $0) (result i32) | ||
;; CHECK-NEXT: (global.get $first.global) | ||
;; CHECK-NEXT: ) | ||
(func $run (export "run") (result i32) | ||
;; Use the global to avoid it being removed. | ||
(global.get $first.global) | ||
) | ||
) |
This file contains 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,3 @@ | ||
(module | ||
(global $second.global (export "second.global.export") i32 (i32.const 42)) | ||
) |
This file contains 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