Skip to content

Commit 3a7b5f5

Browse files
[Prototype] Keep call unique
1 parent 09d81ce commit 3a7b5f5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/Serialization/ModuleSummaryIndexer.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ class FunctionSummaryIndexer : public SILInstructionVisitor<FunctionSummaryIndex
3030
std::unique_ptr<FunctionSummary> TheSummary;
3131

3232
std::set<GUID> RecordedTypes;
33+
std::set<GUID> RecordedDirectTargets;
34+
std::set<GUID> RecordedVTableTargets;
35+
std::set<GUID> RecordedWitnessTargets;
3336

3437
void indexDirectFunctionCall(const SILFunction &Callee);
3538
void indexIndirectFunctionCall(const SILDeclRef &Callee,
@@ -95,6 +98,9 @@ class FunctionSummaryIndexer : public SILInstructionVisitor<FunctionSummaryIndex
9598
void FunctionSummaryIndexer::indexDirectFunctionCall(
9699
const SILFunction &Callee) {
97100
GUID guid = getGUIDFromUniqueName(Callee.getName());
101+
if (!RecordedDirectTargets.insert(guid).second) {
102+
return;
103+
}
98104
FunctionSummary::Call call(guid, Callee.getName(),
99105
FunctionSummary::Call::Direct);
100106
TheSummary->addCall(call);
@@ -104,6 +110,11 @@ void FunctionSummaryIndexer::indexIndirectFunctionCall(
104110
const SILDeclRef &Callee, FunctionSummary::Call::KindTy Kind) {
105111
std::string mangledName = Callee.mangle();
106112
GUID guid = getGUIDFromUniqueName(mangledName);
113+
std::set<GUID> &RecordedTargets = Kind == FunctionSummary::Call::VTable ?
114+
RecordedVTableTargets : RecordedWitnessTargets;
115+
if (!RecordedTargets.insert(guid).second) {
116+
return;
117+
}
107118
FunctionSummary::Call call(guid, mangledName, Kind);
108119
TheSummary->addCall(call);
109120
}

0 commit comments

Comments
 (0)