[llvm] r175360 - MCParser: Reject .balign with non-pow2 alignments.
Benjamin Kramer
benny.kra at googlemail.com
Sat Feb 16 07:00:16 PST 2013
Author: d0k
Date: Sat Feb 16 09:00:16 2013
New Revision: 175360
URL: http://llvm.org/viewvc/llvm-project?rev=175360&view=rev
Log:
MCParser: Reject .balign with non-pow2 alignments.
GNU as rejects them and there are configure scripts in the wild that check if
the assembler rejects ".align 3" to determine whether the alignment is in bytes
or powers of two.
Added:
llvm/trunk/test/MC/AsmParser/align_invalid.s
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=175360&r1=175359&r2=175360&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Sat Feb 16 09:00:16 2013
@@ -2456,6 +2456,10 @@ bool AsmParser::ParseDirectiveAlign(bool
}
Alignment = 1ULL << Alignment;
+ } else {
+ // Reject alignments that aren't a power of two, for gas compatibility.
+ if (!isPowerOf2_64(Alignment))
+ Error(AlignmentLoc, "alignment must be a power of 2");
}
// Diagnose non-sensical max bytes to align.
Added: llvm/trunk/test/MC/AsmParser/align_invalid.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/align_invalid.s?rev=175360&view=auto
==============================================================================
--- llvm/trunk/test/MC/AsmParser/align_invalid.s (added)
+++ llvm/trunk/test/MC/AsmParser/align_invalid.s Sat Feb 16 09:00:16 2013
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -triple i386-linux-gnu < %s 2>&1 | FileCheck %s -check-prefix=ELF
+# RUN: llvm-mc -triple i386-apple-darwin < %s 2>&1 | FileCheck %s -check-prefix=DARWIN
+
+.align 3
+# ELF: error: alignment must be a power of 2
+# DARWIN-NOT: error
+
+.align 32
+# ELF-NOT: error
+# DARWIN: error: invalid alignment value
More information about the llvm-commits
mailing list