Simplify the LiveRangeEdit::canRematerializeAt() interface a bit.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 10 Nov 2010 01:05:12 +0000 (01:05 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 10 Nov 2010 01:05:12 +0000 (01:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118661 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/InlineSpiller.cpp
lib/CodeGen/LiveRangeEdit.cpp
lib/CodeGen/LiveRangeEdit.h

index ee30a1512a204a64d1c694ce09c241a3b9fa197d..cbc6a536539b8d739e70db7431d69b9d50d3a140 100644 (file)
@@ -167,9 +167,8 @@ bool InlineSpiller::reMaterializeFor(MachineBasicBlock::iterator MI) {
     return true;
   }
 
-  LiveRangeEdit::Remat RM = edit_->canRematerializeAt(OrigVNI, UseIdx, false,
-                                                      lis_);
-  if (!RM) {
+  LiveRangeEdit::Remat RM(OrigVNI);
+  if (!edit_->canRematerializeAt(RM, UseIdx, false, lis_)) {
     usedValues_.insert(OrigVNI);
     DEBUG(dbgs() << "\tcannot remat for " << UseIdx << '\t' << *MI);
     return false;
index bbcc07ca09909f0338e372a352b69ba093e5dc08..3c7d9f66e7411339898251cdce490532b8a5cef2 100644 (file)
@@ -88,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,
index 151f5b1b900cedeb39476172879580a2f48e68e3..ad248bf4002c48f2ea43f78c4920cc524cbd5871 100644 (file)
@@ -94,16 +94,16 @@ public:
   struct Remat {
     VNInfo *ParentVNI;      // parent_'s value at the remat location.
     MachineInstr *OrigMI;   // Instruction defining ParentVNI.
-    operator bool() const { return OrigMI; }
+    explicit Remat(VNInfo *ParentVNI) : ParentVNI(ParentVNI), OrigMI(0) {}
   };
 
   /// canRematerializeAt - Determine if ParentVNI can be rematerialized at
   /// UseIdx. It is assumed that parent_.getVNINfoAt(UseIdx) == ParentVNI.
   /// When cheapAsAMove is set, only cheap remats are allowed.
-  Remat canRematerializeAt(VNInfo *ParentVNI,
-                           SlotIndex UseIdx,
-                           bool cheapAsAMove,
-                           LiveIntervals &lis);
+  bool canRematerializeAt(Remat &RM,
+                          SlotIndex UseIdx,
+                          bool cheapAsAMove,
+                          LiveIntervals &lis);
 
   /// rematerializeAt - Rematerialize RM.ParentVNI into DestReg by inserting an
   /// instruction into MBB before MI. The new instruction is mapped, but