diff options
| author | Rui Ueyama <ruiu@google.com> | 2017-10-02 01:21:07 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2017-10-02 01:21:07 +0000 |
| commit | 274aa2fb88f95f55bb4f4e349391ad8e9aa7674b (patch) | |
| tree | e3167c2a58dafb7c8ab68c741679f7a375ca7f8e | |
| parent | c05c390a7cf89e7cf3a06586a44a39b88369fa12 (diff) | |
| download | bcm5719-llvm-274aa2fb88f95f55bb4f4e349391ad8e9aa7674b.tar.gz bcm5719-llvm-274aa2fb88f95f55bb4f4e349391ad8e9aa7674b.zip | |
[ICF] Include section contents in section hash values.
Computing section content hashes early seems like a win in terms of
performance. It increases a chance that two different sections will get
different class IDs from the beginning.
Without threads, this patch improves Chromium link time by about 0.3
seconds. With threads, by 0.1 seconds. That's less than 1% time saving
but not bad for a small patch.
llvm-svn: 314644
| -rw-r--r-- | lld/COFF/ICF.cpp | 9 | ||||
| -rw-r--r-- | lld/ELF/ICF.cpp | 5 |
2 files changed, 8 insertions, 6 deletions
diff --git a/lld/COFF/ICF.cpp b/lld/COFF/ICF.cpp index e50b951c34d..1032fb0ec7a 100644 --- a/lld/COFF/ICF.cpp +++ b/lld/COFF/ICF.cpp @@ -61,9 +61,9 @@ private: // Returns a hash value for S. uint32_t ICF::getHash(SectionChunk *C) { - return hash_combine(C->getPermissions(), hash_value(C->SectionName), - C->NumRelocs, C->Alignment, - uint32_t(C->Header->SizeOfRawData), C->Checksum); + return hash_combine(C->getPermissions(), C->SectionName, C->NumRelocs, + C->Alignment, uint32_t(C->Header->SizeOfRawData), + C->Checksum, C->getContents()); } // Returns true if section S is subject of ICF. @@ -210,9 +210,10 @@ void ICF::run(const std::vector<Chunk *> &Vec) { } // Initially, we use hash values to partition sections. - for (SectionChunk *SC : Chunks) + for_each(parallel::par, Chunks.begin(), Chunks.end(), [&](SectionChunk *SC) { // Set MSB to 1 to avoid collisions with non-hash classs. SC->Class[0] = getHash(SC) | (1 << 31); + }); // From now on, sections in Chunks are ordered so that sections in // the same group are consecutive in the vector. diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index 6d70e9bcab3..30b9be91bd3 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -155,7 +155,7 @@ private: // Returns a hash value for S. Note that the information about // relocation targets is not included in the hash value. template <class ELFT> static uint32_t getHash(InputSection *S) { - return hash_combine(S->Flags, S->getSize(), S->NumRelocations); + return hash_combine(S->Flags, S->getSize(), S->NumRelocations, S->Data); } // Returns true if section S is subject of ICF. @@ -394,9 +394,10 @@ template <class ELFT> void ICF<ELFT>::run() { Sections.push_back(S); // Initially, we use hash values to partition sections. - for (InputSection *S : Sections) + parallelForEach(Sections, [&](InputSection *S) { // Set MSB to 1 to avoid collisions with non-hash IDs. S->Class[0] = getHash<ELFT>(S) | (1 << 31); + }); // From now on, sections in Sections vector are ordered so that sections // in the same equivalence class are consecutive in the vector. |

