aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp7
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp5
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index e5bf88fc00..80eab61b75 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -15,6 +15,9 @@
#include "llvm/Constants.h"
#include "llvm/Pass.h"
#include "llvm/Target/TargetData.h"
+#include "Support/StatisticReporter.h"
+
+static Statistic<> NumLowered("lowerallocs\t- Number of allocations lowered");
using std::vector;
namespace {
@@ -81,7 +84,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock *BB) {
assert(MallocFunc && FreeFunc && BB && "Pass not initialized!");
// Loop over all of the instructions, looking for malloc or free instructions
- for (unsigned i = 0; i < BB->size(); ++i) {
+ for (unsigned i = 0; i != BB->size(); ++i) {
BasicBlock::InstListType &BBIL = BB->getInstList();
if (MallocInst *MI = dyn_cast<MallocInst>(*(BBIL.begin()+i))) {
BBIL.remove(BBIL.begin()+i); // remove the malloc instr...
@@ -116,6 +119,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock *BB) {
MI->replaceAllUsesWith(MCast);
delete MI; // Delete the malloc inst
Changed = true;
+ ++NumLowered;
} else if (FreeInst *FI = dyn_cast<FreeInst>(*(BBIL.begin()+i))) {
BBIL.remove(BB->getInstList().begin()+i);
@@ -132,6 +136,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock *BB) {
// Delete the old free instruction
delete FI;
Changed = true;
+ ++NumLowered;
}
}
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index f67e6d671f..1afb11a986 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -26,6 +26,9 @@
#include "llvm/BasicBlock.h"
#include "llvm/Constant.h"
#include "llvm/Type.h"
+#include "Support/StatisticReporter.h"
+
+static Statistic<> NumPromoted("mem2reg\t\t- Number of alloca's promoted");
using std::vector;
using std::map;
@@ -187,6 +190,8 @@ bool PromotePass::runOnFunction(Function *F) {
delete I;
}
+ NumPromoted += Allocas.size();
+
// Purge data structurse so they are available the next iteration...
Allocas.clear();
AllocaLookup.clear();