Rename MaxAlignment -> Alignment.

We can argue about a maximum alignment of a group of symbols,
but for each symbol, there is only one alignment.
So it is a bit weird that each symbol has a "maximum alignment".

llvm-svn: 263151
This commit is contained in:
Rui Ueyama
2016-03-10 18:58:53 +00:00
parent 1452f485e2
commit 17d6983a4e
3 changed files with 7 additions and 10 deletions

View File

@@ -107,8 +107,7 @@ static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) {
}
static int compareCommons(DefinedCommon *A, DefinedCommon *B) {
A->MaxAlignment = B->MaxAlignment =
std::max(A->MaxAlignment, B->MaxAlignment);
A->Alignment = B->Alignment = std::max(A->Alignment, B->Alignment);
if (A->Size < B->Size)
return -1;
return 1;
@@ -191,10 +190,8 @@ DefinedSynthetic<ELFT>::DefinedSynthetic(StringRef N, uintX_t Value,
DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment,
bool IsWeak, uint8_t Visibility)
: Defined(SymbolBody::DefinedCommonKind, N, IsWeak, Visibility,
0 /* Type */) {
MaxAlignment = Alignment;
this->Size = Size;
}
0 /* Type */),
Alignment(Alignment), Size(Size) {}
std::unique_ptr<InputFile> Lazy::getMember() {
MemoryBufferRef MBRef = File->getMember(&Sym);

View File

@@ -205,7 +205,7 @@ public:
uint64_t OffsetInBss;
// The maximum alignment we have seen for this symbol.
uint64_t MaxAlignment;
uint64_t Alignment;
uint64_t Size;
};

View File

@@ -716,13 +716,13 @@ void Writer<ELFT>::addCommonSymbols(std::vector<DefinedCommon *> &Syms) {
// Sort the common symbols by alignment as an heuristic to pack them better.
std::stable_sort(Syms.begin(), Syms.end(),
[](const DefinedCommon *A, const DefinedCommon *B) {
return A->MaxAlignment > B->MaxAlignment;
return A->Alignment > B->Alignment;
});
uintX_t Off = getBss()->getSize();
for (DefinedCommon *C : Syms) {
Off = alignTo(Off, C->MaxAlignment);
Out<ELFT>::Bss->updateAlign(C->MaxAlignment);
Off = alignTo(Off, C->Alignment);
Out<ELFT>::Bss->updateAlign(C->Alignment);
C->OffsetInBss = Off;
Off += C->Size;
}