[PATCH] D18936: Fix regalloc-verifier error for r265547

Wei Mi via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 11 14:37:58 PDT 2016


wmi updated this revision to Diff 53321.
wmi added a comment.

Address Quentins' comment.


Repository:
  rL LLVM

http://reviews.llvm.org/D18936

Files:
  lib/CodeGen/LiveRangeEdit.cpp
  test/CodeGen/X86/new-remat.ll

Index: test/CodeGen/X86/new-remat.ll
===================================================================
--- test/CodeGen/X86/new-remat.ll
+++ test/CodeGen/X86/new-remat.ll
@@ -1,4 +1,4 @@
-; RUN: llc < %s | FileCheck %s
+; RUN: llc -verify-regalloc < %s | FileCheck %s
 ; Check all spills are rematerialized.
 ; CHECK-NOT: Spill
 
Index: lib/CodeGen/LiveRangeEdit.cpp
===================================================================
--- lib/CodeGen/LiveRangeEdit.cpp
+++ lib/CodeGen/LiveRangeEdit.cpp
@@ -148,10 +148,12 @@
                                          bool Late) {
   assert(RM.OrigMI && "Invalid remat");
   TII.reMaterialize(MBB, MI, DestReg, 0, RM.OrigMI, tri);
+  // DestReg of the cloned instruction cannot be Dead. Set isDead of DestReg
+  // to false anyway in case the isDead flag of RM.OrigMI's dest register
+  // is true.
+  (*--MI).getOperand(0).setIsDead(false);
   Rematted.insert(RM.ParentVNI);
-  return LIS.getSlotIndexes()
-      ->insertMachineInstrInMaps(*--MI, Late)
-      .getRegSlot();
+  return LIS.getSlotIndexes()->insertMachineInstrInMaps(*MI, Late).getRegSlot();
 }
 
 void LiveRangeEdit::eraseVirtReg(unsigned Reg) {
@@ -325,12 +327,14 @@
     // The inst is saved in LiveRangeEdit::DeadRemats and will be deleted
     // after all the allocations of the func are done.
     if (isOrigDef) {
-      unsigned NewDest = createFrom(Dest);
+      LiveInterval &NewLI = createEmptyIntervalFrom(Dest);
+      VNInfo *VNI = NewLI.getNextValue(Idx, LIS.getVNInfoAllocator());
+      NewLI.addSegment(LiveInterval::Segment(Idx, Idx.getDeadSlot(), VNI));
       pop_back();
       markDeadRemat(MI);
       const TargetRegisterInfo &TRI = *MRI.getTargetRegisterInfo();
-      MI->substituteRegister(Dest, NewDest, 0, TRI);
-      MI->getOperand(0).setIsDead(false);
+      MI->substituteRegister(Dest, NewLI.reg, 0, TRI);
+      MI->getOperand(0).setIsDead(true);
     } else {
       if (TheDelegate)
         TheDelegate->LRE_WillEraseInstruction(MI);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18936.53321.patch
Type: text/x-patch
Size: 1991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160411/96cc0b6a/attachment.bin>


More information about the llvm-commits mailing list