Skip to content

Commit 12bdeba

Browse files
committed
Revert "[Serialization] Support load lazy specialization lazily"
This reverts commit b5bd192. It brokes multiple llvm bots including clang-x64-windows-msvc
1 parent 4a44e4b commit 12bdeba

27 files changed

+176
-1613
lines changed

clang/include/clang/AST/DeclTemplate.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,6 @@ class RedeclarableTemplateDecl : public TemplateDecl,
735735
}
736736

737737
void anchor() override;
738-
739738
protected:
740739
template <typename EntryType> struct SpecEntryTraits {
741740
using DeclType = EntryType;
@@ -776,22 +775,13 @@ class RedeclarableTemplateDecl : public TemplateDecl,
776775
return SpecIterator<EntryType>(isEnd ? Specs.end() : Specs.begin());
777776
}
778777

779-
void loadLazySpecializationsImpl(bool OnlyPartial = false) const;
780-
781-
bool loadLazySpecializationsImpl(llvm::ArrayRef<TemplateArgument> Args,
782-
TemplateParameterList *TPL = nullptr) const;
778+
void loadLazySpecializationsImpl() const;
783779

784780
template <class EntryType, typename ...ProfileArguments>
785781
typename SpecEntryTraits<EntryType>::DeclType*
786782
findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
787783
void *&InsertPos, ProfileArguments &&...ProfileArgs);
788784

789-
template <class EntryType, typename... ProfileArguments>
790-
typename SpecEntryTraits<EntryType>::DeclType *
791-
findSpecializationLocally(llvm::FoldingSetVector<EntryType> &Specs,
792-
void *&InsertPos,
793-
ProfileArguments &&...ProfileArgs);
794-
795785
template <class Derived, class EntryType>
796786
void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
797787
EntryType *Entry, void *InsertPos);
@@ -806,6 +796,13 @@ class RedeclarableTemplateDecl : public TemplateDecl,
806796
/// was explicitly specialized.
807797
llvm::PointerIntPair<RedeclarableTemplateDecl *, 1, bool>
808798
InstantiatedFromMember;
799+
800+
/// If non-null, points to an array of specializations (including
801+
/// partial specializations) known only by their external declaration IDs.
802+
///
803+
/// The first value in the array is the number of specializations/partial
804+
/// specializations that follow.
805+
GlobalDeclID *LazySpecializations = nullptr;
809806
};
810807

811808
/// Pointer to the common data shared by all declarations of this
@@ -2286,7 +2283,7 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl {
22862283
friend class TemplateDeclInstantiator;
22872284

22882285
/// Load any lazily-loaded specializations from the external source.
2289-
void LoadLazySpecializations(bool OnlyPartial = false) const;
2286+
void LoadLazySpecializations() const;
22902287

22912288
/// Get the underlying class declarations of the template.
22922289
CXXRecordDecl *getTemplatedDecl() const {
@@ -3036,7 +3033,7 @@ class VarTemplateDecl : public RedeclarableTemplateDecl {
30363033
friend class ASTDeclWriter;
30373034

30383035
/// Load any lazily-loaded specializations from the external source.
3039-
void LoadLazySpecializations(bool OnlyPartial = false) const;
3036+
void LoadLazySpecializations() const;
30403037

30413038
/// Get the underlying variable declarations of the template.
30423039
VarDecl *getTemplatedDecl() const {

clang/include/clang/AST/ExternalASTSource.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,6 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
152152
virtual bool
153153
FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name);
154154

155-
/// Load all the external specializations for the Decl \param D if \param
156-
/// OnlyPartial is false. Otherwise, load all the external **partial**
157-
/// specializations for the \param D.
158-
///
159-
/// Return true if any new specializations get loaded. Return false otherwise.
160-
virtual bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial);
161-
162-
/// Load all the specializations for the Decl \param D with the same template
163-
/// args specified by \param TemplateArgs.
164-
///
165-
/// Return true if any new specializations get loaded. Return false otherwise.
166-
virtual bool
167-
LoadExternalSpecializations(const Decl *D,
168-
ArrayRef<TemplateArgument> TemplateArgs);
169-
170155
/// Ensures that the table of all visible declarations inside this
171156
/// context is up to date.
172157
///

clang/include/clang/Sema/MultiplexExternalSemaSource.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,6 @@ class MultiplexExternalSemaSource : public ExternalSemaSource {
9797
bool FindExternalVisibleDeclsByName(const DeclContext *DC,
9898
DeclarationName Name) override;
9999

100-
bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial) override;
101-
102-
bool
103-
LoadExternalSpecializations(const Decl *D,
104-
ArrayRef<TemplateArgument> TemplateArgs) override;
105-
106100
/// Ensures that the table of all visible declarations inside this
107101
/// context is up to date.
108102
void completeVisibleDeclsMap(const DeclContext *DC) override;

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -733,13 +733,6 @@ enum ASTRecordTypes {
733733
/// Record code for Sema's vector of functions/blocks with effects to
734734
/// be verified.
735735
DECLS_WITH_EFFECTS_TO_VERIFY = 72,
736-
737-
/// Record code for updated specialization
738-
UPDATE_SPECIALIZATION = 73,
739-
740-
CXX_ADDED_TEMPLATE_SPECIALIZATION = 74,
741-
742-
CXX_ADDED_TEMPLATE_PARTIAL_SPECIALIZATION = 75,
743736
};
744737

745738
/// Record types used within a source manager block.
@@ -1509,12 +1502,6 @@ enum DeclCode {
15091502
/// An ImplicitConceptSpecializationDecl record.
15101503
DECL_IMPLICIT_CONCEPT_SPECIALIZATION,
15111504

1512-
// A decls specilization record.
1513-
DECL_SPECIALIZATIONS,
1514-
1515-
// A decls specilization record.
1516-
DECL_PARTIAL_SPECIALIZATIONS,
1517-
15181505
DECL_LAST = DECL_IMPLICIT_CONCEPT_SPECIALIZATION
15191506
};
15201507

clang/include/clang/Serialization/ASTReader.h

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,6 @@ class ASTIdentifierLookupTrait;
354354
/// The on-disk hash table(s) used for DeclContext name lookup.
355355
struct DeclContextLookupTable;
356356

357-
/// The on-disk hash table(s) used for specialization decls.
358-
struct LazySpecializationInfoLookupTable;
359-
360357
} // namespace reader
361358

362359
} // namespace serialization
@@ -635,40 +632,20 @@ class ASTReader
635632
llvm::DenseMap<const DeclContext *,
636633
serialization::reader::DeclContextLookupTable> Lookups;
637634

638-
using SpecLookupTableTy =
639-
llvm::DenseMap<const Decl *,
640-
serialization::reader::LazySpecializationInfoLookupTable>;
641-
/// Map from decls to specialized decls.
642-
SpecLookupTableTy SpecializationsLookups;
643-
/// Split partial specialization from specialization to speed up lookups.
644-
SpecLookupTableTy PartialSpecializationsLookups;
645-
646-
bool LoadExternalSpecializationsImpl(SpecLookupTableTy &SpecLookups,
647-
const Decl *D);
648-
bool LoadExternalSpecializationsImpl(SpecLookupTableTy &SpecLookups,
649-
const Decl *D,
650-
ArrayRef<TemplateArgument> TemplateArgs);
651-
652635
// Updates for visible decls can occur for other contexts than just the
653636
// TU, and when we read those update records, the actual context may not
654637
// be available yet, so have this pending map using the ID as a key. It
655-
// will be realized when the data is actually loaded.
656-
struct UpdateData {
638+
// will be realized when the context is actually loaded.
639+
struct PendingVisibleUpdate {
657640
ModuleFile *Mod;
658641
const unsigned char *Data;
659642
};
660-
using DeclContextVisibleUpdates = SmallVector<UpdateData, 1>;
643+
using DeclContextVisibleUpdates = SmallVector<PendingVisibleUpdate, 1>;
661644

662645
/// Updates to the visible declarations of declaration contexts that
663646
/// haven't been loaded yet.
664647
llvm::DenseMap<GlobalDeclID, DeclContextVisibleUpdates> PendingVisibleUpdates;
665648

666-
using SpecializationsUpdate = SmallVector<UpdateData, 1>;
667-
using SpecializationsUpdateMap =
668-
llvm::DenseMap<GlobalDeclID, SpecializationsUpdate>;
669-
SpecializationsUpdateMap PendingSpecializationsUpdates;
670-
SpecializationsUpdateMap PendingPartialSpecializationsUpdates;
671-
672649
/// The set of C++ or Objective-C classes that have forward
673650
/// declarations that have not yet been linked to their definitions.
674651
llvm::SmallPtrSet<Decl *, 4> PendingDefinitions;
@@ -701,11 +678,6 @@ class ASTReader
701678
llvm::BitstreamCursor &Cursor,
702679
uint64_t Offset, GlobalDeclID ID);
703680

704-
bool ReadSpecializations(ModuleFile &M, llvm::BitstreamCursor &Cursor,
705-
uint64_t Offset, Decl *D, bool IsPartial);
706-
void AddSpecializations(const Decl *D, const unsigned char *Data,
707-
ModuleFile &M, bool IsPartial);
708-
709681
/// A vector containing identifiers that have already been
710682
/// loaded.
711683
///
@@ -1447,14 +1419,6 @@ class ASTReader
14471419
const serialization::reader::DeclContextLookupTable *
14481420
getLoadedLookupTables(DeclContext *Primary) const;
14491421

1450-
/// Get the loaded specializations lookup tables for \p D,
1451-
/// if any.
1452-
serialization::reader::LazySpecializationInfoLookupTable *
1453-
getLoadedSpecializationsLookupTables(const Decl *D, bool IsPartial);
1454-
1455-
/// If we have any unloaded specialization for \p D
1456-
bool haveUnloadedSpecializations(const Decl *D) const;
1457-
14581422
private:
14591423
struct ImportedModule {
14601424
ModuleFile *Mod;
@@ -2112,12 +2076,6 @@ class ASTReader
21122076
unsigned BlockID,
21132077
uint64_t *StartOfBlockOffset = nullptr);
21142078

2115-
bool LoadExternalSpecializations(const Decl *D, bool OnlyPartial) override;
2116-
2117-
bool
2118-
LoadExternalSpecializations(const Decl *D,
2119-
ArrayRef<TemplateArgument> TemplateArgs) override;
2120-
21212079
/// Finds all the visible declarations with a given name.
21222080
/// The current implementation of this method just loads the entire
21232081
/// lookup table as unmaterialized references.

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,6 @@ class ASTWriter : public ASTDeserializationListener,
423423
/// Only meaningful for reduced BMI.
424424
DeclUpdateMap DeclUpdatesFromGMF;
425425

426-
/// Mapping from decl templates and its new specialization in the
427-
/// current TU.
428-
using SpecializationUpdateMap =
429-
llvm::MapVector<const NamedDecl *, SmallVector<const Decl *>>;
430-
SpecializationUpdateMap SpecializationsUpdates;
431-
SpecializationUpdateMap PartialSpecializationsUpdates;
432-
433426
using FirstLatestDeclMap = llvm::DenseMap<Decl *, Decl *>;
434427

435428
/// Map of first declarations from a chained PCH that point to the
@@ -582,12 +575,6 @@ class ASTWriter : public ASTDeserializationListener,
582575

583576
bool isLookupResultExternal(StoredDeclsList &Result, DeclContext *DC);
584577

585-
void GenerateSpecializationInfoLookupTable(
586-
const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
587-
llvm::SmallVectorImpl<char> &LookupTable, bool IsPartial);
588-
uint64_t WriteSpecializationInfoLookupTable(
589-
const NamedDecl *D, llvm::SmallVectorImpl<const Decl *> &Specializations,
590-
bool IsPartial);
591578
void GenerateNameLookupTable(ASTContext &Context, const DeclContext *DC,
592579
llvm::SmallVectorImpl<char> &LookupTable);
593580
uint64_t WriteDeclContextLexicalBlock(ASTContext &Context,
@@ -603,7 +590,6 @@ class ASTWriter : public ASTDeserializationListener,
603590
void WriteDeclAndTypes(ASTContext &Context);
604591
void PrepareWritingSpecialDecls(Sema &SemaRef);
605592
void WriteSpecialDeclRecords(Sema &SemaRef);
606-
void WriteSpecializationsUpdates(bool IsPartial);
607593
void WriteDeclUpdatesBlocks(ASTContext &Context,
608594
RecordDataImpl &OffsetsRecord);
609595
void WriteDeclContextVisibleUpdate(ASTContext &Context,
@@ -633,9 +619,6 @@ class ASTWriter : public ASTDeserializationListener,
633619
unsigned DeclEnumAbbrev = 0;
634620
unsigned DeclObjCIvarAbbrev = 0;
635621
unsigned DeclCXXMethodAbbrev = 0;
636-
unsigned DeclSpecializationsAbbrev = 0;
637-
unsigned DeclPartialSpecializationsAbbrev = 0;
638-
639622
unsigned DeclDependentNonTemplateCXXMethodAbbrev = 0;
640623
unsigned DeclTemplateCXXMethodAbbrev = 0;
641624
unsigned DeclMemberSpecializedCXXMethodAbbrev = 0;

0 commit comments

Comments
 (0)