@@ -1198,27 +1198,6 @@ TrampolineDest::TrampolineDest(SILBasicBlock *sourceBB,
11981198 destBB = targetBranch->getDestBB ();
11991199}
12001200
1201- // / \return If this is a basic block without any arguments and it has
1202- // / a single br instruction, return this br.
1203- static BranchInst *getTrampolineWithoutBBArgsTerminator (SILBasicBlock *SBB) {
1204- if (!SBB->args_empty ())
1205- return nullptr ;
1206-
1207- // Ignore blocks with more than one instruction.
1208- if (!onlyHasTerminatorAndDebugInsts (SBB))
1209- return nullptr ;
1210-
1211- auto *BI = dyn_cast<BranchInst>(SBB->getTerminator ());
1212- if (!BI)
1213- return nullptr ;
1214-
1215- // Disallow infinite loops.
1216- if (BI->getDestBB () == SBB)
1217- return nullptr ;
1218-
1219- return BI;
1220- }
1221-
12221201#ifndef NDEBUG
12231202// / Is the block reachable from the entry.
12241203static bool isReachable (SILBasicBlock *Block) {
@@ -1392,20 +1371,6 @@ bool SimplifyCFG::simplifyBranchBlock(BranchInst *BI) {
13921371 return Simplified;
13931372}
13941373
1395- // / Check if replacing an existing edge of the terminator by another
1396- // / one which has a DestBB as its destination would create a critical edge.
1397- static bool wouldIntroduceCriticalEdge (TermInst *T, SILBasicBlock *DestBB) {
1398- auto SrcSuccs = T->getSuccessors ();
1399- if (SrcSuccs.size () <= 1 )
1400- return false ;
1401-
1402- assert (!DestBB->pred_empty () && " There should be a predecessor" );
1403- if (DestBB->getSinglePredecessorBlock ())
1404- return false ;
1405-
1406- return true ;
1407- }
1408-
14091374// / Returns the original boolean value, looking through possible invert
14101375// / builtins. The parameter \p Inverted is inverted if the returned original
14111376// / value is the inverted value of the passed \p Cond.
@@ -1633,44 +1598,6 @@ bool SimplifyCFG::simplifyCondBrBlock(CondBranchInst *BI) {
16331598 removeIfDead (FalseSide);
16341599 return true ;
16351600 }
1636- auto *TrueTrampolineBr = getTrampolineWithoutBBArgsTerminator (TrueSide);
1637- if (TrueTrampolineBr &&
1638- !wouldIntroduceCriticalEdge (BI, TrueTrampolineBr->getDestBB ())) {
1639- LLVM_DEBUG (llvm::dbgs () << " true-trampoline from bb" << ThisBB->getDebugID ()
1640- << " to bb"
1641- << TrueTrampolineBr->getDestBB ()->getDebugID ()
1642- << ' \n ' );
1643- SILBuilderWithScope (BI).createCondBranch (
1644- BI->getLoc (), BI->getCondition (), TrueTrampolineBr->getDestBB (),
1645- TrueTrampolineBr->getArgs (), FalseSide, FalseArgs, BI->getTrueBBCount (),
1646- BI->getFalseBBCount ());
1647- BI->eraseFromParent ();
1648-
1649- if (LoopHeaders.count (TrueSide))
1650- LoopHeaders.insert (ThisBB);
1651- removeIfDead (TrueSide);
1652- addToWorklist (ThisBB);
1653- return true ;
1654- }
1655-
1656- auto *FalseTrampolineBr = getTrampolineWithoutBBArgsTerminator (FalseSide);
1657- if (FalseTrampolineBr &&
1658- !wouldIntroduceCriticalEdge (BI, FalseTrampolineBr->getDestBB ())) {
1659- LLVM_DEBUG (llvm::dbgs () << " false-trampoline from bb"
1660- << ThisBB->getDebugID () << " to bb"
1661- << FalseTrampolineBr->getDestBB ()->getDebugID ()
1662- << ' \n ' );
1663- SILBuilderWithScope (BI).createCondBranch (
1664- BI->getLoc (), BI->getCondition (), TrueSide, TrueArgs,
1665- FalseTrampolineBr->getDestBB (), FalseTrampolineBr->getArgs (),
1666- BI->getTrueBBCount (), BI->getFalseBBCount ());
1667- BI->eraseFromParent ();
1668- if (LoopHeaders.count (FalseSide))
1669- LoopHeaders.insert (ThisBB);
1670- removeIfDead (FalseSide);
1671- addToWorklist (ThisBB);
1672- return true ;
1673- }
16741601 // If we have a (cond (select_enum)) on a two element enum, always have the
16751602 // first case as our checked tag. If we have the second, create a new
16761603 // select_enum with the first case and swap our operands. This simplifies
0 commit comments