Fixed bug in the serialization of SelectorTable where we did not register the
pointer of MultiKeywordSelectors.
Added optimization to the serialization of SelectorTable where we only serialize
out MultiKeywordSelectors that are ever referenced by an object other than the
SelectorTable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44483 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Basic/IdentifierTable.cpp b/Basic/IdentifierTable.cpp
index 5459d60..3d1ef1f 100644
--- a/Basic/IdentifierTable.cpp
+++ b/Basic/IdentifierTable.cpp
@@ -507,7 +507,12 @@
S.EmitPtr(this);
for (iterator I=SelTab->begin(), E=SelTab->end(); I != E; ++I) {
+ if (!S.isRegistered(&*I))
+ continue;
+
S.FlushRecord(); // Start a new record.
+
+ S.EmitPtr(&*I);
S.EmitInt(I->getNumArgs());
for (MultiKeywordSelector::keyword_iterator KI = I->keyword_begin(),
@@ -528,6 +533,8 @@
*static_cast<llvm::FoldingSet<MultiKeywordSelector>*>(t->Impl);
while (!D.FinishedBlock(BLoc)) {
+
+ llvm::SerializedPtrID PtrID = D.ReadPtrID();
unsigned nKeys = D.ReadInt();
MultiKeywordSelector *SI =
@@ -535,6 +542,8 @@
nKeys*sizeof(IdentifierInfo *));
new (SI) MultiKeywordSelector(nKeys);
+
+ D.RegisterPtr(PtrID,SI);
IdentifierInfo **KeyInfo = reinterpret_cast<IdentifierInfo **>(SI+1);