Reduce the offsets in DwarfDebugInfoEntry to 32 bit, they're printed with %x and
[oota-llvm.git] / lib / CodeGen / StrongPHIElimination.cpp
index 17bd2cfee6c5d1f633ac0d3f56a060b8546856a9..260cc0ee50a56950b0bd68b35cd66afa3783d317 100644 (file)
@@ -47,6 +47,8 @@
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/Target/TargetInstrInfo.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Debug.h"
 using namespace llvm;
 
@@ -187,6 +189,10 @@ namespace {
   };
 } // namespace
 
+STATISTIC(NumPHIsLowered, "Number of PHIs lowered");
+STATISTIC(NumDestCopiesInserted, "Number of destination copies inserted");
+STATISTIC(NumSrcCopiesInserted, "Number of source copies inserted");
+
 char StrongPHIElimination::ID = 0;
 INITIALIZE_PASS_BEGIN(StrongPHIElimination, "strong-phi-node-elimination",
   "Eliminate PHI nodes for register allocation, intelligently", false, false)
@@ -582,7 +588,7 @@ StrongPHIElimination::SplitInterferencesForBasicBlock(
   }
 
   // We now walk the PHIs in successor blocks and check for interferences. This
-  // is necesary because the use of a PHI's operands are logically contained in
+  // is necessary because the use of a PHI's operands are logically contained in
   // the predecessor block. The def of a PHI's destination register is processed
   // along with the other defs in a basic block.
 
@@ -645,6 +651,7 @@ StrongPHIElimination::SplitInterferencesForBasicBlock(
 void StrongPHIElimination::InsertCopiesForPHI(MachineInstr *PHI,
                                               MachineBasicBlock *MBB) {
   assert(PHI->isPHI());
+  ++NumPHIsLowered;
   unsigned PHIColor = getPHIColor(PHI);
 
   for (unsigned i = 1; i < PHI->getNumOperands(); i += 2) {
@@ -667,7 +674,7 @@ void StrongPHIElimination::InsertCopiesForPHI(MachineInstr *PHI,
     if (PHIColor && SrcColor == PHIColor) {
       LiveInterval &SrcInterval = LI->getInterval(SrcReg);
       SlotIndex PredIndex = LI->getMBBEndIdx(PredBB);
-      VNInfo *SrcVNI = SrcInterval.getVNInfoAt(PredIndex.getPrevIndex());
+      VNInfo *SrcVNI = SrcInterval.getVNInfoBefore(PredIndex);
       assert(SrcVNI);
       SrcVNI->setHasPHIKill(true);
       continue;
@@ -694,6 +701,7 @@ void StrongPHIElimination::InsertCopiesForPHI(MachineInstr *PHI,
                                         TII->get(TargetOpcode::COPY),
                                         CopyReg).addReg(SrcReg, 0, SrcSubReg);
       LI->InsertMachineInstrInMaps(CopyInstr);
+      ++NumSrcCopiesInserted;
 
       // addLiveRangeToEndOfBlock() also adds the phikill flag to the VNInfo for
       // the newly added range.
@@ -763,6 +771,7 @@ void StrongPHIElimination::InsertCopiesForPHI(MachineInstr *PHI,
                                     DestReg).addReg(CopyReg);
   LI->InsertMachineInstrInMaps(CopyInstr);
   PHI->getOperand(0).setReg(CopyReg);
+  ++NumDestCopiesInserted;
 
   // Add the region from the beginning of MBB to the copy instruction to
   // CopyReg's live interval, and give the VNInfo the phidef flag.