GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix DWARF line attribution after deleted instructions and Asyncify by cpunion · Pull Request #9194 · WebAssembly/binaryen

Conversation

@cpunion

@cpunion cpunion commented Oct 2, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Depends on #9196, which depends on #9192. Standalone diff. The main-based diff includes these prerequisites and their regenerated DWARF snapshots.

Summary

Fix source attribution when optimization deletes the instruction starting a DWARF row, or Asyncify inserts unwind/rewind code.

Rebuild line tables from the original address intervals and the origins of emitted instructions. Surviving instructions retain their source lines; originless code gets line zero. Track delimiters, including delegate with its variable-length label, and distinguish Asyncify's synthetic terminal end from an ordinary function end.

Output instruction records belong to WasmBinaryWriter. Input origins use the existing expression/delimiter position maps; the original function range remains available for DIE updates. There are no new IR fields or changes to wasm.h.

Validation

  • On 1b07772c: 97 Python tests (14 DWARF), the wasm-opt suite including snapshots, and 437 C++ tests pass; one existing C++ test is skipped.
  • All four delegate cases fail on the preceding head and pass after the fix, covering both writers, multi-byte labels, and roundtripping. Existing regressions cover deleted row-start instructions, writer-generated traps, row markers, and void/value/early-return Asyncify ends.
  • Local V8 execution checks were disabled because the installed d8 is Android's DEX compiler.

Earlier debugger validation used 5f75465a. On that head, a TinyGo O1+Asyncify module grew from 2,146,432 to 2,459,732 bytes including DWARF, while stripped outputs were byte-identical. Those measurements have not been repeated on the current head.

This changes line attribution; it does not reindex locals or generate helper DIEs, and does not fully resolve tinygo-org/tinygo#5736.

Original contribution, developed with AI assistance.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cpunion added 2 commits October 2, 2026 11:04
@cpunion
Preserve DWARF line-zero rows
0cb3245
@cpunion
Update DWARF snapshots for preserved line-zero rows
885be9e
@cpunion
cpunion requested a review from a team as a code owner October 2, 2026 04:20
@cpunion
cpunion requested review from tlively and removed request for a team October 2, 2026 04:20
cpunion added 4 commits October 2, 2026 15:20
@cpunion
Correct and compact DWARF line-program encoding
a2a4a1d
@cpunion
Regenerate snapshots for compact DWARF line encoding
b59bd3d
@cpunion
Preserve instruction origins in rewritten DWARF line tables
3642dcd
@cpunion
Regenerate snapshots for instruction origin tracking
ebbd3ff
@cpunion cpunion mentioned this pull request Oct 2, 2026
Correct and compact DWARF line-program encoding #9196
Open
@cpunion
cpunion force-pushed the codex/asyncify-dwarf-generated-code branch from c693cda to ebbd3ff Compare October 2, 2026 07:28
@cpunion cpunion mentioned this pull request Oct 2, 2026
Preserve DWARF line-zero rows #9192
Open
@tlively

tlively commented Oct 2, 2026

Copy link
Copy Markdown
Member

@kripken, do you have more context for this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kripken

kripken commented Oct 2, 2026

Copy link
Copy Markdown
Member

No, I have no more context here.

@cpunion it would be good to clarify what is fixed here with a small example.

Also the overview could be more specific: "Preserve instruction origins in rewritten DWARF line tables" is something we were already doing, or at least trying to.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tlively

tlively commented Oct 2, 2026

Copy link
Copy Markdown
Member

Asyncify's inserted rewind/unwind code must not inherit a neighboring user's source line.

Why is this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cpunion
Keep Asyncify's synthetic function end off source return lines
5f75465
@cpunion cpunion changed the title Preserve instruction origins in rewritten DWARF line tables Fix DWARF line attribution after deleted instructions and Asyncify Oct 3, 2026
@cpunion

cpunion commented Oct 3, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@kripken @tlively I've clarified the title and narrowed the claim. There are two concrete problems.

1. Deleting a row's first instruction loses a surviving instruction's location. Consider these instructions with the indicated input DWARF rows:

nop           ;; line 10 starts here
call $g       ;; still covered by line 10
i32.const 42  ;; line 20 starts here
i32.add

Removing the nop with either command below must leave the call attributed to line 10. On #9196 it loses that attribution; this PR preserves it by treating each input row as an address interval. DCE alone does not remove this nop.

wasm-opt input.wasm --vacuum -g -o output.wasm
wasm-opt input.wasm -O1 -g -o output.wasm

2. Asyncify's unwind machinery can stop on source statements that were not executed. The debugger fixture contains:

__attribute__((noinline)) int f(void) {
  int value = suspend_once(); // line 28
  observed = value;          // line 29
  return value + 42;         // line 30
}

The first call starts unwinding: neither line 29 nor line 30 executes, and Asyncify returns a placeholder. The second call rewinds/resumes, executes both statements, and returns 49. The driver checks those side effects.

Source-level next Before/control Current output (5f75465)
GDB: unwind 28 → 28 → 30 → caller 28 → caller
LLDB: unwind 28 → 30 → 30 → caller 28 → caller
GDB: resumed execution 28 → 29 → 30 → caller 28 → 29 → 30 → caller

The GDB control inherits neighboring source rows and differs only in the line table; every other section is byte-identical. The LLDB baseline is the previous PR head, which still mapped Asyncify's synthetic terminal end to the original return. The current column uses actual rebuilt output. Ordinary function ends retain their locations.

This demonstrates why line 0 helps for these separate unwind/rewind paths, not a rule that all generated instructions must lack source locations. Generated instructions implementing a source operation can legitimately retain its location.

Each trace was repeated three times. The final checks ran with Wasmtime's compilation cache disabled: 6 bounded LLDB runs (three before/after pairs) and 21 complete GDB runs passed, including breakpoints, caller frames and finish. The regression tests cover instruction origins and void/value/early-return function ends with optimization, Stack IR and roundtripping; all 12 new end cases fail before the fix and pass after it.

For the representative TinyGo module, updated module sizes with DWARF are:

Transformation #9196 bytes Current bytes
Roundtrip 1,893,879 1,895,081
O1 1,872,431 1,937,517
O1 + Asyncify 2,146,432 2,459,732

The terminal-end fix removes 1,125 bytes from the previous Asyncify output. Stripped outputs remain byte-identical; Asyncify executable code remains 671,942 bytes. The extra size is debug information, not executable code. Full timing/cost details and validation limits are in the PR body.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cpunion cpunion mentioned this pull request Oct 3, 2026
Preserve DWARF local indices through local reordering #9199
Open
@deadprogram deadprogram mentioned this pull request Oct 8, 2026
compiler: WASM DWARF misses ~40% of code bytes with opts=1 tinygo-org/tinygo#5736
Open
kripken
kripken reviewed Oct 12, 2026
View reviewed changes
Comment thread src/wasm.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

cpunion added 2 commits October 13, 2026 07:29
@cpunion
Keep DWARF writer metadata out of the main IR
db5db49
@cpunion
Preserve delegate instruction origins when rewriting DWARF
1b07772

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kripken kripken kripken left review comments
@tlively tlively Awaiting requested review from tlively tlively was automatically assigned from WebAssembly/binaryen-reviewers

At least 1 approving review is required to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

compiler: WASM DWARF misses ~40% of code bytes with opts=1

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@cpunion @tlively @kripken
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.