-
Notifications
You must be signed in to change notification settings - Fork 15.3k
RegAllocFast: Fix verifier errors after assigning to reserved registers #128155
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
Closed
arsenm
wants to merge
3
commits into
main
from
users/arsenm/regalloc-fast-fix-verifier-errors-after-failure
Closed
Changes from all commits
Commits
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 |
|---|---|---|
|
|
@@ -598,6 +598,9 @@ void VirtRegRewriter::rewrite() { | |
| SmallVector<Register, 8> SuperDefs; | ||
| SmallVector<Register, 8> SuperKills; | ||
|
|
||
| const bool IsValidAlloc = !MF->getProperties().hasProperty( | ||
| MachineFunctionProperties::Property::FailedRegAlloc); | ||
|
|
||
| for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end(); | ||
| MBBI != MBBE; ++MBBI) { | ||
| LLVM_DEBUG(MBBI->print(dbgs(), Indexes)); | ||
|
|
@@ -617,9 +620,7 @@ void VirtRegRewriter::rewrite() { | |
| assert(Register(PhysReg).isPhysical()); | ||
|
|
||
| RewriteRegs.insert(PhysReg); | ||
| assert((!MRI->isReserved(PhysReg) || | ||
| MF->getProperties().hasProperty( | ||
| MachineFunctionProperties::Property::FailedRegAlloc)) && | ||
| assert((!MRI->isReserved(PhysReg) || !IsValidAlloc) && | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR - should insert a separate assertion for FailedRegalloc with an appropriate failure message. |
||
| "Reserved register assignment"); | ||
|
|
||
| // Preserve semantics of sub-register operands. | ||
|
|
@@ -695,7 +696,14 @@ void VirtRegRewriter::rewrite() { | |
| // Rewrite. Note we could have used MachineOperand::substPhysReg(), but | ||
| // we need the inlining here. | ||
| MO.setReg(PhysReg); | ||
| MO.setIsRenamable(true); | ||
|
|
||
| // Defend against generating invalid flags in allocation failure | ||
| // scenarios. We have have assigned a register which was undefined, or a | ||
| // reserved register which cannot be renamable. | ||
| if (LLVM_LIKELY(IsValidAlloc)) | ||
| MO.setIsRenamable(true); | ||
| else if (MO.isUse()) | ||
| MO.setIsUndef(true); | ||
| } | ||
|
|
||
| // Add any missing super-register kills after rewriting the whole | ||
|
|
||
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
8 changes: 3 additions & 5 deletions
8
llvm/test/CodeGen/AMDGPU/ran-out-of-registers-error-all-regs-reserved.ll
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
6 changes: 2 additions & 4 deletions
6
llvm/test/CodeGen/AMDGPU/regalloc-failure-overlapping-insert-assert.mir
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
11 changes: 5 additions & 6 deletions
11
llvm/test/CodeGen/AMDGPU/remaining-virtual-register-operands.ll
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
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.
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.
Nit: You can avoid the double negation if the variable name is changed to
IsFailedAlloc.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.
This keeps the negation out of the loop