Skip to content

Commit d78c4db

Browse files
committed
[CalleeAnalysis] Remove the enumeration of functions in the module for sorting.
Use the function name to sort the calees, not their order in the module.
1 parent 293d08e commit d78c4db

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

lib/SILAnalysis/BasicCalleeAnalysis.cpp

+2-17
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,14 @@
2222
using namespace swift;
2323

2424
void CalleeCache::sortAndUniqueCallees() {
25-
llvm::DenseMap<SILFunction *, unsigned int> FunctionEnumeration;
26-
27-
// Enumerate the functions in the module to use as keys in sorting.
28-
unsigned int count = 0;
29-
for (auto &F : M)
30-
FunctionEnumeration[&F] = count++;
31-
32-
auto Lookup = [&FunctionEnumeration](SILFunction *F) -> unsigned int {
33-
auto It = FunctionEnumeration.find(F);
34-
assert(It != FunctionEnumeration.end() &&
35-
"Function unexpectedly not found in enumeration!");
36-
37-
return It->second;
38-
};
39-
4025
// Sort the callees for each decl and remove duplicates.
4126
for (auto &Pair : TheCache) {
4227
auto &Callees = *Pair.second.getPointer();
4328

4429
// Sort by enumeration number so that clients get a stable order.
4530
std::sort(Callees.begin(), Callees.end(),
46-
[&Lookup](SILFunction *Left, SILFunction *Right) {
47-
return Lookup(Left) < Lookup(Right);
31+
[](SILFunction *Left, SILFunction *Right) {
32+
return Left->getName().compare(Right->getName());
4833
});
4934

5035
// Remove duplicates.

0 commit comments

Comments
 (0)