summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2010-07-12 10:36:48 +0000
committerGabor Greif <ggreif@gmail.com>2010-07-12 10:36:48 +0000
commita8b9df7bd96e0b0bc6dec448d30b7d72180b6595 (patch)
tree7e20ea4d0895649d903c2805551ec04f30d16b23
parent3472766f9eb7d66f234c390ce1b3a8b76f0ee9ce (diff)
downloadllvm-a8b9df7bd96e0b0bc6dec448d30b7d72180b6595.tar.gz
llvm-a8b9df7bd96e0b0bc6dec448d30b7d72180b6595.tar.bz2
llvm-a8b9df7bd96e0b0bc6dec448d30b7d72180b6595.tar.xz
cache dereferenced iterators
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108131 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp9
-rw-r--r--lib/Transforms/Scalar/TailRecursionElimination.cpp7
-rw-r--r--lib/VMCore/Instruction.cpp5
3 files changed, 12 insertions, 9 deletions
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp
index 2306a77670..febc872d93 100644
--- a/lib/Transforms/Scalar/TailDuplication.cpp
+++ b/lib/Transforms/Scalar/TailDuplication.cpp
@@ -206,13 +206,14 @@ static BasicBlock *FindObviousSharedDomOf(BasicBlock *SrcBlock,
// there is only one other pred, get it, otherwise we can't handle it.
PI = pred_begin(DstBlock); PE = pred_end(DstBlock);
BasicBlock *DstOtherPred = 0;
- if (*PI == SrcBlock) {
+ BasicBlock *P = *PI;
+ if (P == SrcBlock) {
if (++PI == PE) return 0;
- DstOtherPred = *PI;
+ DstOtherPred = P;
if (++PI != PE) return 0;
} else {
- DstOtherPred = *PI;
- if (++PI == PE || *PI != SrcBlock || ++PI != PE) return 0;
+ DstOtherPred = P;
+ if (++PI == PE || P != SrcBlock || ++PI != PE) return 0;
}
// We can handle two situations here: "if then" and "if then else" blocks. An
diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp
index a018130f7a..7403e3711e 100644
--- a/lib/Transforms/Scalar/TailRecursionElimination.cpp
+++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp
@@ -476,10 +476,11 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry,
// it will not show up as a predecessor.
for (pred_iterator PI = pred_begin(OldEntry), PE = pred_end(OldEntry);
PI != PE; ++PI) {
- if (*PI == &F->getEntryBlock())
- AccPN->addIncoming(AccumulatorRecursionEliminationInitVal, *PI);
+ BasicBlock *P = *PI;
+ if (P == &F->getEntryBlock())
+ AccPN->addIncoming(AccumulatorRecursionEliminationInitVal, P);
else
- AccPN->addIncoming(AccPN, *PI);
+ AccPN->addIncoming(AccPN, P);
}
// Add an incoming argument for the current block, which is computed by our
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index d3f62d0d08..9792adaaa1 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -286,9 +286,10 @@ bool Instruction::isUsedOutsideOfBlock(const BasicBlock *BB) const {
for (const_use_iterator UI = use_begin(), E = use_end(); UI != E; ++UI) {
// PHI nodes uses values in the corresponding predecessor block. For other
// instructions, just check to see whether the parent of the use matches up.
- const PHINode *PN = dyn_cast<PHINode>(*UI);
+ const User *U = *UI;
+ const PHINode *PN = dyn_cast<PHINode>(U);
if (PN == 0) {
- if (cast<Instruction>(*UI)->getParent() != BB)
+ if (cast<Instruction>(U)->getParent() != BB)
return true;
continue;
}