@@ -514,9 +514,8 @@ runFunctionPasses(unsigned FromTransIdx, unsigned ToTransIdx) {
514514 return ;
515515
516516 BasicCalleeAnalysis *BCA = getAnalysis<BasicCalleeAnalysis>();
517- BottomUpFunctionOrder BottomUpOrder (BCA);
518- BottomUpOrder.computeBottomUpOrder (Mod);
519- auto BottomUpFunctions = BottomUpOrder.getBottomUpOrder ();
517+ BottomUpFunctionOrder BottomUpOrder (*Mod, BCA);
518+ auto BottomUpFunctions = BottomUpOrder.getFunctions ();
520519
521520 assert (FunctionWorklist.empty () && " Expected empty function worklist!" );
522521
@@ -569,47 +568,6 @@ runFunctionPasses(unsigned FromTransIdx, unsigned ToTransIdx) {
569568 ++Entry.PipelineIdx ;
570569 }
571570 clearRestartPipeline ();
572-
573- if (TailIdx == (FunctionWorklist.size () - 1 )) {
574- // No new functions to process
575- continue ;
576- }
577-
578- // Compute the bottom up order of the new functions and the callees in it
579- BottomUpFunctionOrder SubBottomUpOrder (BCA);
580- // Initialize BottomUpFunctionOrder with new functions
581- for (auto It = FunctionWorklist.begin () + TailIdx + 1 ;
582- It != FunctionWorklist.end (); It++) {
583- SubBottomUpOrder.computeBottomUpOrder (It->F );
584- }
585- auto NewFunctionsBottomUp = SubBottomUpOrder.getBottomUpOrder ();
586- SmallPtrSet<SILFunction *, 8 > NewBottomUpSet (NewFunctionsBottomUp.begin (),
587- NewFunctionsBottomUp.end ());
588-
589- // Remove all the functions in the new bottom up order from FunctionWorklist
590- llvm::DenseMap<SILFunction *, WorklistEntry> FunctionsToReorder;
591- auto RemoveFn = [&FunctionsToReorder,
592- &NewBottomUpSet](WorklistEntry Entry) {
593- if (NewBottomUpSet.find (Entry.F ) == NewBottomUpSet.end ()) {
594- return false ;
595- }
596- FunctionsToReorder.insert (std::make_pair (Entry.F , Entry));
597- return true ;
598- };
599- std::remove_if (FunctionWorklist.begin (), FunctionWorklist.end (), RemoveFn);
600- FunctionWorklist.erase ((FunctionWorklist.begin () + FunctionWorklist.size () -
601- FunctionsToReorder.size ()),
602- FunctionWorklist.end ());
603-
604- // Add back the functions in the new bottom up order to the FunctionWorklist
605- for (auto it = NewFunctionsBottomUp.rbegin ();
606- it != NewFunctionsBottomUp.rend (); it++) {
607- auto Entry = FunctionsToReorder.find (*it);
608- if (Entry == FunctionsToReorder.end ()) {
609- continue ;
610- }
611- FunctionWorklist.push_back ((*Entry).second );
612- }
613571 }
614572}
615573
0 commit comments