-
Notifications
You must be signed in to change notification settings - Fork 816
Source maps: Fix locations without debug info between ones that do #5906
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 all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2caae6a
yolo
kripken 2aa5e06
terrible idea
kripken 8a374c6
Merge remote-tracking branch 'origin/main' into debug.stop
kripken ff78328
work
kripken cb3c821
fix
kripken ae5d506
wek
kripken 65d061c
clean
kripken 0c2b390
end
kripken 57c940b
end
kripken 6cb8056
almost
kripken 77ae0d9
test
kripken ed4c6e7
format
kripken 00955b2
fix
kripken 03b144b
clean
kripken e86e1de
clean
kripken 0c62b40
clean
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
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,122 @@ | ||
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. | ||
|
||
;; RUN: wasm-opt %s -g -o %s.wasm -osm %s.wasm.map | ||
;; RUN: wasm-opt %s.wasm -ism %s.wasm.map -S -o - | filecheck %s | ||
|
||
;; Verify that writing to a source map and reading it back does not "smear" | ||
;; debug info across adjacent instructions. The debug info in the output should | ||
;; be identical to the input. | ||
|
||
(module | ||
;; CHECK: (func $test (param $0 i32) (result i32) | ||
;; CHECK-NEXT: (drop | ||
;; CHECK-NEXT: (call $test | ||
;; CHECK-NEXT: ;;@ waka:100:1 | ||
;; CHECK-NEXT: (i32.const 1) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ;;@ waka:200:2 | ||
;; CHECK-NEXT: (i32.const 2) | ||
;; CHECK-NEXT: ) | ||
(func $test (param i32) (result i32) | ||
;; The drop&call have no debug info, and should remain so. Specifically the | ||
;; instruction right before them in the binary (the const 1) should not | ||
;; smear its debug info on it. And the drop is between an instruction that | ||
;; has debug info (the const 1) and another (the i32.const 2): we should not | ||
;; receive the debug info of either. (This is a regression test for a bug | ||
;; that only happens in that state: removing the debug info either before or | ||
;; after would avoid that bug.) | ||
|
||
(drop | ||
(call $test | ||
;;@ waka:100:1 | ||
(i32.const 1) | ||
) | ||
) | ||
;;@ waka:200:2 | ||
(i32.const 2) | ||
) | ||
|
||
;; CHECK: (func $same-later (param $0 i32) (result i32) | ||
;; CHECK-NEXT: (drop | ||
;; CHECK-NEXT: (call $test | ||
;; CHECK-NEXT: ;;@ waka:100:1 | ||
;; CHECK-NEXT: (i32.const 1) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ;;@ waka:100:1 | ||
;; CHECK-NEXT: (i32.const 2) | ||
;; CHECK-NEXT: ) | ||
(func $same-later (param i32) (result i32) | ||
;; As the first, but now the later debug info is also 100:1. No debug info | ||
;; should change here. | ||
|
||
(drop | ||
(call $test | ||
;;@ waka:100:1 | ||
(i32.const 1) | ||
) | ||
) | ||
;;@ waka:100:1 | ||
(i32.const 2) | ||
) | ||
|
||
;; CHECK: (func $more-before (param $0 i32) (result i32) | ||
;; CHECK-NEXT: ;;@ waka:50:5 | ||
;; CHECK-NEXT: (nop) | ||
;; CHECK-NEXT: ;;@ waka:50:5 | ||
;; CHECK-NEXT: (drop | ||
;; CHECK-NEXT: (call $test | ||
;; CHECK-NEXT: ;;@ waka:100:1 | ||
;; CHECK-NEXT: (i32.const 1) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ;;@ waka:200:2 | ||
;; CHECK-NEXT: (i32.const 2) | ||
;; CHECK-NEXT: ) | ||
(func $more-before (param i32) (result i32) | ||
;; As the first, but now there is more debug info before the 100:1 (the | ||
;; very first debug info in a function has special handling, so we test it | ||
;; more carefully). | ||
;; | ||
;; The s-parser actually smears 50:5 on the drop and call after it, so the | ||
;; output here looks incorrect. This may be a bug there, TODO | ||
|
||
;;@ waka:50:5 | ||
(nop) | ||
(drop | ||
(call $test | ||
;;@ waka:100:1 | ||
(i32.const 1) | ||
) | ||
) | ||
;;@ waka:200:2 | ||
(i32.const 2) | ||
) | ||
|
||
;; CHECK: (func $nothing-before (param $0 i32) (result i32) | ||
;; CHECK-NEXT: (nop) | ||
;; CHECK-NEXT: (drop | ||
;; CHECK-NEXT: (call $test | ||
;; CHECK-NEXT: ;;@ waka:100:1 | ||
;; CHECK-NEXT: (i32.const 1) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ) | ||
;; CHECK-NEXT: ;;@ waka:200:2 | ||
;; CHECK-NEXT: (i32.const 2) | ||
;; CHECK-NEXT: ) | ||
(func $nothing-before (param i32) (result i32) | ||
;; As before, but no debug info on the nop before us (so the first | ||
;; instruction in the function no longer has a debug annotation). Nothing | ||
;; should change in the debug info. | ||
(nop) | ||
(drop | ||
(call $test | ||
;;@ waka:100:1 | ||
(i32.const 1) | ||
) | ||
) | ||
;;@ waka:200:2 | ||
(i32.const 2) | ||
) | ||
) |
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.
This is not new logic - just moved up from below (since we also want it for a 1-length entry).
Uh oh!
There was an error while loading. Please reload this page.
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.
@kripken
Hi Alon,
does this optimization only impact the debug info read process? how about the
BinaryenFunctionSetDebugLocation
API? I think AssemblyScript is using this API for debug info generation, it also have the smeared issue for the shadow stack check.for more detail: AssemblyScript/assemblyscript#2704
CC @dcodeIO @MaxGraey @HerrCai0907
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.
This part of the code, or this PR as a whole?
The PR as a whole affects binary read and write. We now write 1-length segments to prevent smearing, and we read them properly as well.
SetDebugLocation
should still be fine. That sets debug info on a single expression. This PR fixes things in binary reading and writing, which due to smearing would cause things to get debug info when they should not. See the testcase in the PR for an example of a bug that is fixed.