diff options
| author | Rui Ueyama <ruiu@google.com> | 2017-05-05 23:52:24 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2017-05-05 23:52:24 +0000 |
| commit | 88172fb6039123304e817b81f65b95897fbee337 (patch) | |
| tree | 4612419a16e34c07b36fb0a80feb667152d71d53 | |
| parent | e803cc52bd035b322c2907e2dc2ddb2b49eea163 (diff) | |
| download | bcm5719-llvm-88172fb6039123304e817b81f65b95897fbee337.tar.gz bcm5719-llvm-88172fb6039123304e817b81f65b95897fbee337.zip | |
Use the same terminology as ELF.
This patch do s/color/class/g.
llvm-svn: 302326
| -rw-r--r-- | lld/COFF/Chunks.h | 2 | ||||
| -rw-r--r-- | lld/COFF/ICF.cpp | 42 |
2 files changed, 22 insertions, 22 deletions
diff --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h index 44d7f31afc6..f7412517765 100644 --- a/lld/COFF/Chunks.h +++ b/lld/COFF/Chunks.h @@ -201,7 +201,7 @@ private: // Used for ICF (Identical COMDAT Folding) void replace(SectionChunk *Other); - uint32_t Color[2] = {0, 0}; + uint32_t Class[2] = {0, 0}; // Sym points to a section symbol if this is a COMDAT chunk. DefinedRegular *Sym = nullptr; diff --git a/lld/COFF/ICF.cpp b/lld/COFF/ICF.cpp index fe59de6efa5..9a43f2bd43f 100644 --- a/lld/COFF/ICF.cpp +++ b/lld/COFF/ICF.cpp @@ -49,10 +49,10 @@ private: size_t findBoundary(size_t Begin, size_t End); - void forEachColorRange(size_t Begin, size_t End, + void forEachClassRange(size_t Begin, size_t End, std::function<void(size_t, size_t)> Fn); - void forEachColor(std::function<void(size_t, size_t)> Fn); + void forEachClass(std::function<void(size_t, size_t)> Fn); std::vector<SectionChunk *> Chunks; int Cnt = 0; @@ -85,7 +85,7 @@ bool ICF::isEligible(SectionChunk *C) { return C->isCOMDAT() && C->isLive() && Global && Executable && !Writable; } -// Split a range into smaller ranges by recoloring sections +// Split an equivalence class into smaller classes. void ICF::segregate(size_t Begin, size_t End, bool Constant) { while (Begin < End) { // Divide [Begin, End) into two. Let Mid be the start index of the @@ -101,7 +101,7 @@ void ICF::segregate(size_t Begin, size_t End, bool Constant) { // Split [Begin, End) into [Begin, Mid) and [Mid, End). uint32_t Id = NextId++; for (size_t I = Begin; I < Mid; ++I) - Chunks[I]->Color[(Cnt + 1) % 2] = Id; + Chunks[I]->Class[(Cnt + 1) % 2] = Id; // If we created a group, we need to iterate the main loop again. if (Mid != End) @@ -130,7 +130,7 @@ bool ICF::equalsConstant(const SectionChunk *A, const SectionChunk *B) { if (auto *D1 = dyn_cast<DefinedRegular>(B1)) if (auto *D2 = dyn_cast<DefinedRegular>(B2)) return D1->getValue() == D2->getValue() && - D1->getChunk()->Color[Cnt % 2] == D2->getChunk()->Color[Cnt % 2]; + D1->getChunk()->Class[Cnt % 2] == D2->getChunk()->Class[Cnt % 2]; return false; }; if (!std::equal(A->Relocs.begin(), A->Relocs.end(), B->Relocs.begin(), Eq)) @@ -155,7 +155,7 @@ bool ICF::equalsVariable(const SectionChunk *A, const SectionChunk *B) { return true; if (auto *D1 = dyn_cast<DefinedRegular>(B1)) if (auto *D2 = dyn_cast<DefinedRegular>(B2)) - return D1->getChunk()->Color[Cnt % 2] == D2->getChunk()->Color[Cnt % 2]; + return D1->getChunk()->Class[Cnt % 2] == D2->getChunk()->Class[Cnt % 2]; return false; }; return std::equal(A->Relocs.begin(), A->Relocs.end(), B->Relocs.begin(), Eq); @@ -163,12 +163,12 @@ bool ICF::equalsVariable(const SectionChunk *A, const SectionChunk *B) { size_t ICF::findBoundary(size_t Begin, size_t End) { for (size_t I = Begin + 1; I < End; ++I) - if (Chunks[Begin]->Color[Cnt % 2] != Chunks[I]->Color[Cnt % 2]) + if (Chunks[Begin]->Class[Cnt % 2] != Chunks[I]->Class[Cnt % 2]) return I; return End; } -void ICF::forEachColorRange(size_t Begin, size_t End, +void ICF::forEachClassRange(size_t Begin, size_t End, std::function<void(size_t, size_t)> Fn) { if (Begin > 0) Begin = findBoundary(Begin - 1, End); @@ -180,12 +180,12 @@ void ICF::forEachColorRange(size_t Begin, size_t End, } } -// Call Fn on each color group. -void ICF::forEachColor(std::function<void(size_t, size_t)> Fn) { +// Call Fn on each class group. +void ICF::forEachClass(std::function<void(size_t, size_t)> Fn) { // If the number of sections are too small to use threading, // call Fn sequentially. if (Chunks.size() < 1024) { - forEachColorRange(0, Chunks.size(), Fn); + forEachClassRange(0, Chunks.size(), Fn); return; } @@ -193,9 +193,9 @@ void ICF::forEachColor(std::function<void(size_t, size_t)> Fn) { size_t NumShards = 256; size_t Step = Chunks.size() / NumShards; parallel_for(size_t(0), NumShards, [&](size_t I) { - forEachColorRange(I * Step, (I + 1) * Step, Fn); + forEachClassRange(I * Step, (I + 1) * Step, Fn); }); - forEachColorRange(Step * NumShards, Chunks.size(), Fn); + forEachClassRange(Step * NumShards, Chunks.size(), Fn); } // Merge identical COMDAT sections. @@ -209,11 +209,11 @@ void ICF::run(const std::vector<Chunk *> &Vec) { continue; if (isEligible(SC)) { - // Set MSB to 1 to avoid collisions with non-hash colors. - SC->Color[0] = getHash(SC) | (1 << 31); + // Set MSB to 1 to avoid collisions with non-hash classs. + SC->Class[0] = getHash(SC) | (1 << 31); Chunks.push_back(SC); } else { - SC->Color[0] = NextId++; + SC->Class[0] = NextId++; } } @@ -224,25 +224,25 @@ void ICF::run(const std::vector<Chunk *> &Vec) { // the same group are consecutive in the vector. std::stable_sort(Chunks.begin(), Chunks.end(), [](SectionChunk *A, SectionChunk *B) { - return A->Color[0] < B->Color[0]; + return A->Class[0] < B->Class[0]; }); // Compare static contents and assign unique IDs for each static content. - forEachColor([&](size_t Begin, size_t End) { segregate(Begin, End, true); }); + forEachClass([&](size_t Begin, size_t End) { segregate(Begin, End, true); }); ++Cnt; // Split groups by comparing relocations until convergence is obtained. do { Repeat = false; - forEachColor( + forEachClass( [&](size_t Begin, size_t End) { segregate(Begin, End, false); }); ++Cnt; } while (Repeat); log("ICF needed " + Twine(Cnt) + " iterations"); - // Merge sections in the same colors. - forEachColor([&](size_t Begin, size_t End) { + // Merge sections in the same classs. + forEachClass([&](size_t Begin, size_t End) { if (End - Begin == 1) return; |

