Fix PR number.
[oota-llvm.git] / lib / CodeGen / PHIElimination.cpp
index fec54eac373905680914ea8be53257a1efada4c9..fec9e2ec32784fda9c92d7a4e963705a07f835e0 100644 (file)
@@ -13,6 +13,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "phielim"
 #include "llvm/CodeGen/LiveVariables.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
@@ -20,7 +21,6 @@
 #include "llvm/CodeGen/SSARegMap.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetMachine.h"
-#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Compiler.h"
 #include <algorithm>
 using namespace llvm;
 
+STATISTIC(NumAtomic, "Number of atomic phis lowered");
+//STATISTIC(NumSimple, "Number of simple phis lowered");
+
 namespace {
-  static Statistic NumAtomic("phielim", "Number of atomic phis lowered");
-  static Statistic NumSimple("phielim", "Number of simple phis lowered");
-  
   struct VISIBILITY_HIDDEN PNE : public MachineFunctionPass {
+    static char ID; // Pass identification, replacement for typeid
+    PNE() : MachineFunctionPass((intptr_t)&ID) {}
+
     bool runOnMachineFunction(MachineFunction &Fn) {
       analyzePHINodes(Fn);
 
@@ -73,6 +76,7 @@ namespace {
     VRegPHIUse VRegPHIUseCount;
   };
 
+  char PNE::ID = 0;
   RegisterPass<PNE> X("phi-node-elimination",
                       "Eliminate PHI nodes for register allocation");
 }
@@ -138,6 +142,9 @@ void PNE::LowerAtomicPHINode(MachineBasicBlock &MBB,
   if (LV) {
     MachineInstr *PHICopy = prior(AfterPHIsIt);
 
+    // Increment use count of the newly created virtual register.
+    LV->getVarInfo(IncomingReg).NumUses++;
+
     // Add information to LiveVariables to know that the incoming value is
     // killed.  Note that because the value is defined in several places (once
     // each for each incoming block), the "def" block and instruction fields