cache dereferenced iterators
authorGabor Greif <ggreif@gmail.com>
Mon, 12 Jul 2010 10:36:48 +0000 (10:36 +0000)
committerGabor Greif <ggreif@gmail.com>
Mon, 12 Jul 2010 10:36:48 +0000 (10:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108131 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/TailDuplication.cpp
lib/Transforms/Scalar/TailRecursionElimination.cpp
lib/VMCore/Instruction.cpp

index 2306a77670fe4464b4b9f8c9f528b6e956849d81..febc872d930ca74f191990e70b7150daeaced395 100644 (file)
@@ -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
index a018130f7a00d247a6c5653e2a903b50a8409486..7403e3711e713ab47063e91f5ab1b3964b7026c5 100644 (file)
@@ -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
index d3f62d0d08fa81b8ced9f9507a699e8118da6430..9792adaaa122d889c26fa7a6d7677396bc1b9ca3 100644 (file)
@@ -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;
     }