abrown opened PR #10648 from abrown:asm-xor-clear to bytecodealliance:main:
This change uses an "uninitialized value" to resolve the register allocation issues that come up when clearing a GPR with
xor; this tries out the approach suggested in #10632 and will replace that if merged. The problem is that, inxor <tmp>, <tmp>, we need some way to communicate to the register allocator that the previous values of<tmp>are completely cleared--i.e., not used. While #10632 started down the path of allowing the register allocator to make a different decision about<tmp>--the approach currently taken forAluConstOp--this change instead adopts the "uninitialized value" approach. As was done previously withXmmUninitializedValue, we create a new pseudo-instruction calledGprUninitializedValuewhose registers are defined out of thin air.
cfallin submitted PR review:
LGTM, thanks!
cfallin created PR review comment:
I know pre-existing, but can we add a bit more here about how it's used (to ease concerns of the reader that this looks wildly unsafe)? Basically something like: "This is always immediately followed by an instruction, such as
xor reg, reg, that semantically reads this undefined value but arithmetically produces the same result regardless of its value."
abrown submitted PR review.
abrown created PR review comment:
I do have some questions about the offset changes here (hence the draft status): here, for example, we've managed to shave a byte off our encodings somehow...
abrown created PR review comment:
And here, we've somehow lost a byte again, but without any other changes to the file?
abrown created PR review comment:
...whereas here we've managed to gain two of them! It's not yet clear to me why this is.
abrown updated PR #10648.
abrown has marked PR #10648 as ready for review.
abrown requested fitzgen for a review on PR #10648.
abrown requested wasmtime-compiler-reviewers for a review on PR #10648.
abrown requested wasmtime-core-reviewers for a review on PR #10648.
abrown commented on PR #10648:
In the Cranelift meeting today we chalked these offset changes up to different register allocation (potentially adding or removing REX bytes in a few places) — no one sounded too concerned. We did discuss another approach: instead of continuing to rely on the
uninitfootgun, we could create a pseudo-instruction, much like the currentAluConstOp, to differentiate thisxor <tmp>, <tmp>pattern for register allocation. (I have built a branch that already walks out that approach: https://github.com/bytecodealliance/wasmtime/compare/main...abrown:wasmtime:asm-const).
abrown merged PR #10648.
Last updated: Dec 06 2025 at 07:03 UTC