[llvm] [SelectionDAG] Prevent converting a virtual register to an MCRegister. (PR #122857)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 21:13:42 PST 2025


================
@@ -705,53 +705,57 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
     if (InstrRef)
       continue;
 
-    // If Reg is live-in then update debug info to track its copy in a vreg.
-    DenseMap<MCRegister, Register>::iterator LDI = LiveInMap.find(Reg);
-    if (LDI != LiveInMap.end()) {
-      assert(!hasFI && "There's no handling of frame pointer updating here yet "
-                       "- add if needed");
-      MachineInstr *Def = RegInfo->getVRegDef(LDI->second);
-      MachineBasicBlock::iterator InsertPos = Def;
-      const MDNode *Variable = MI->getDebugVariable();
-      const MDNode *Expr = MI->getDebugExpression();
-      DebugLoc DL = MI->getDebugLoc();
-      bool IsIndirect = MI->isIndirectDebugValue();
-      if (IsIndirect)
-        assert(MI->getDebugOffset().getImm() == 0 &&
-               "DBG_VALUE with nonzero offset");
-      assert(cast<DILocalVariable>(Variable)->isValidLocationForIntrinsic(DL) &&
-             "Expected inlined-at fields to agree");
-      assert(MI->getOpcode() != TargetOpcode::DBG_VALUE_LIST &&
-             "Didn't expect to see a DBG_VALUE_LIST here");
-      // Def is never a terminator here, so it is ok to increment InsertPos.
-      BuildMI(*EntryMBB, ++InsertPos, DL, TII->get(TargetOpcode::DBG_VALUE),
-              IsIndirect, LDI->second, Variable, Expr);
-
-      // If this vreg is directly copied into an exported register then
-      // that COPY instructions also need DBG_VALUE, if it is the only
-      // user of LDI->second.
-      MachineInstr *CopyUseMI = nullptr;
-      for (MachineInstr &UseMI : RegInfo->use_instructions(LDI->second)) {
-        if (UseMI.isDebugValue())
-          continue;
-        if (UseMI.isCopy() && !CopyUseMI && UseMI.getParent() == EntryMBB) {
-          CopyUseMI = &UseMI;
-          continue;
+    if (Reg.isPhysical()) {
+      // If Reg is live-in then update debug info to track its copy in a vreg.
----------------
arsenm wrote:

Probably should extract into its own function at this point 

https://github.com/llvm/llvm-project/pull/122857


More information about the llvm-commits mailing list