[PATCH] D12682: [MC/ELF] Accept zero for .align directive

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 12:01:13 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL247048: [MC/ELF] Accept zero for .align directive (authored by davide).

Changed prior to commit:
  http://reviews.llvm.org/D12682?vs=34171&id=34236#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12682

Files:
  llvm/trunk/lib/MC/MCParser/AsmParser.cpp
  llvm/trunk/test/MC/ELF/align-zero.s

Index: llvm/trunk/test/MC/ELF/align-zero.s
===================================================================
--- llvm/trunk/test/MC/ELF/align-zero.s
+++ llvm/trunk/test/MC/ELF/align-zero.s
@@ -0,0 +1,4 @@
+// Test that an alignment of zero is accepted.
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o -
+
+  .align 0
Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp
@@ -2706,7 +2706,11 @@
 
     Alignment = 1ULL << Alignment;
   } else {
-    // Reject alignments that aren't a power of two, for gas compatibility.
+    // Reject alignments that aren't either a power of two or zero,
+    // for gas compatibility. Alignment of zero is silently rounded
+    // up to one.
+    if (Alignment == 0)
+      Alignment = 1;
     if (!isPowerOf2_64(Alignment))
       Error(AlignmentLoc, "alignment must be a power of 2");
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12682.34236.patch
Type: text/x-patch
Size: 999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150908/f101f894/attachment.bin>


More information about the llvm-commits mailing list