Skip to content

Conversation

@arsenm
Copy link
Contributor

@arsenm arsenm commented Sep 24, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Sep 24, 2025

@llvm/pr-subscribers-llvm-regalloc
@llvm/pr-subscribers-backend-systemz

@llvm/pr-subscribers-backend-x86

Author: Matt Arsenault (arsenm)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/RegAllocGreedy.cpp (+3-2)
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index dc23ab3ce9d2b..6957548ac6c7a 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -2502,8 +2502,10 @@ void RAGreedy::tryHintRecoloring(const LiveInterval &VirtReg) {
   do {
     Reg = RecoloringCandidates.pop_back_val();
 
+    MCRegister CurrPhys = VRM->getPhys(Reg);
+
     // This may be a skipped register.
-    if (!VRM->hasPhys(Reg)) {
+    if (!CurrPhys) {
       assert(!shouldAllocateRegister(Reg) &&
              "We have an unallocated variable which should have been handled");
       continue;
@@ -2512,7 +2514,6 @@ void RAGreedy::tryHintRecoloring(const LiveInterval &VirtReg) {
     // Get the live interval mapped with this virtual register to be able
     // to check for the interference with the new color.
     LiveInterval &LI = LIS->getInterval(Reg);
-    MCRegister CurrPhys = VRM->getPhys(Reg);
     // Check that the new color matches the register class constraints and
     // that it is free for this live range.
     if (CurrPhys != PhysReg && (!MRI->getRegClass(Reg)->contains(PhysReg) ||

Copy link
Collaborator

@preames preames left a comment

Choose a reason for hiding this comment

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

LGTM

@arsenm arsenm force-pushed the users/arsenm/greedy/move-physreg-check-tryHintRecoloring branch from 19296e2 to f588d48 Compare September 26, 2025 15:48
@arsenm arsenm force-pushed the users/arsenm/greedy/merge-virtregmap-getPhys-checks branch 2 times, most recently from b9629d1 to b049f4a Compare September 27, 2025 01:35
@arsenm arsenm force-pushed the users/arsenm/greedy/move-physreg-check-tryHintRecoloring branch 2 times, most recently from 5e1d9bb to 9c6c1a9 Compare October 2, 2025 11:42
@arsenm arsenm force-pushed the users/arsenm/greedy/merge-virtregmap-getPhys-checks branch from b049f4a to 585006d Compare October 2, 2025 11:42
Base automatically changed from users/arsenm/greedy/move-physreg-check-tryHintRecoloring to main October 2, 2025 13:24
@arsenm arsenm force-pushed the users/arsenm/greedy/merge-virtregmap-getPhys-checks branch from 585006d to 0c43968 Compare October 2, 2025 13:39
@arsenm arsenm enabled auto-merge (squash) October 2, 2025 13:42
@arsenm arsenm merged commit 706b790 into main Oct 2, 2025
9 checks passed
@arsenm arsenm deleted the users/arsenm/greedy/merge-virtregmap-getPhys-checks branch October 2, 2025 14:06
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
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