[CodeGen] Ask the target whether it can clear registers or the stack - #7
[CodeGen] Ask the target whether it can clear registers or the stack#7claude[bot] wants to merge 1 commit into
Conversation
|
|
cf198e8 to
2812359
Compare
413a04b to
8ab6b64
Compare
2812359 to
4fa2552
Compare
8ab6b64 to
a8c76e7
Compare
|
A full The cause is the new "not supported by this target" diagnostic added here at Build: Generated by Claude Code |
4fa2552 to
384fc0f
Compare
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.
a8c76e7 to
171f6f9
Compare
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