Skip to content

LiveRangeEdit: Replace setIsDead with an assert #92964

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
merged 1 commit into from
May 22, 2024

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented May 21, 2024

I noticed this was possibly buggy with implicit operands with the same dest register, and should maybe be using addRegisterDead. However, this is never called in a situation where the operand wasn't already marked dead. This is eliminateDeadDef, implying the def was already known to be dead.

Add an assert to detect inconsistencies in dead flags. This was apparently added in 9a16d65.

I noticed this was possibly buggy with implicit operands with the same
dest register, and should maybe be using addRegisterDead. However,
this is never called in a situation where the operand wasn't already marked
dead. This is eliminateDeadDef, implying the def was already known to be dead.

Add an assert to detect inconsistencies in dead flags.
@llvmbot
Copy link
Member

llvmbot commented May 21, 2024

@llvm/pr-subscribers-llvm-regalloc

Author: Matt Arsenault (arsenm)

Changes

I noticed this was possibly buggy with implicit operands with the same dest register, and should maybe be using addRegisterDead. However, this is never called in a situation where the operand wasn't already marked dead. This is eliminateDeadDef, implying the def was already known to be dead.

Add an assert to detect inconsistencies in dead flags. This was apparently added in 9a16d65.


Full diff: https://github.com/llvm/llvm-project/pull/92964.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/LiveRangeEdit.cpp (+1-1)
diff --git a/llvm/lib/CodeGen/LiveRangeEdit.cpp b/llvm/lib/CodeGen/LiveRangeEdit.cpp
index 643370f0573d1..7b7b5459ad7b2 100644
--- a/llvm/lib/CodeGen/LiveRangeEdit.cpp
+++ b/llvm/lib/CodeGen/LiveRangeEdit.cpp
@@ -414,7 +414,7 @@ void LiveRangeEdit::eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink) {
       DeadRemats->insert(MI);
       const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
       MI->substituteRegister(Dest, NewLI.reg(), 0, TRI);
-      MI->getOperand(0).setIsDead(true);
+      assert(MI->registerDefIsDead(NewLI.reg(), &TRI));
     } else {
       if (TheDelegate)
         TheDelegate->LRE_WillEraseInstruction(MI);

Copy link
Collaborator

@qcolombet qcolombet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Maybe ::substituteRegister used to reset the dead flag?

Anyhow LGTM.

@arsenm arsenm merged commit d41dde7 into llvm:main May 22, 2024
6 checks passed
@arsenm arsenm deleted the liverangeedit-setisdead-to-assert branch May 22, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants