[llvm] 17a5930 - ModuloSchedule: Fix using getVRegDef/getUniqueVRegDef on physregs (#216795)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 23 23:30:24 PDT 2026


Author: Matt Arsenault
Date: 2026-08-24T08:30:19+02:00
New Revision: 17a5930373025c8acd5ff393503d0691d3907b92

URL: https://github.com/llvm/llvm-project/commit/17a5930373025c8acd5ff393503d0691d3907b92
DIFF: https://github.com/llvm/llvm-project/commit/17a5930373025c8acd5ff393503d0691d3907b92.diff

LOG: ModuloSchedule: Fix using getVRegDef/getUniqueVRegDef on physregs (#216795)

These should be invalid to use on physical registers, but are currently
permissive. Avoid calling them so in the future they can assert.

Also this pass seems to run in SSA, so shouldn't really be using
getUniqueVRegDef.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>

Added: 
    

Modified: 
    llvm/lib/CodeGen/ModuloSchedule.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp
index c62759aedc5ba..3c441393dbb39 100644
--- a/llvm/lib/CodeGen/ModuloSchedule.cpp
+++ b/llvm/lib/CodeGen/ModuloSchedule.cpp
@@ -949,6 +949,8 @@ bool ModuloScheduleExpander::computeDelta(MachineInstr &MI, unsigned &Delta) {
     return false;
 
   Register BaseReg = BaseOp->getReg();
+  if (!BaseReg.isVirtual())
+    return false;
 
   MachineRegisterInfo &MRI = MF.getRegInfo();
   // Check if there is a Phi. If so, get the definition in the loop.
@@ -1722,7 +1724,7 @@ void PeelingModuloScheduleExpander::moveStageBetweenBlocks(
         continue;
       if (auto It = Remaps.find(MO.getReg()); It != Remaps.end())
         MO.setReg(It->second);
-      else {
+      else if (MO.getReg().isVirtual()) {
         // If we are using a phi from the source block we need to add a new phi
         // pointing to the old one.
         MachineInstr *Use = MRI.getUniqueVRegDef(MO.getReg());


        


More information about the llvm-commits mailing list