diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 6f91a644997a..a951bebe96bd 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -425,7 +425,7 @@ bool EhFrameSection::isFdeLive(EhSectionPiece &Fde, ArrayRef Rels) { // one and associates FDEs to the CIE. template void EhFrameSection::addSectionAux(EhInputSection *Sec, ArrayRef Rels) { - DenseMap OffsetToCie; + OffsetToCie.clear(); for (EhSectionPiece &Piece : Sec->Pieces) { // The empty record is the end marker. if (Piece.Size == 4) diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index f27b91b4d6bc..fc5ffa3f2747 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -86,6 +86,10 @@ public: ArrayRef getCieRecords() const { return CieRecords; } private: + // This is used only when parsing EhInputSection. We keep it here to avoid + // allocating one for each EhInputSection. + llvm::DenseMap OffsetToCie; + uint64_t Size = 0; template