diff --git a/lib/SILAnalysis/BasicCalleeAnalysis.cpp b/lib/SILAnalysis/BasicCalleeAnalysis.cpp index 6aa36a30cbc85..98f082df2f186 100644 --- a/lib/SILAnalysis/BasicCalleeAnalysis.cpp +++ b/lib/SILAnalysis/BasicCalleeAnalysis.cpp @@ -22,29 +22,15 @@ using namespace swift; void CalleeCache::sortAndUniqueCallees() { - llvm::DenseMap FunctionEnumeration; - - // Enumerate the functions in the module to use as keys in sorting. - unsigned int count = 0; - for (auto &F : M) - FunctionEnumeration[&F] = count++; - - auto Lookup = [&FunctionEnumeration](SILFunction *F) -> unsigned int { - auto It = FunctionEnumeration.find(F); - assert(It != FunctionEnumeration.end() && - "Function unexpectedly not found in enumeration!"); - - return It->second; - }; - // Sort the callees for each decl and remove duplicates. for (auto &Pair : TheCache) { auto &Callees = *Pair.second.getPointer(); // Sort by enumeration number so that clients get a stable order. std::sort(Callees.begin(), Callees.end(), - [&Lookup](SILFunction *Left, SILFunction *Right) { - return Lookup(Left) < Lookup(Right); + [](SILFunction *Left, SILFunction *Right) { + // Check if Right's lexicographical order is greater than Left. + return 1 == Right->getName().compare(Left->getName()); }); // Remove duplicates. diff --git a/test/SILAnalysis/function-order.sil b/test/SILAnalysis/function-order.sil index 0a19e6819e757..340101ee8ff4f 100644 --- a/test/SILAnalysis/function-order.sil +++ b/test/SILAnalysis/function-order.sil @@ -14,8 +14,8 @@ import Builtin // CHECK-NEXT: public_bottom // CHECK-NEXT: public_middle // CHECK-NEXT: public_top -// CHECK-NEXT: private_derived_foo // CHECK-NEXT: private_base_foo +// CHECK-NEXT: private_derived_foo // CHECK-NEXT: call_private // CHECK-NEXT: internal_base_foo // CHECK-NEXT: internal_derived_foo