summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/ArgumentPromotion.cpp
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2010-07-12 14:15:10 +0000
committerGabor Greif <ggreif@gmail.com>2010-07-12 14:15:10 +0000
commita53029b1fcc71b1482863a7031ddb0c48d7a1177 (patch)
tree58aafc8f0e7493954cf31b7762d524115dedd890 /lib/Transforms/IPO/ArgumentPromotion.cpp
parent65b9212d344d97f7305f61048c1c87bd5ffa0c32 (diff)
downloadllvm-a53029b1fcc71b1482863a7031ddb0c48d7a1177.tar.gz
llvm-a53029b1fcc71b1482863a7031ddb0c48d7a1177.tar.bz2
llvm-a53029b1fcc71b1482863a7031ddb0c48d7a1177.tar.xz
cache result of operator*
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108146 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/ArgumentPromotion.cpp')
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index 89f213e2ac..28ea079abd 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -360,19 +360,20 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg, bool isByVal) const {
IndicesVector Operands;
for (Value::use_iterator UI = Arg->use_begin(), E = Arg->use_end();
UI != E; ++UI) {
+ User *U = *UI;
Operands.clear();
- if (LoadInst *LI = dyn_cast<LoadInst>(*UI)) {
+ if (LoadInst *LI = dyn_cast<LoadInst>(U)) {
if (LI->isVolatile()) return false; // Don't hack volatile loads
Loads.push_back(LI);
// Direct loads are equivalent to a GEP with a zero index and then a load.
Operands.push_back(0);
- } else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(*UI)) {
+ } else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(U)) {
if (GEP->use_empty()) {
// Dead GEP's cause trouble later. Just remove them if we run into
// them.
getAnalysis<AliasAnalysis>().deleteValue(GEP);
GEP->eraseFromParent();
- // TODO: This runs the above loop over and over again for dead GEPS
+ // TODO: This runs the above loop over and over again for dead GEPs
// Couldn't we just do increment the UI iterator earlier and erase the
// use?
return isSafeToPromoteArgument(Arg, isByVal);
@@ -452,12 +453,14 @@ bool ArgPromotion::isSafeToPromoteArgument(Argument *Arg, bool isByVal) const {
// Now check every path from the entry block to the load for transparency.
// To do this, we perform a depth first search on the inverse CFG from the
// loading block.
- for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI)
+ for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
+ BasicBlock *P = *PI;
for (idf_ext_iterator<BasicBlock*, SmallPtrSet<BasicBlock*, 16> >
- I = idf_ext_begin(*PI, TranspBlocks),
- E = idf_ext_end(*PI, TranspBlocks); I != E; ++I)
+ I = idf_ext_begin(P, TranspBlocks),
+ E = idf_ext_end(P, TranspBlocks); I != E; ++I)
if (AA.canBasicBlockModify(**I, Arg, LoadSize))
return false;
+ }
}
// If the path from the entry of the function to each load is free of