Avoid deleting individual instructions until AFTER dead blocks have dropped
[oota-llvm.git] / lib / Transforms / Scalar / DecomposeMultiDimRefs.cpp
index a97389999e641f0c6efa9e15aa5d7c56300c0615..90301f8792c91eb71de770956181498a3b757817 100644 (file)
@@ -15,6 +15,9 @@
 #include "llvm/iOther.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Pass.h"
+#include "Support/StatisticReporter.h"
+
+static Statistic<> NumAdded("lowerrefs\t\t- New instructions added");
 
 namespace {
   struct DecomposePass : public BasicBlockPass {
@@ -112,6 +115,7 @@ void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) {
     if (!indexIsZero) {
       LastPtr = new GetElementPtrInst(LastPtr, Indices, "ptr1");
       NewInsts.push_back(cast<Instruction>(LastPtr));
+      ++NumAdded;
     }
       
     // Instruction 2: nextPtr2 = cast nextPtr1 to NextPtrTy
@@ -120,6 +124,7 @@ void DecomposePass::decomposeArrayRef(BasicBlock::iterator &BBI) {
     if (LastPtr->getType() != NextPtrTy) {
       LastPtr = new CastInst(LastPtr, NextPtrTy, "ptr2");
       NewInsts.push_back(cast<Instruction>(LastPtr));
+      ++NumAdded;
     }
   }