================
@@ -7599,11 +7600,20 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl(
 
       const TargetRegisterClass &RC = *MF.getRegInfo().getRegClass(SrcReg);
       Register NewSrc = MF.getRegInfo().createVirtualRegister(&RC);
-      BuildMI(*NewMI->getParent(), *NewMI, MI.getDebugLoc(),
-              get(TargetOpcode::COPY))
-          .addReg(NewSrc, RegState::Define)
-          .addReg(SrcReg);
+      MachineInstr *Copy = BuildMI(*NewMI->getParent(), *NewMI,
+                                   MI.getDebugLoc(), get(TargetOpcode::COPY))
+                               .addReg(NewSrc, RegState::Define)
+                               .addReg(SrcReg);
       NewMI->getOperand(1).setReg(NewSrc);
+
+      if (LIS) {
+        SlotIndex CopyIdx = LIS->InsertMachineInstrInMaps(*Copy);
+        SlotIndex Idx = LIS->getInstructionIndex(MI);
+        LiveInterval &LI = LIS->getInterval(SrcReg);
+        LiveRange::Segment *S = LI.getSegmentContaining(Idx);
----------------
KanRobert wrote:

Is it possible the SrcReg is killed in this instrruction so that the 
`getSegmentContaining` returns nullptr?

https://github.com/llvm/llvm-project/pull/191102
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to