-
Notifications
You must be signed in to change notification settings - Fork 745
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
SimplifyGlobals: Apply constant globals to segment offsets #6226
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f8dded8
prep
kripken 69d101c
work
kripken 05e191b
work
kripken f161132
comment
kripken 06ccc63
finish
kripken 3076303
Merge remote-tracking branch 'origin/main' into rume.ginits
kripken 961b83f
feedback
kripken 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 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,78 @@ | ||
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | ||
;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up. | ||
|
||
;; RUN: foreach %s %t wasm-opt --simplify-globals -all -S -o - | filecheck %s | ||
|
||
;; Apply constant globals to segment offsets. The non-imported global.gets will | ||
;; be applied in the segments named $use-defined. | ||
|
||
(module | ||
;; CHECK: (type $0 (func)) | ||
|
||
;; CHECK: (import "env" "memory" (memory $memory 256)) | ||
(import "env" "memory" (memory $memory 256)) | ||
|
||
;; CHECK: (import "env" "table" (table $table 0 funcref)) | ||
(import "env" "table" (table $table 0 funcref)) | ||
|
||
;; CHECK: (import "env" "imported" (global $imported i32)) | ||
(import "env" "imported" (global $imported i32)) | ||
|
||
;; CHECK: (global $defined i32 (i32.const 42)) | ||
(global $defined i32 (i32.const 42)) | ||
|
||
;; CHECK: (global $use-defined i32 (i32.const 42)) | ||
(global $use-defined i32 (global.get $defined)) | ||
|
||
;; CHECK: (data $use-imported (global.get $imported) "hello, world!") | ||
(data $use-imported (global.get $imported) "hello, world!") | ||
|
||
;; CHECK: (data $use-defined (i32.const 42) "hello, world!") | ||
(data $use-defined (global.get $defined) "hello, world!") | ||
|
||
;; CHECK: (data $dropped "hello, world!") | ||
(data $dropped "hello, world!") | ||
|
||
;; CHECK: (elem $use-imported (global.get $imported) $func) | ||
(elem $use-imported (global.get $imported) $func) | ||
|
||
;; CHECK: (elem $use-defined (i32.const 42) $func $func) | ||
(elem $use-defined (global.get $defined) $func $func) | ||
|
||
;; CHECK: (export "func" (func $func)) | ||
(export "func" (func $func)) | ||
|
||
;; CHECK: (func $func (type $0) | ||
;; CHECK-NEXT: (drop | ||
;; CHECK-NEXT: (i32.load | ||
;; CHECK-NEXT: (i32.const 0) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: (drop | ||
;; CHECK-NEXT: (table.get $table | ||
;; CHECK-NEXT: (i32.const 0) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: (drop | ||
;; CHECK-NEXT: (i32.const 42) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: (data.drop $dropped) | ||
;; CHECK-NEXT: ) | ||
(func $func | ||
;; Use things to avoid DCE. | ||
(drop | ||
(i32.load | ||
(i32.const 0) | ||
) | ||
) | ||
(drop | ||
(table.get $table | ||
(i32.const 0) | ||
) | ||
) | ||
(drop | ||
(global.get $use-defined) | ||
) | ||
Comment on lines
+80
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, done. |
||
(data.drop $dropped) | ||
) | ||
) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this relevant to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a segment without an offset, so the pass has nothing to do there but also it should not error on it (there is a nullptr for the offset). I added a comment to clarify.