[llvm-commits] [llvm] r118661 - in /llvm/trunk/lib/CodeGen: InlineSpiller.cpp LiveRangeEdit.cpp LiveRangeEdit.h

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue Nov 9 17:05:12 PST 2010


Author: stoklund
Date: Tue Nov  9 19:05:12 2010
New Revision: 118661

URL: http://llvm.org/viewvc/llvm-project?rev=118661&view=rev
Log:
Simplify the LiveRangeEdit::canRematerializeAt() interface a bit.

Modified:
    llvm/trunk/lib/CodeGen/InlineSpiller.cpp
    llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp
    llvm/trunk/lib/CodeGen/LiveRangeEdit.h

Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=118661&r1=118660&r2=118661&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original)
+++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Tue Nov  9 19:05:12 2010
@@ -167,9 +167,8 @@
     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;

Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp?rev=118661&r1=118660&r2=118661&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp Tue Nov  9 19:05:12 2010
@@ -88,36 +88,29 @@
   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,

Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.h?rev=118661&r1=118660&r2=118661&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveRangeEdit.h (original)
+++ llvm/trunk/lib/CodeGen/LiveRangeEdit.h Tue Nov  9 19:05:12 2010
@@ -94,16 +94,16 @@
   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





More information about the llvm-commits mailing list