[lld] r246869 - COFF: Use section content checksum for ICF.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 4 13:45:51 PDT 2015
Author: ruiu
Date: Fri Sep 4 15:45:50 2015
New Revision: 246869
URL: http://llvm.org/viewvc/llvm-project?rev=246869&view=rev
Log:
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.
Modified:
lld/trunk/COFF/Chunks.h
lld/trunk/COFF/ICF.cpp
lld/trunk/COFF/InputFiles.cpp
Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=246869&r1=246868&r2=246869&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Fri Sep 4 15:45:50 2015
@@ -183,6 +183,10 @@ public:
// and this chunk is considrered as dead.
SectionChunk *Ptr;
+ // The CRC of the contents as described in the COFF spec 4.5.5.
+ // Auxiliary Format 5: Section Definitions. Used for ICF.
+ uint32_t Checksum = 0;
+
private:
ArrayRef<uint8_t> getContents() const;
Modified: lld/trunk/COFF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ICF.cpp?rev=246869&r1=246868&r2=246869&view=diff
==============================================================================
--- lld/trunk/COFF/ICF.cpp (original)
+++ lld/trunk/COFF/ICF.cpp Fri Sep 4 15:45:50 2015
@@ -44,7 +44,7 @@ uint64_t SectionChunk::getHash() const {
NumRelocs,
uint32_t(Header->SizeOfRawData),
std::distance(Relocs.end(), Relocs.begin()),
- hash_combine_range(A.data(), A.data() + A.size()));
+ Checksum);
}
// Returns true if this and a given chunk are identical COMDAT sections.
@@ -58,6 +58,8 @@ bool SectionChunk::equals(const SectionC
return false;
if (NumRelocs != X->NumRelocs)
return false;
+ if (Checksum != X->Checksum)
+ return false;
// Compare data
if (getContents() != X->getContents())
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=246869&r1=246868&r2=246869&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Fri Sep 4 15:45:50 2015
@@ -225,13 +225,14 @@ Defined *ObjectFile::createDefined(COFFS
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);
More information about the llvm-commits
mailing list