GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Preserve DWARF local indices through local reordering by cpunion · Pull Request #9199 · WebAssembly/binaryen Conversation
|
| Check | Before | After |
|---|---|---|
GDB / LLDB: a, b, c |
22, 11, 33 |
11, 22, 33 |
| Program result | 66 |
66 |
| Deleted local | Can point at an unrelated surviving local | Unavailable |
The interactive comparison includes #9194 on both sides to separate this bug from the independent line-table problems. This PR is based directly on main (5e56913e); its automated regression tests need no other PR.
Compose input-to-IR local mappings across reordering and coalescing, then apply the writer's final binary-local mapping to DWARF locations. This also handles the coalescing performed internally by Asyncify. Coalescing's existing DWARF-invalidating status remains: repairing indices does not repair changed variable live ranges.
Rewrite inline expressions and location lists, including shared suffixes, nested expressions and expression-level DIE/type references. If an operand grows across a LEB boundary, relocate the affected list offsets, DIE references, CU lengths and public-name tables. Collection, expression/layout relocation and public-table updates are separate stages. The common same-width case skips the .debug_info layout pass; expressions without DIE references are not decoded again on subsequent iterations. Instruction boundaries use a small ordered vector instead of per-instruction hash allocations. No optimization is disabled.
d8 is not V8. The full build and these automated checks were rerun after rebasing onto current main on November 12.{"name":"dwarf","value":42}. GDB on Linux arm64 and LLDB on macOS arm64 read the correct values in the combined verification above.TinyGo sample on the original main baseline (82439ad0), seven alternating warmed runs on macOS arm64; timings are medians, not evidence of a speedup:
| Configuration | Output bytes, before → after | wasm-opt time, before → after |
|---|---|---|
| O1 + Asyncify, no debug | 1,791,971 → 1,791,971 | 727.4 → 730.6 ms |
| O1, debug | 1,912,371 → 1,912,371 | 353.0 → 362.6 ms |
| O1 + Asyncify, debug | 2,185,951 → 2,185,947 | 924.5 → 884.0 ms |
Stripped outputs are byte-identical in all three configurations. This fixes local-index relocation, not all remaining DWARF limitations or variable live-range transformations.
Developed with AI assistance; the validation above was executed locally.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
bb1bd09 to
abfeadc
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I'll remove myself as a reviewer because I won't be able to review this effectively due to lack of DWARF expertise. As an alternative approach, you could skip passes that reorder locals, e.g. with --skip-pass=coalesce-locals.
I've left some notes below about bugs Gemini found, though.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| } | ||
|
|
||
| static bool isLocationList(llvm::dwarf::Attribute attr, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't be defining static functions in a header. Can all the implementation here be moved to wasm-debug.cpp or a new .cpp file?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| LocationUpdater locationUpdater(wasm, newLocations); | ||
|
|
||
| DwarfLocalRewriter(wasm, data, *info.context, newLocations).run(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Gemini claims it is a bug to run this before updateCompileUnits below. updateCompileUnits updates AddrSize after Memory64Lowering, and I guess DwarfLocalRewriter should run after that update.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (!op.extract( | ||
| bytes, unit->getVersion(), unit->getAddressByteSize(), start) || | ||
| op.getEndOffset() > input.size()) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Gemini claims this does not handle truncated DWARF expression operands. op.extract will return true in this case. I don't know how important that is to handle.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.