[lld] r286553 - [lld/COFF] Don't round alignment if it's already a power-of-two.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 18:53:49 PST 2016


Author: davide
Date: Thu Nov 10 20:53:48 2016
New Revision: 286553

URL: http://llvm.org/viewvc/llvm-project?rev=286553&view=rev
Log:
[lld/COFF] Don't round alignment if it's already a power-of-two.

This matches link.exe behaviour.

Differential Revision:  https://reviews.llvm.org/D26372

Modified:
    lld/trunk/COFF/Chunks.cpp
    lld/trunk/test/COFF/common.test

Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=286553&r1=286552&r2=286553&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Thu Nov 10 20:53:48 2016
@@ -249,7 +249,7 @@ void SectionChunk::replace(SectionChunk
 CommonChunk::CommonChunk(const COFFSymbolRef S) : Sym(S) {
   // Common symbols are aligned on natural boundaries up to 32 bytes.
   // This is what MSVC link.exe does.
-  Align = std::min(uint64_t(32), NextPowerOf2(Sym.getValue()));
+  Align = std::min(uint64_t(32), PowerOf2Ceil(Sym.getValue()));
 }
 
 uint32_t CommonChunk::getPermissions() const {

Modified: lld/trunk/test/COFF/common.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/common.test?rev=286553&r1=286552&r2=286553&view=diff
==============================================================================
--- lld/trunk/test/COFF/common.test (original)
+++ lld/trunk/test/COFF/common.test Thu Nov 10 20:53:48 2016
@@ -7,7 +7,7 @@
 # CHECK: 3005: b8 04 10 00 40
 # CHECK: 300a: b8 20 10 00 40
 # CHECK: 300f: b8 60 10 00 40
-# CHECK: 3014: b8 80 10 00 40
+# CHECK: 3014: b8 70 10 00 40
 
 --- !COFF
 header:




More information about the llvm-commits mailing list