[CodeGen] Ask the target whether it can clear registers or the stack - #7
Draft
claude[bot] wants to merge 1 commit into
Draft
[CodeGen] Ask the target whether it can clear registers or the stack#7claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
|
|
A request to clear call-used registers is dispatched through emitZeroCallUsedRegs, whose default body is empty. A target that has not implemented it therefore compiles the request into nothing at all, and nothing says so: the caller asked for the registers to be destroyed, the object file leaves them holding what was in them, and the only way to find out is to read the disassembly. ARM32 is the live case. The driver refuses the command-line flag there through a hard-coded list of triples, but the function attribute that flag turns into is accepted, carried through the whole pipeline, and dropped in the frame lowering, so anything that sets the attribute directly, including LTO and inlining of code compiled elsewhere, silently gets nothing. Add a capability query the target answers instead of inferring support from an emission that may do nothing. supportsZeroCallUsedRegs defaults to false, so a target is unsupported until it says otherwise, and prologue-epilogue insertion asks before computing what to clear: a target that answers false gets a diagnostic and no code, rather than no diagnostic and no code. The three targets that implement the emission today, X86, AArch64 and RISCV, answer true, which is what the driver's triple list already assumed, so no target changes what it generates. supportsZeroizeStack is the same query for the "zeroize-stack" attribute, and today every target answers false, because none of them clears the frame yet. That attribute has had no backend consumer at all since it was added, which is the same silence in a worse form, so it now reports itself as unsupported everywhere until an implementation exists. DiagnosticInfoUnsupported is what the backend already uses to refuse a request it cannot compile, including in frame lowering, where RISCV reports a reserved stack or frame pointer through it. It names the function, is an error rather than a warning, and leaves llc exiting non-zero, which is what fails closed means here. The scope is the query surface and the refusal. Clearing the stack is trailofbits/vspells-ct-internal-notes#26 and the set of registers to clear is unchanged, on trailofbits/vspells-ct-internal-notes#27. The frontend diagnostic that replaces the driver's triple list is trailofbits/vspells-ct-internal-notes#67, which will consult these queries. The names are recommendations awaiting sign-off on trailofbits/vspells-ct-internal-notes#64. This is trailofbits/vspells-ct-internal-notes#23, under the umbrella trailofbits/vspells-ct-internal-notes#17.
claude
Bot
force-pushed
the
zeroize-lowering
branch
from
August 11, 2026 19:58
cf198e8 to
2812359
Compare
claude
Bot
force-pushed
the
zeroize-capabilities
branch
from
August 11, 2026 19:58
413a04b to
8ab6b64
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Requested by Francesco Bertolaccini · Slack thread
A request to clear call-used registers is dispatched through
emitZeroCallUsedRegs, whose default body is empty. A target that has not
implemented it therefore compiles the request into nothing at all, and nothing
says so: the caller asked for the registers to be destroyed, the object file
leaves them holding what was in them, and the only way to find out is to read
the disassembly. ARM32 is the live case. The driver refuses the command-line
flag there through a hard-coded list of triples, but the function attribute
that flag turns into is accepted, carried through the whole pipeline, and
dropped in the frame lowering, so anything that sets the attribute directly,
including LTO and inlining of code compiled elsewhere, silently gets nothing.
Add a capability query the target answers instead of inferring support from an
emission that may do nothing. supportsZeroCallUsedRegs defaults to false, so a
target is unsupported until it says otherwise, and prologue-epilogue insertion
asks before computing what to clear: a target that answers false gets a
diagnostic and no code, rather than no diagnostic and no code. The three
targets that implement the emission today, X86, AArch64 and RISCV, answer true,
which is what the driver's triple list already assumed, so no target changes
what it generates.
supportsZeroizeStack is the same query for the "zeroize-stack" attribute, and
today every target answers false, because none of them clears the frame yet.
That attribute has had no backend consumer at all since it was added, which is
the same silence in a worse form, so it now reports itself as unsupported
everywhere until an implementation exists.
DiagnosticInfoUnsupported is what the backend already uses to refuse a request
it cannot compile, including in frame lowering, where RISCV reports a reserved
stack or frame pointer through it. It names the function, is an error rather
than a warning, and leaves llc exiting non-zero, which is what fails closed
means here.
The scope is the query surface and the refusal. Clearing the stack is
trailofbits/vspells-ct-internal-notes#26 and the set of registers to clear is
unchanged, on trailofbits/vspells-ct-internal-notes#27. The frontend
diagnostic that replaces the driver's triple list is
trailofbits/vspells-ct-internal-notes#67, which will consult these queries.
The names are recommendations awaiting sign-off on
trailofbits/vspells-ct-internal-notes#64.
This is trailofbits/vspells-ct-internal-notes#23, under the umbrella
trailofbits/vspells-ct-internal-notes#17.
AI tool use
This pull request contains AI-generated content. It was prepared with the assistance of Claude Code; the contributor has reviewed the generated code and text, is the author of the contribution, and is accountable for it, per the LLVM AI Tool Use Policy.
Generated by Claude Code