COFF: Use section content checksum for ICF.
Previously, we calculated our own hash values for section contents.
Of coruse that's slow because we had to access all bytes in sections.
Fortunately, COFF objects usually contain hash values for COMDAT
sections. We can use that to speed up Identical COMDAT Folding.
llvm-svn: 246869
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index a8a35a5..a8537ec 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -225,13 +225,14 @@
if (!SC)
return nullptr;
- // Handle associative sections
+ // Handle section definitions
if (IsFirst && AuxP) {
auto *Aux = reinterpret_cast<const coff_aux_section_definition *>(AuxP);
if (Aux->Selection == IMAGE_COMDAT_SELECT_ASSOCIATIVE)
if (auto *ParentSC = cast_or_null<SectionChunk>(
SparseChunks[Aux->getNumber(Sym.isBigObj())]))
ParentSC->addAssociative(SC);
+ SC->Checksum = Aux->CheckSum;
}
auto *B = new (Alloc) DefinedRegular(this, Sym, SC);