-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Move vzeroupper emit back to JIT #115748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move vzeroupper emit back to JIT #115748
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR shifts the emission of the VZEROUPPER AVX instruction from static assembly helpers into the JIT pipeline, ensuring it’s only generated when needed.
- Removed unconditional
vzeroupper
from various static ASM/S assembly helper prologs and epilogs. - Introduced
genClearAvxStateProlog
andgenClearAvxStateEpilog
in the JIT to emitvzeroupper
conditionally. - Updated calls to preserve/restore callee-saved float registers to use new parameterless signatures.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
vm/amd64/asmhelpers.S | Removed vzeroupper in static helper macros |
vm/amd64/AsmHelpers.asm | Removed duplicate vzeroupper in assembly prologs |
nativeaot/Runtime/amd64/ExceptionHandling.asm | Removed vzeroupper from native AOT funclet helpers |
nativeaot/Runtime/amd64/ExceptionHandling.S | Same removal in .S variant |
jit/codegenxarch.cpp | Added JIT hooks (genClearAvxState* ) and refactored preserve/restore calls |
jit/codegencommon.cpp | Inserted genClearAvxStateProlog before float-reg save |
jit/codegen.h | Declared new clear-state methods and updated signatures |
Comments suppressed due to low confidence (2)
src/coreclr/jit/codegencommon.cpp:5288
- The new
genClearAvxStateProlog
branch logic (checkingContainsCallNeedingVzeroupper
vs.Contains256bitOrMoreAVX
) should have unit or integration tests to validate both code paths emit (or skip)vzeroupper
as expected.
genClearAvxStateProlog();
src/coreclr/jit/codegenxarch.cpp:11040
- There are two calls to
genClearAvxStateProlog()
in the samegenFuncletProlog
implementation (around lines 10918 and 11040). Consider consolidating to a single insertion point to avoid duplicated VZEROUPPER emission.
genClearAvxStateProlog();
This comment was marked as resolved.
This comment was marked as resolved.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
vzeroupper is AVX instruction and so it cannot be executed unconditionally in static asm helpers Fixes dotnet#115672
int shiftByValue = (int)shiftBy->AsIntConCommon()->IconValue(); | ||
|
||
if (tree->OperIsRotate() && compiler->compOpportunisticallyDependsOn(InstructionSet_BMI2) && !tree->gtSetFlags()) | ||
if (tree->OperIsRotate() && compiler->compOpportunisticallyDependsOn(InstructionSet_BMI2) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes from jit format
/ba-g unrelated timeout |
vzeroupper is AVX instruction and so it cannot be executed unconditionally in static asm helpers
Fixes #115672