Skip to content

Commit 5ed14f1

Browse files
committed
Merge pull request swiftlang#10 from nadavrot/calee_analysis_branch
Remove the FunctionEnumeration data structure from CalleeAnalysis
2 parents 293d08e + 693f6af commit 5ed14f1

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

lib/SILAnalysis/BasicCalleeAnalysis.cpp

+3-17
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,15 @@
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+
// Check if Right's lexicographical order is greater than Left.
33+
return 1 == Right->getName().compare(Left->getName());
4834
});
4935

5036
// Remove duplicates.

test/SILAnalysis/function-order.sil

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import Builtin
1414
// CHECK-NEXT: public_bottom
1515
// CHECK-NEXT: public_middle
1616
// CHECK-NEXT: public_top
17-
// CHECK-NEXT: private_derived_foo
1817
// CHECK-NEXT: private_base_foo
18+
// CHECK-NEXT: private_derived_foo
1919
// CHECK-NEXT: call_private
2020
// CHECK-NEXT: internal_base_foo
2121
// CHECK-NEXT: internal_derived_foo

0 commit comments

Comments
 (0)