[lld] r263151 - Rename MaxAlignment -> Alignment.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 10:58:54 PST 2016


Author: ruiu
Date: Thu Mar 10 12:58:53 2016
New Revision: 263151

URL: http://llvm.org/viewvc/llvm-project?rev=263151&view=rev
Log:
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".

Modified:
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/ELF/Symbols.h
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=263151&r1=263150&r2=263151&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Thu Mar 10 12:58:53 2016
@@ -107,8 +107,7 @@ static uint8_t getMinVisibility(uint8_t
 }
 
 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
 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);

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=263151&r1=263150&r2=263151&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Thu Mar 10 12:58:53 2016
@@ -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;
 };

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=263151&r1=263150&r2=263151&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Mar 10 12:58:53 2016
@@ -716,13 +716,13 @@ void Writer<ELFT>::addCommonSymbols(std:
   // 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;
   }




More information about the llvm-commits mailing list