summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/StructRetPromotion.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-03-04 17:44:37 +0000
committerDevang Patel <dpatel@apple.com>2008-03-04 17:44:37 +0000
commit98a6e067df5f6a17c12ad68fed5586e238575275 (patch)
treef82b36a43d67aa4d71321f770bcdcdfd91fd3ee4 /lib/Transforms/IPO/StructRetPromotion.cpp
parente6074a027fd78939cc69a8c5db72f789b4e1b2c7 (diff)
downloadllvm-98a6e067df5f6a17c12ad68fed5586e238575275.tar.gz
llvm-98a6e067df5f6a17c12ad68fed5586e238575275.tar.bz2
llvm-98a6e067df5f6a17c12ad68fed5586e238575275.tar.xz
Collect statistics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/StructRetPromotion.cpp')
-rw-r--r--lib/Transforms/IPO/StructRetPromotion.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp
index 298b5b1c1f..3ea9a04adb 100644
--- a/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/lib/Transforms/IPO/StructRetPromotion.cpp
@@ -24,9 +24,12 @@
#include "llvm/Support/Debug.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
using namespace llvm;
+STATISTIC(NumRejectedSRETUses , "Number of sret rejected due to unexpected uses");
+STATISTIC(NumSRET , "Number of sret promoted");
namespace {
/// SRETPromotion - This pass removes sret parameter and updates
/// function to use multiple return value.
@@ -87,15 +90,18 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
assert (STy && "Invalid sret parameter element type");
// Check if it is ok to perform this promotion.
- if (isSafeToUpdateAllCallers(F) == false)
+ if (isSafeToUpdateAllCallers(F) == false) {
+ NumRejectedSRETUses++;
return false;
+ }
// [1] Replace use of sret parameter
- AllocaInst *TheAlloca = new AllocaInst (STy, NULL, "mrv", F->getEntryBlock().begin());
+ AllocaInst *TheAlloca = new AllocaInst (STy, NULL, "mrv",
+ F->getEntryBlock().begin());
Value *NFirstArg = F->arg_begin();
NFirstArg->replaceAllUsesWith(TheAlloca);
- // Find and replace ret instructions
+ // [2] Find and replace ret instructions
SmallVector<Value *,4> RetVals;
for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI)
for(BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ) {
@@ -119,10 +125,10 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
}
}
- // Create the new function body and insert it into the module.
+ // [3] Create the new function body and insert it into the module.
Function *NF = cloneFunctionBody(F, STy);
- // Update all call sites to use new function
+ // [4] Update all call sites to use new function
updateCallSites(F, NF);
F->eraseFromParent();