Skip to content

Commit

Permalink
[Transform][ObjCARC] Change the 'for(;;)' to a do-while
Browse files Browse the repository at this point in the history
At the moment, there is a TODO item in ObjCARC just to change
'for (;;)' to a do-while. And it is the only place using 'for (;;)'
in llvm. In contrary, there are many places using the do-while.
It is reasonable to change the 'for(;;)' to a do-while.

This commit change the 'for(;;)' to a do-while and eliminate some
discord in the code.
  • Loading branch information
zhanyi22333 committed Feb 29, 2024
1 parent afa6b5e commit b0810e7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,7 @@ bool ObjCARCContract::run(Function &F, AAResults *A, DominatorTree *D) {
Value *Arg = cast<CallInst>(Inst)->getArgOperand(0);
Value *OrigArg = Arg;

// TODO: Change this to a do-while.
for (;;) {
do {
ReplaceArgUses(Arg);

// If Arg is a no-op casted pointer, strip one level of casts and iterate.
Expand All @@ -683,7 +682,7 @@ bool ObjCARCContract::run(Function &F, AAResults *A, DominatorTree *D) {
}
break;
}
}
} while (true);

// Replace bitcast users of Arg that are dominated by Inst.
SmallVector<BitCastInst *, 2> BitCastUsers;
Expand Down

0 comments on commit b0810e7

Please sign in to comment.