Skip to content

Commit 8dcfa13

Browse files
committed
StructurizeCFG: Use phi iterator range
llvm-svn: 321568
1 parent 344c092 commit 8dcfa13

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

llvm/lib/Transforms/Scalar/StructurizeCFG.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -544,10 +544,7 @@ void StructurizeCFG::insertConditions(bool Loops) {
544544
/// them in DeletedPhis
545545
void StructurizeCFG::delPhiValues(BasicBlock *From, BasicBlock *To) {
546546
PhiMap &Map = DeletedPhis[To];
547-
for (Instruction &I : *To) {
548-
if (!isa<PHINode>(I))
549-
break;
550-
PHINode &Phi = cast<PHINode>(I);
547+
for (PHINode &Phi : To->phis()) {
551548
while (Phi.getBasicBlockIndex(From) != -1) {
552549
Value *Deleted = Phi.removeIncomingValue(From, false);
553550
Map[&Phi].push_back(std::make_pair(From, Deleted));
@@ -557,10 +554,7 @@ void StructurizeCFG::delPhiValues(BasicBlock *From, BasicBlock *To) {
557554

558555
/// \brief Add a dummy PHI value as soon as we knew the new predecessor
559556
void StructurizeCFG::addPhiValues(BasicBlock *From, BasicBlock *To) {
560-
for (Instruction &I : *To) {
561-
if (!isa<PHINode>(I))
562-
break;
563-
PHINode &Phi = cast<PHINode>(I);
557+
for (PHINode &Phi : To->phis()) {
564558
Value *Undef = UndefValue::get(Phi.getType());
565559
Phi.addIncoming(Undef, From);
566560
}

0 commit comments

Comments
 (0)