- Notifications
You must be signed in to change notification settings - Fork 825
MemoryPacking: Handle non-empty trapping segments #6261
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
Merged
Changes from 5 commits
Commits
Show all changes
13 commits Select commit Hold shift + click to select a range
b0bec8f start
kripken a1cf59b test
kripken 5eff14b work
kripken 66bf12a work
kripken dd924ab test
kripken adce58c fix test, check prefix cannot start with _
kripken ce57873 Merge remote-tracking branch 'origin/main' into mp.overflow
kripken 784978c feedback: name test items
kripken 35ef883 cleaner
kripken 08c442e change
kripken 0edcf1b finish
kripken 4aec05b format
kripken 0a24de7 cleanup
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 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,96 @@ | ||
| ;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. | ||
| | ||
| ;; RUN: foreach %s %t wasm-opt --memory-packing -all --zero-filled-memory -S -o - | filecheck %s | ||
| ;; RUN: foreach %s %t wasm-opt --memory-packing -all --zero-filled-memory -tnh -S -o - | filecheck %s --check-prefix=_TNH_ | ||
| | ||
| (module | ||
| ;; We should not optimize out a segment that will trap, as that is an effect | ||
| ;; we need to preserve (unless TrapsNeverHappen). | ||
| (memory 1 2 shared) | ||
| (data (i32.const -1) "\00") | ||
| ) | ||
| | ||
| ;; CHECK: (memory $0 1 2 shared) | ||
| | ||
| ;; CHECK: (data $0 (i32.const -1) "\00") | ||
| | ||
| ;; _TNH_: (memory $0 1 2 shared) | ||
| (module | ||
| ;; We should handle the possible overflow in adding the offset and size, and | ||
| ;; see this might trap. | ||
| (memory 1 2 shared) | ||
| (data (i32.const -2) "\00\00\00") | ||
| ) | ||
| | ||
| ;; CHECK: (memory $0 1 2 shared) | ||
| | ||
| ;; CHECK: (data $0 (i32.const -2) "\00\00\00") | ||
| | ||
| ;; _TNH_: (memory $0 1 2 shared) | ||
| (module | ||
| ;; This segment will almost trap, but not. | ||
| (memory 1 2 shared) | ||
| (data (i32.const 65535) "\00") | ||
| ) | ||
| | ||
| ;; CHECK: (memory $0 1 2 shared) | ||
| | ||
| ;; _TNH_: (memory $0 1 2 shared) | ||
| (module | ||
| ;; This one is slightly larger, and will trap. | ||
| (memory 1 2 shared) | ||
| (data (i32.const 65535) "\00\00") | ||
| ) | ||
| | ||
| ;; CHECK: (memory $0 1 2 shared) | ||
| | ||
| ;; CHECK: (data $0 (i32.const 65535) "\00\00") | ||
| | ||
| ;; _TNH_: (memory $0 1 2 shared) | ||
| (module | ||
| ;; This one is slightly larger, but the offset is lower so it will not trap. | ||
| (memory 1 2 shared) | ||
| (data (i32.const 65534) "\00\00") | ||
| ) | ||
| | ||
| ;; CHECK: (memory $0 1 2 shared) | ||
| | ||
| ;; _TNH_: (memory $0 1 2 shared) | ||
| (module | ||
| ;; This one's offset is just large enough to trap. | ||
| (memory 1 2 shared) | ||
| (data (i32.const 65536) "\00") | ||
| ) | ||
| | ||
| ;; CHECK: (memory $0 1 2 shared) | ||
| | ||
| ;; CHECK: (data $0 (i32.const 65536) "\00") | ||
| | ||
| ;; _TNH_: (memory $0 1 2 shared) | ||
| (module | ||
| ;; This offset is unknown, so assume the worst. | ||
| ;; TODO: We could remove it in TNH mode | ||
| | ||
| ;; CHECK: (import "a" "b" (global $g i32)) | ||
| ;; _TNH_: (import "a" "b" (global $g i32)) | ||
| (import "a" "b" (global $g i32)) | ||
| (memory 1 2 shared) | ||
| (data (global.get $g) "\00") | ||
| ) | ||
| | ||
| ;; CHECK: (memory $0 1 2 shared) | ||
| | ||
| ;; CHECK: (data $0 (global.get $g) "\00") | ||
| | ||
| ;; _TNH_: (memory $0 1 2 shared) | ||
| | ||
| ;; _TNH_: (data $0 (global.get $g) "\00") | ||
| (module | ||
| ;; Passive segments cannot trap during startup and are removable if they have | ||
| ;; no uses, like here. | ||
| (memory 1 2 shared) | ||
| (data $data "\00\00\00") | ||
| ) | ||
| ;; CHECK: (memory $0 1 2 shared) | ||
| | ||
| ;; _TNH_: (memory $0 1 2 shared) | ||
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.
You can give these names to make the output more readable.