summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LowerAllocations.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-05-10 15:38:35 +0000
committerChris Lattner <sabre@nondot.org>2002-05-10 15:38:35 +0000
commit3dec1f272219ee1f8e1499929cdf53f5bc3c2272 (patch)
tree5f1b55fbf194e79beb850cf398cc39d13071c0d7 /lib/Transforms/Utils/LowerAllocations.cpp
parent55547274bc3ef98165275da8b0f9af24c268dcf5 (diff)
downloadllvm-3dec1f272219ee1f8e1499929cdf53f5bc3c2272.tar.gz
llvm-3dec1f272219ee1f8e1499929cdf53f5bc3c2272.tar.bz2
llvm-3dec1f272219ee1f8e1499929cdf53f5bc3c2272.tar.xz
Add support for printing out statistics information when -stats is added to
the command line git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2601 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LowerAllocations.cpp')
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp7
1 files changed, 6 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;
}
}