[lld] r302326 - Use the same terminology as ELF.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri May 5 16:52:24 PDT 2017
Author: ruiu
Date: Fri May 5 18:52:24 2017
New Revision: 302326
URL: http://llvm.org/viewvc/llvm-project?rev=302326&view=rev
Log:
Use the same terminology as ELF.
This patch do s/color/class/g.
Modified:
lld/trunk/COFF/Chunks.h
lld/trunk/COFF/ICF.cpp
Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=302326&r1=302325&r2=302326&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Fri May 5 18:52:24 2017
@@ -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;
Modified: lld/trunk/COFF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ICF.cpp?rev=302326&r1=302325&r2=302326&view=diff
==============================================================================
--- lld/trunk/COFF/ICF.cpp (original)
+++ lld/trunk/COFF/ICF.cpp Fri May 5 18:52:24 2017
@@ -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
// 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 SectionCh
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 SectionCh
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 SectionCh
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
}
}
-// 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<voi
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 *>
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 *>
// 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;
More information about the llvm-commits
mailing list