philipc opened PR #12428 from philipc:transform to bytecodealliance:main:
Replace parts of the transform code with
gimli's generic DWARF transformation support. Most of the remaining code is specific to the needs of Wasmtime.This change relates to #5537. While this PR provides some small improvements, it doesn't fundamentally change the quality of the transformed DWARF. The primary benefit is simply less code in Wasmtime.
The overall behaviour is the same as the previous implementation. We build a graph of the DIE dependencies, and prune DIEs that don't have valid code ranges. Then we traverse the DIE tree again and transform the DIEs. However, there are some differences.
Previously, unresolved references to DIEs were stored in
PendingUnitRefsandPendingDebugInfoRefs, then at the end of the transformation we went back and fixed up these references. The new behaviour reserves IDs for all of the DIEs in the dependency tree before transformation, which avoids the need to fix up references later. It also allows gimli to correctly handle references in DWARF expressions, although that doesn't currently matter for Wasmtime because it doesn't handle references in expressions yet. The visible effect of this in Wasmtime is that the order of transformed attributes will now always match the original DWARF.The DIE tree pruning is slightly different. We no longer add back-edges pointing to namespace DIEs or the root DIE, which previously caused some DIEs to be reachable when they should not have been. In particular, this affects DW_TAG_variable DIEs for global variables. Wasmtime can't currently translate the location for globals, so they were added without a valid DW_AT_location. These DIEs are now omitted from the transformed DWARF. In the future when global variables can be translated correctly, they can be included by calling
ReserveUnitSection::require_entry.Performance measurements for
wasmtime compile -D debug-info=yshow minimal change.
philipc requested wasmtime-compiler-reviewers for a review on PR #12428.
philipc requested fitzgen for a review on PR #12428.
fitzgen submitted PR review:
Fantastic, thanks so much!
fitzgen created PR review comment:
Nice to see this parameter list getting smaller!
fitzgen commented on PR #12428:
Going to wait until https://www.githubstatus.com/incidents/90hj03y5tj3c is resolved before adding this to the merge queue.
alexcrichton added PR #12428 Use gimli::write::Dwarf::convert_with_filter for DWARF transform to the merge queue.
alexcrichton merged PR #12428.
alexcrichton removed PR #12428 Use gimli::write::Dwarf::convert_with_filter for DWARF transform from the merge queue.
Last updated: Jan 29 2026 at 13:25 UTC