@@ -661,30 +661,16 @@ bool ObjCARCContract::run(Function &F, AAResults *A, DominatorTree *D) {
661661
662662 Value *Arg = cast<CallInst>(Inst)->getArgOperand (0 );
663663
664- // TODO: Change this to a do-while.
665- for (;;) {
666- ReplaceArgUses (Arg);
667-
668- // If Arg is a no-op casted pointer, strip one level of casts and iterate.
669- if (const BitCastInst *BI = dyn_cast<BitCastInst>(Arg))
670- Arg = BI->getOperand (0 );
671- else if (isa<GEPOperator>(Arg) &&
672- cast<GEPOperator>(Arg)->hasAllZeroIndices ())
673- Arg = cast<GEPOperator>(Arg)->getPointerOperand ();
674- else if (isa<GlobalAlias>(Arg) &&
675- !cast<GlobalAlias>(Arg)->isInterposable ())
676- Arg = cast<GlobalAlias>(Arg)->getAliasee ();
677- else {
678- // If Arg is a PHI node, get PHIs that are equivalent to it and replace
679- // their uses.
680- if (PHINode *PN = dyn_cast<PHINode>(Arg)) {
681- SmallVector<Value *, 1 > PHIList;
682- getEquivalentPHIs (*PN, PHIList);
683- for (Value *PHI : PHIList)
684- ReplaceArgUses (PHI);
685- }
686- break ;
687- }
664+ ReplaceArgUses (Arg);
665+
666+ Arg = Arg->stripPointerCastsAndAliases ();
667+ // If Arg is a PHI node, get PHIs that are equivalent to it and replace
668+ // their uses.
669+ if (PHINode *PN = dyn_cast<PHINode>(Arg)) {
670+ SmallVector<Value *, 1 > PHIList;
671+ getEquivalentPHIs (*PN, PHIList);
672+ for (Value *PHI : PHIList)
673+ ReplaceArgUses (PHI);
688674 }
689675 }
690676
0 commit comments