cfallin edited PR #2565 from debug-value-labels
to main
:
This PR propagates "value labels" all the way from CLIF to DWARF
metadata on the emitted machine code. The key idea is as follows:
Translate value-label metadata on the input into "value_label"
pseudo-instructions when lowering into VCode. These
pseudo-instructions take a register as input, denote a value label,
and semantically are like a "move into value label" -- i.e., they
update the current value (as seen by debugging tools) of the given
local. These pseudo-instructions emit no machine code.Perform a dataflow analysis at the machine-code level, tracking
value-labels that propagate into registers and into [SP+constant]
stack storage. This is a forward dataflow fixpoint analysis where each
storage location can contain a set of value labels, and each value
label can reside in a set of storage locations. (Meet function is
pairwise intersection by storage location.)This analysis traces value labels symbolically through loads and
stores and reg-to-reg moves, so it will naturally handle spills and
reloads without knowing anything special about them.When this analysis converges, we have, at each machine-code offset, a
mapping from value labels to some number of storage locations; for
each offset for each label, we choose the best location (prefer
registers). Note that we can choose any location, as the symbolic
dataflow analysis is sound and guarantees that the value at the
value_label instruction propagates to all of the named locations.Then we can convert this mapping into a format that the DWARF
generation code (wasmtime's debug crate) can use.This PR also adds the new-backend variant to the gdb tests on CI.
cfallin updated PR #2565 from debug-value-labels
to main
:
This PR propagates "value labels" all the way from CLIF to DWARF
metadata on the emitted machine code. The key idea is as follows:
Translate value-label metadata on the input into "value_label"
pseudo-instructions when lowering into VCode. These
pseudo-instructions take a register as input, denote a value label,
and semantically are like a "move into value label" -- i.e., they
update the current value (as seen by debugging tools) of the given
local. These pseudo-instructions emit no machine code.Perform a dataflow analysis at the machine-code level, tracking
value-labels that propagate into registers and into [SP+constant]
stack storage. This is a forward dataflow fixpoint analysis where each
storage location can contain a set of value labels, and each value
label can reside in a set of storage locations. (Meet function is
pairwise intersection by storage location.)This analysis traces value labels symbolically through loads and
stores and reg-to-reg moves, so it will naturally handle spills and
reloads without knowing anything special about them.When this analysis converges, we have, at each machine-code offset, a
mapping from value labels to some number of storage locations; for
each offset for each label, we choose the best location (prefer
registers). Note that we can choose any location, as the symbolic
dataflow analysis is sound and guarantees that the value at the
value_label instruction propagates to all of the named locations.Then we can convert this mapping into a format that the DWARF
generation code (wasmtime's debug crate) can use.This PR also adds the new-backend variant to the gdb tests on CI.
cfallin updated PR #2565 from debug-value-labels
to main
:
This PR propagates "value labels" all the way from CLIF to DWARF
metadata on the emitted machine code. The key idea is as follows:
Translate value-label metadata on the input into "value_label"
pseudo-instructions when lowering into VCode. These
pseudo-instructions take a register as input, denote a value label,
and semantically are like a "move into value label" -- i.e., they
update the current value (as seen by debugging tools) of the given
local. These pseudo-instructions emit no machine code.Perform a dataflow analysis at the machine-code level, tracking
value-labels that propagate into registers and into [SP+constant]
stack storage. This is a forward dataflow fixpoint analysis where each
storage location can contain a set of value labels, and each value
label can reside in a set of storage locations. (Meet function is
pairwise intersection by storage location.)This analysis traces value labels symbolically through loads and
stores and reg-to-reg moves, so it will naturally handle spills and
reloads without knowing anything special about them.When this analysis converges, we have, at each machine-code offset, a
mapping from value labels to some number of storage locations; for
each offset for each label, we choose the best location (prefer
registers). Note that we can choose any location, as the symbolic
dataflow analysis is sound and guarantees that the value at the
value_label instruction propagates to all of the named locations.Then we can convert this mapping into a format that the DWARF
generation code (wasmtime's debug crate) can use.This PR also adds the new-backend variant to the gdb tests on CI.
cfallin requested fitzgen, bnjbvr and yurydelendik for a review on PR #2565.
cfallin requested fitzgen, bnjbvr and yurydelendik for a review on PR #2565.
cfallin updated PR #2565 from debug-value-labels
to main
:
This PR propagates "value labels" all the way from CLIF to DWARF
metadata on the emitted machine code. The key idea is as follows:
Translate value-label metadata on the input into "value_label"
pseudo-instructions when lowering into VCode. These
pseudo-instructions take a register as input, denote a value label,
and semantically are like a "move into value label" -- i.e., they
update the current value (as seen by debugging tools) of the given
local. These pseudo-instructions emit no machine code.Perform a dataflow analysis at the machine-code level, tracking
value-labels that propagate into registers and into [SP+constant]
stack storage. This is a forward dataflow fixpoint analysis where each
storage location can contain a set of value labels, and each value
label can reside in a set of storage locations. (Meet function is
pairwise intersection by storage location.)This analysis traces value labels symbolically through loads and
stores and reg-to-reg moves, so it will naturally handle spills and
reloads without knowing anything special about them.When this analysis converges, we have, at each machine-code offset, a
mapping from value labels to some number of storage locations; for
each offset for each label, we choose the best location (prefer
registers). Note that we can choose any location, as the symbolic
dataflow analysis is sound and guarantees that the value at the
value_label instruction propagates to all of the named locations.Then we can convert this mapping into a format that the DWARF
generation code (wasmtime's debug crate) can use.This PR also adds the new-backend variant to the gdb tests on CI.
yurydelendik submitted PR Review.
yurydelendik created PR Review Comment:
ExpressionWriter
haswrite_op_breg
fitzgen submitted PR Review.
fitzgen created PR Review Comment:
All of these methods could use a little, single-sentence doc comment describing what they're doing.
fitzgen submitted PR Review.
fitzgen created PR Review Comment:
Is the worklist processing order important here (eg avoiding big O blow up)? If not, I suspect that
Vec
andpop
would be faster thanVecDeque
andpop_front
.
fitzgen created PR Review Comment:
What is
remove
here? Can you add comments for this struct and its members?
fitzgen created PR Review Comment:
Ah is this when a collection becomes empty and can be removed from its parent collection? Maybe
is_empty
is a better name, or maybe just having a comment that explains would be enough.
fitzgen created PR Review Comment:
This will always search for
stack
even ifreg.is_some()
. This can be remedied by using.or_else(inline_the_def_of_stack_here)
.
fitzgen created PR Review Comment:
This could be a little tighter as
if list.last().map_or(true, |last| last.end <= offset || last.loc != loc) { ... }
fitzgen created PR Review Comment:
What is this? I have no idea what
iix
means here.
fitzgen created PR Review Comment:
remove_keys.clear()
to reuse the previous allocation
cfallin updated PR #2565 from debug-value-labels
to main
:
This PR propagates "value labels" all the way from CLIF to DWARF
metadata on the emitted machine code. The key idea is as follows:
Translate value-label metadata on the input into "value_label"
pseudo-instructions when lowering into VCode. These
pseudo-instructions take a register as input, denote a value label,
and semantically are like a "move into value label" -- i.e., they
update the current value (as seen by debugging tools) of the given
local. These pseudo-instructions emit no machine code.Perform a dataflow analysis at the machine-code level, tracking
value-labels that propagate into registers and into [SP+constant]
stack storage. This is a forward dataflow fixpoint analysis where each
storage location can contain a set of value labels, and each value
label can reside in a set of storage locations. (Meet function is
pairwise intersection by storage location.)This analysis traces value labels symbolically through loads and
stores and reg-to-reg moves, so it will naturally handle spills and
reloads without knowing anything special about them.When this analysis converges, we have, at each machine-code offset, a
mapping from value labels to some number of storage locations; for
each offset for each label, we choose the best location (prefer
registers). Note that we can choose any location, as the symbolic
dataflow analysis is sound and guarantees that the value at the
value_label instruction propagates to all of the named locations.Then we can convert this mapping into a format that the DWARF
generation code (wasmtime's debug crate) can use.This PR also adds the new-backend variant to the gdb tests on CI.
cfallin submitted PR Review.
cfallin created PR Review Comment:
The
map_or(true, ...)
form is a little hard to read for me, so I didlist.last().map(...).unwrap_or(true)
to be a little more explicit, and added a comment too. Happy to make things more concise, just want to avoid Haskell-like terseness that takes too much brain (for me, anyway) to decode :-)
cfallin submitted PR Review.
cfallin created PR Review Comment:
Nice improvement, thanks!
cfallin submitted PR Review.
cfallin created PR Review Comment:
Done; no, it shouldn't be important.
cfallin submitted PR Review.
cfallin created PR Review Comment:
Changed to
index
; it's a regalloc.rs-ism but I should really just write it out.
cfallin submitted PR Review.
cfallin created PR Review Comment:
Done, thanks!
cfallin submitted PR Review.
cfallin created PR Review Comment:
Added comment and renamed; agreed, that's more clear.
cfallin submitted PR Review.
cfallin created PR Review Comment:
Done; sorry about the terseness!
cfallin updated PR #2565 from debug-value-labels
to main
:
This PR propagates "value labels" all the way from CLIF to DWARF
metadata on the emitted machine code. The key idea is as follows:
Translate value-label metadata on the input into "value_label"
pseudo-instructions when lowering into VCode. These
pseudo-instructions take a register as input, denote a value label,
and semantically are like a "move into value label" -- i.e., they
update the current value (as seen by debugging tools) of the given
local. These pseudo-instructions emit no machine code.Perform a dataflow analysis at the machine-code level, tracking
value-labels that propagate into registers and into [SP+constant]
stack storage. This is a forward dataflow fixpoint analysis where each
storage location can contain a set of value labels, and each value
label can reside in a set of storage locations. (Meet function is
pairwise intersection by storage location.)This analysis traces value labels symbolically through loads and
stores and reg-to-reg moves, so it will naturally handle spills and
reloads without knowing anything special about them.When this analysis converges, we have, at each machine-code offset, a
mapping from value labels to some number of storage locations; for
each offset for each label, we choose the best location (prefer
registers). Note that we can choose any location, as the symbolic
dataflow analysis is sound and guarantees that the value at the
value_label instruction propagates to all of the named locations.Then we can convert this mapping into a format that the DWARF
generation code (wasmtime's debug crate) can use.This PR also adds the new-backend variant to the gdb tests on CI.
fitzgen submitted PR Review.
cfallin merged PR #2565.
Last updated: Nov 22 2024 at 16:03 UTC