Skip to content

[CodeGen][X86] LiveRangeShrink: fix increment after end #115276

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
Nov 9, 2024

Conversation

MuellerMP
Copy link
Contributor

This fixes the infinite loop discovered in #114195.
Since we skip debug instructions at the start of the loop we do not need to skip them again at the end of the loop.

@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2024

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-llvm-regalloc

Author: Mirko (MuellerMP)

Changes

This fixes the infinite loop discovered in #114195.
Since we skip debug instructions at the start of the loop we do not need to skip them again at the end of the loop.


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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/LiveRangeShrink.cpp (+1-1)
diff --git a/llvm/lib/CodeGen/LiveRangeShrink.cpp b/llvm/lib/CodeGen/LiveRangeShrink.cpp
index f4bf47c3ae158f..6a0b918d5e6f67 100644
--- a/llvm/lib/CodeGen/LiveRangeShrink.cpp
+++ b/llvm/lib/CodeGen/LiveRangeShrink.cpp
@@ -246,7 +246,7 @@ bool LiveRangeShrink::runOnMachineFunction(MachineFunction &MF) {
         if (MI.getOperand(0).isReg())
           for (; EndIter != MBB.end() && EndIter->isDebugValue() &&
                  EndIter->hasDebugOperandForReg(MI.getOperand(0).getReg());
-               ++EndIter, ++Next)
+               ++EndIter)
             IOM[&*EndIter] = NewOrder;
         MBB.splice(I, &MBB, MI.getIterator(), EndIter);
       }

Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

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

Needs test

@nathanchance
Copy link
Member

Thanks, this appears to resolve the issue I reported, but I understand there needs to be a test added before it can be merged.

@MuellerMP
Copy link
Contributor Author

This is how far i could reduce the orginal sample. (Still repros on trunk https://llvm.godbolt.org/z/bh8boEvff)
It requires the debug value + phi setup to trigger this specific issue with debug values at the end of an MBB.

This fixes the infinite loop discovered in llvm#114195.
Since we skip debug instructions at the start of the loop we do not
need to skip them again at the end of the loop.
@arsenm arsenm merged commit 5e02fd8 into llvm:main Nov 9, 2024
8 checks passed
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
This fixes the infinite loop discovered in llvm#114195. 
Since we skip debug instructions at the start of the loop we do not need
to skip them again at the end of the loop.
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.

4 participants