diff --git a/lld/COFF/DebugTypes.h b/lld/COFF/DebugTypes.h --- a/lld/COFF/DebugTypes.h +++ b/lld/COFF/DebugTypes.h @@ -46,6 +46,7 @@ const llvm::codeview::PrecompRecord *precomp); void loadTypeServerSource(llvm::MemoryBufferRef m); +void clearTypeServerSourceInstances(); // Temporary interface to get the dependency template const T &retrieveDependencyInfo(const TpiSource *source); diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp --- a/lld/COFF/DebugTypes.cpp +++ b/lld/COFF/DebugTypes.cpp @@ -90,6 +90,8 @@ }; } // namespace +void lld::coff::clearTypeServerSourceInstances() { TypeServerSource::instances.clear(); } + static std::vector> GC; TpiSource::TpiSource(TpiKind k, const ObjFile *f) : kind(k), file(f) { diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -84,6 +84,8 @@ ImportFile::instances.clear(); BitcodeFile::instances.clear(); memset(MergeChunk::instances, 0, sizeof(MergeChunk::instances)); + OutputSection::clearOutputSections(); + clearTypeServerSourceInstances(); return !errorCount(); } diff --git a/lld/COFF/Writer.h b/lld/COFF/Writer.h --- a/lld/COFF/Writer.h +++ b/lld/COFF/Writer.h @@ -75,6 +75,8 @@ std::vector contribSections; + static void clearOutputSections(); + private: uint32_t stringTableOff = 0; }; diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -82,6 +82,8 @@ // this can be indexed by Chunk::getOutputSection. static std::vector outputSections; +void OutputSection::clearOutputSections() { outputSections.clear(); } + OutputSection *Chunk::getOutputSection() const { return osidx == 0 ? nullptr : outputSections[osidx - 1]; }