#include "llvm/Analysis/Expressions.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "Support/STLExtras.h"
+#include "Support/StatisticReporter.h"
#include <algorithm>
+static Statistic<> NumLoadStorePeepholes("raise\t\t- Number of load/store peepholes");
+static Statistic<> NumGEPInstFormed("raise\t\t- Number of other getelementptr's formed");
+static Statistic<> NumExprTreesConv("raise\t\t- Number of expression trees converted");
+static Statistic<> NumCastOfCast("raise\t\t- Number of cast-of-self removed");
+static Statistic<> NumDCEorCP("raise\t\t- Number of insts DCE'd or constprop'd");
+
+
//#define DEBUG_PEEPHOLE_INSTS 1
#ifdef DEBUG_PEEPHOLE_INSTS
CI->setName("");
Src->setName(Name, BB->getParent()->getSymbolTable());
}
+
+ // DCE the instruction now, to avoid having the iterative version of DCE
+ // have to worry about it.
+ //
+ delete BB->getInstList().remove(BI);
+
+ ++NumCastOfCast;
return true;
}
#ifdef DEBUG_PEEPHOLE_INSTS
cerr << "DONE CONVERTING SRC EXPR TYPE: \n" << BB->getParent();
#endif
+ ++NumExprTreesConv;
return true;
}
#ifdef DEBUG_PEEPHOLE_INSTS
cerr << "DONE CONVERTING EXPR TYPE: \n\n" << BB->getParent();
#endif
+ ++NumExprTreesConv;
return true;
}
}
if (const PointerType *DestPTy = dyn_cast<PointerType>(DestTy)) {
if (HandleCastToPointer(BI, DestPTy)) {
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
+ ++NumGEPInstFormed;
return true;
}
}
CI->setOperand(0, GEP);
PRINT_PEEPHOLE2("cast-for-first:out", GEP, CI);
+ ++NumGEPInstFormed;
return true;
}
}
ReplaceInstWithInst(BB->getInstList(), BI,
SI = new StoreInst(NCI, CastSrc));
PRINT_PEEPHOLE3("st-src-cast:out", NCI, CastSrc, SI);
+ ++NumLoadStorePeepholes;
return true;
}
isa<CastInst>(I->getOperand(1))) {
if (PeepholeOptimizeAddCast(BB, BI, I->getOperand(0),
- cast<CastInst>(I->getOperand(1))))
+ cast<CastInst>(I->getOperand(1)))) {
+ ++NumGEPInstFormed;
return true;
-
+ }
#endif
}
#endif
if (dceInstruction(BIL, BI) || doConstantPropogation(BB, BI)) {
Changed = true;
+ ++NumDCEorCP;
#ifdef DEBUG_PEEPHOLE_INSTS
cerr << "***\t\t^^-- DeadCode Elinated!\n";
#endif