Remove/fix invalid README entries. The well thought out strcpy function doesn't retur...
[oota-llvm.git] / lib / CodeGen / LiveRangeEdit.cpp
index cc9c3a3c2f3741eb4d60b31a09035a860c8c60ac..3c7d9f66e7411339898251cdce490532b8a5cef2 100644 (file)
 
 using namespace llvm;
 
-int LiveRangeEdit::assignStackSlot(VirtRegMap &vrm) {
-  int ss = vrm.getStackSlot(getReg());
-  if (ss != VirtRegMap::NO_STACK_SLOT)
-    return ss;
-  return vrm.assignVirt2StackSlot(getReg());
-}
-
 LiveInterval &LiveRangeEdit::create(MachineRegisterInfo &mri,
                                     LiveIntervals &lis,
                                     VirtRegMap &vrm) {
   const TargetRegisterClass *RC = mri.getRegClass(parent_.reg);
   unsigned VReg = mri.createVirtualRegister(RC);
   vrm.grow();
-  // Immediately assign to the same stack slot as parent.
-  vrm.assignVirt2StackSlot(VReg, assignStackSlot(vrm));
   LiveInterval &li = lis.getOrCreateInterval(VReg);
   newRegs_.push_back(&li);
   return li;
@@ -97,36 +88,29 @@ bool LiveRangeEdit::allUsesAvailableAt(const MachineInstr *OrigMI,
   return true;
 }
 
-LiveRangeEdit::Remat LiveRangeEdit::canRematerializeAt(VNInfo *ParentVNI,
-                                                       SlotIndex UseIdx,
-                                                       bool cheapAsAMove,
-                                                       LiveIntervals &lis) {
+bool LiveRangeEdit::canRematerializeAt(Remat &RM,
+                                       SlotIndex UseIdx,
+                                       bool cheapAsAMove,
+                                       LiveIntervals &lis) {
   assert(scannedRemattable_ && "Call anyRematerializable first");
-  Remat RM = { 0, 0 };
-
-  // We could remat an undefined value as IMPLICIT_DEF, but all that should have
-  // been taken care of earlier.
-  if (!(RM.ParentVNI = parent_.getVNInfoAt(UseIdx)))
-    return RM;
 
   // Use scanRemattable info.
   if (!remattable_.count(RM.ParentVNI))
-    return RM;
+    return false;
 
   // No defining instruction.
-  MachineInstr *OrigMI = lis.getInstructionFromIndex(RM.ParentVNI->def);
-  assert(OrigMI && "Defining instruction for remattable value disappeared");
+  RM.OrigMI = lis.getInstructionFromIndex(RM.ParentVNI->def);
+  assert(RM.OrigMI && "Defining instruction for remattable value disappeared");
 
   // If only cheap remats were requested, bail out early.
-  if (cheapAsAMove && !OrigMI->getDesc().isAsCheapAsAMove())
-    return RM;
+  if (cheapAsAMove && !RM.OrigMI->getDesc().isAsCheapAsAMove())
+    return false;
 
   // Verify that all used registers are available with the same values.
-  if (!allUsesAvailableAt(OrigMI, RM.ParentVNI->def, UseIdx, lis))
-    return RM;
+  if (!allUsesAvailableAt(RM.OrigMI, RM.ParentVNI->def, UseIdx, lis))
+    return false;
 
-  RM.OrigMI = OrigMI;
-  return RM;
+  return true;
 }
 
 SlotIndex LiveRangeEdit::rematerializeAt(MachineBasicBlock &MBB,
@@ -138,6 +122,7 @@ SlotIndex LiveRangeEdit::rematerializeAt(MachineBasicBlock &MBB,
                                          const TargetRegisterInfo &tri) {
   assert(RM.OrigMI && "Invalid remat");
   tii.reMaterialize(MBB, MI, DestReg, 0, RM.OrigMI, tri);
+  rematted_.insert(RM.ParentVNI);
   return lis.InsertMachineInstrInMaps(--MI).getDefIndex();
 }