-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Fix poisoning for very large structs #61521
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
Merged
jakobbotsch
merged 2 commits into
dotnet:main
from
jakobbotsch:fix-poisoning-large-structs
Nov 16, 2021
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -712,6 +712,20 @@ bool LinearScan::isContainableMemoryOp(GenTree* node) | |
| // | ||
| void LinearScan::addRefsForPhysRegMask(regMaskTP mask, LsraLocation currentLoc, RefType refType, bool isLastUse) | ||
| { | ||
| if (refType == RefTypeKill) | ||
| { | ||
| // The mask identifies a set of registers that will be used during | ||
| // codegen. Mark these as modified here, so when we do final frame | ||
| // layout, we'll know about all these registers. This is especially | ||
| // important if mask contains callee-saved registers, which affect the | ||
| // frame size since we need to save/restore them. In the case where we | ||
| // have a copyBlk with GC pointers, can need to call the | ||
| // CORINFO_HELP_ASSIGN_BYREF helper, which kills callee-saved RSI and | ||
| // RDI, if LSRA doesn't assign RSI/RDI, they wouldn't get marked as | ||
| // modified until codegen, which is too late. | ||
| compiler->codeGen->regSet.rsSetRegsModified(mask DEBUGARG(true)); | ||
| } | ||
|
|
||
| for (regNumber reg = REG_FIRST; mask; reg = REG_NEXT(reg), mask >>= 1) | ||
| { | ||
| if (mask & 1) | ||
|
|
@@ -1137,16 +1151,6 @@ bool LinearScan::buildKillPositionsForNode(GenTree* tree, LsraLocation currentLo | |
|
|
||
| if (killMask != RBM_NONE) | ||
| { | ||
| // The killMask identifies a set of registers that will be used during codegen. | ||
| // Mark these as modified here, so when we do final frame layout, we'll know about | ||
| // all these registers. This is especially important if killMask contains | ||
| // callee-saved registers, which affect the frame size since we need to save/restore them. | ||
| // In the case where we have a copyBlk with GC pointers, can need to call the | ||
| // CORINFO_HELP_ASSIGN_BYREF helper, which kills callee-saved RSI and RDI, if | ||
| // LSRA doesn't assign RSI/RDI, they wouldn't get marked as modified until codegen, | ||
| // which is too late. | ||
| compiler->codeGen->regSet.rsSetRegsModified(killMask DEBUGARG(true)); | ||
|
|
||
| addRefsForPhysRegMask(killMask, currentLoc, RefTypeKill, true); | ||
|
|
||
| // TODO-CQ: It appears to be valuable for both fp and int registers to avoid killing the callee | ||
|
|
@@ -2356,7 +2360,15 @@ void LinearScan::buildIntervals() | |
| // into the scratch register, so it will be killed here. | ||
| if (compiler->compShouldPoisonFrame() && compiler->fgFirstBBisScratch() && block == compiler->fgFirstBB) | ||
| { | ||
| addRefsForPhysRegMask(genRegMask(REG_SCRATCH), currentLoc + 1, RefTypeKill, true); | ||
| regMaskTP killed; | ||
| #if defined(TARGET_XARCH) | ||
| // Poisoning uses EAX for small vars and rep stosd that kills edi, ecx and eax for large vars. | ||
| killed = RBM_EDI | RBM_ECX | RBM_EAX; | ||
| #else | ||
| // Poisoning uses REG_SCRATCH for small vars and memset helper for big vars. | ||
| killed = genRegMask(REG_SCRATCH) | compiler->compHelperCallKillSet(CORINFO_HELP_MEMSET); | ||
| #endif | ||
| addRefsForPhysRegMask(killed, currentLoc + 1, RefTypeKill, true); | ||
| currentLoc += 2; | ||
| } | ||
|
|
||
|
|
@@ -3291,7 +3303,7 @@ void LinearScan::BuildStoreLocDef(GenTreeLclVarCommon* storeLoc, | |
| defCandidates = allRegs(type); | ||
| } | ||
| #else | ||
| defCandidates = allRegs(type); | ||
| defCandidates = allRegs(type); | ||
|
||
| #endif // TARGET_X86 | ||
|
|
||
| RefPosition* def = newRefPosition(varDefInterval, currentLoc + 1, RefTypeDef, storeLoc, defCandidates, index); | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.