@@ -511,36 +511,41 @@ void SILGlobalOpt::placeInitializers(SILFunction *InitF,
511
511
ApplyInst *HoistAI =
512
512
getHoistedApplyForInitializer (AI, DT, InitF, ParentF, ParentFuncs);
513
513
514
- if (HoistAI) {
515
- // Move this call to the outermost loop preheader.
516
- SILBasicBlock *BB = HoistAI->getParent ();
517
- typedef llvm::DomTreeNodeBase<SILBasicBlock> DomTreeNode;
518
- DomTreeNode *Node = DT->getNode (BB);
519
- while (Node) {
520
- SILBasicBlock *DomParentBB = Node->getBlock ();
521
- if (isAvailabilityCheck (DomParentBB)) {
522
- DEBUG (llvm::dbgs () << " don't hoist above availability check at bb"
523
- << DomParentBB->getDebugID () << " \n " );
524
- break ;
525
- }
526
- BB = DomParentBB;
527
- if (!isInLoop (BB))
528
- break ;
529
- Node = Node->getIDom ();
530
- }
531
- if (BB == HoistAI->getParent ()) {
532
- // BB is either unreachable or not in a loop.
533
- DEBUG (llvm::dbgs () << " skipping (not in a loop): " << *HoistAI
534
- << " in " << HoistAI->getFunction ()->getName () << " \n " );
535
- }
536
- else {
537
- DEBUG (llvm::dbgs () << " hoisting: " << *HoistAI
538
- << " in " << HoistAI->getFunction ()->getName () << " \n " );
539
- HoistAI->moveBefore (&*BB->begin ());
540
- placeFuncRef (HoistAI, DT);
541
- HasChanged = true ;
514
+ // If we were unable to find anything, just go onto the next apply.
515
+ if (!HoistAI) {
516
+ continue ;
517
+ }
518
+
519
+ // Otherwise, move this call to the outermost loop preheader.
520
+ SILBasicBlock *BB = HoistAI->getParent ();
521
+ typedef llvm::DomTreeNodeBase<SILBasicBlock> DomTreeNode;
522
+ DomTreeNode *Node = DT->getNode (BB);
523
+ while (Node) {
524
+ SILBasicBlock *DomParentBB = Node->getBlock ();
525
+ if (isAvailabilityCheck (DomParentBB)) {
526
+ DEBUG (llvm::dbgs () << " don't hoist above availability check at bb"
527
+ << DomParentBB->getDebugID () << " \n " );
528
+ break ;
542
529
}
530
+ BB = DomParentBB;
531
+ if (!isInLoop (BB))
532
+ break ;
533
+ Node = Node->getIDom ();
534
+ }
535
+
536
+ if (BB == HoistAI->getParent ()) {
537
+ // BB is either unreachable or not in a loop.
538
+ DEBUG (llvm::dbgs () << " skipping (not in a loop): " << *HoistAI
539
+ << " in " << HoistAI->getFunction ()->getName ()
540
+ << " \n " );
541
+ continue ;
543
542
}
543
+
544
+ DEBUG (llvm::dbgs () << " hoisting: " << *HoistAI << " in "
545
+ << HoistAI->getFunction ()->getName () << " \n " );
546
+ HoistAI->moveBefore (&*BB->begin ());
547
+ placeFuncRef (HoistAI, DT);
548
+ HasChanged = true ;
544
549
}
545
550
}
546
551
0 commit comments