diff --git a/include/swift/SILAnalysis/Analysis.h b/include/swift/SILAnalysis/Analysis.h index 7dcd7fc1780..0c3e978ed02 100644 --- a/include/swift/SILAnalysis/Analysis.h +++ b/include/swift/SILAnalysis/Analysis.h @@ -75,7 +75,6 @@ namespace swift { } void bottomUpCallGraphOrder(std::vector &order); - void topDownCallGraphOrder(std::vector &order); virtual void invalidate(InvalidationKind K) { // TODO: invalidate the cache once we implement one. diff --git a/include/swift/SILPasses/Utils/Local.h b/include/swift/SILPasses/Utils/Local.h index 84374c2f504..9e5c0b28430 100644 --- a/include/swift/SILPasses/Utils/Local.h +++ b/include/swift/SILPasses/Utils/Local.h @@ -58,10 +58,6 @@ namespace swift { /// include functions that don't participate in any call (caller or callee). void bottomUpCallGraphOrder(SILModule *M, std::vector &order); - /// Return the top-down call-graph order for module M. Notice that we don't - /// include functions that don't participate in any call (caller or callee). - void topDownCallGraphOrder(SILModule *M, std::vector &order); - /// Does the passed in BuiltinFunctionRefInst have any side effects? bool isSideEffectFree(BuiltinFunctionRefInst *FR); diff --git a/lib/SILAnalysis/Analysis.cpp b/lib/SILAnalysis/Analysis.cpp index 08d3de2a8b7..3cf4386af1f 100644 --- a/lib/SILAnalysis/Analysis.cpp +++ b/lib/SILAnalysis/Analysis.cpp @@ -28,13 +28,6 @@ CallGraphAnalysis::bottomUpCallGraphOrder(std::vector &order) { swift::bottomUpCallGraphOrder(M, order); } -void -CallGraphAnalysis::topDownCallGraphOrder(std::vector &order) { - // TODO: cache this calculation. - swift::topDownCallGraphOrder(M, order); -} - - SILAnalysis *swift::createCallGraphAnalysis(SILModule *M) { return new CallGraphAnalysis(M); } diff --git a/lib/SILPasses/PerformanceInliner.cpp b/lib/SILPasses/PerformanceInliner.cpp index 2c17d93fa1a..036af6866eb 100644 --- a/lib/SILPasses/PerformanceInliner.cpp +++ b/lib/SILPasses/PerformanceInliner.cpp @@ -375,7 +375,8 @@ public: // Collect a call-graph bottom-up list of functions. std::vector Worklist; - CGA->topDownCallGraphOrder(Worklist); + CGA->bottomUpCallGraphOrder(Worklist); + std::reverse(Worklist.begin(), Worklist.end()); SILPerformanceInliner inliner(Threshold); diff --git a/lib/SILPasses/Utils/Local.cpp b/lib/SILPasses/Utils/Local.cpp index 835b03cb39d..b9bdafe1874 100644 --- a/lib/SILPasses/Utils/Local.cpp +++ b/lib/SILPasses/Utils/Local.cpp @@ -187,20 +187,3 @@ void swift::bottomUpCallGraphOrder(SILModule *M, sorter.sort(order); } - -void swift::topDownCallGraphOrder(SILModule *M, - std::vector &order) { - CallGraphSorter sorter; - - // NOTE: we are inserting edges in reverse to get the top-down call graph. - for (auto &Caller : *M) - for (auto &BB : Caller) - for (auto &I : BB) - if (FunctionRefInst *FRI = dyn_cast(&I)) { - SILFunction *Callee = FRI->getReferencedFunction(); - sorter.addEdge(Callee, &Caller); - } - - // Perform the topological sorting. - sorter.sort(order); -}