[PATCH] D36060: [AsmParser][GAS-compatibility] Ignore an empty 'p2align' directive
coby via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 30 07:35:36 PDT 2017
coby created this revision.
GAS ignores the aforementioned issue
this patch aligns LLVM + throws in an appropriate warning
Repository:
rL LLVM
https://reviews.llvm.org/D36060
Files:
lib/MC/MCParser/AsmParser.cpp
test/MC/AsmParser/directive_align.s
Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -3199,7 +3199,7 @@
int64_t MaxBytesToFill = 0;
auto parseAlign = [&]() -> bool {
- if (checkForValidSection() || parseAbsoluteExpression(Alignment))
+ if (parseAbsoluteExpression(Alignment))
return true;
if (parseOptionalToken(AsmToken::Comma)) {
// The fill expression can be omitted while specifying a maximum number of
@@ -3218,6 +3218,13 @@
return parseToken(AsmToken::EndOfStatement);
};
+ if (checkForValidSection())
+ return addErrorSuffix(" in directive");
+ // GAS-Compatibility: Ignore empty '.p2align', but add a warning
+ if (IsPow2 && (ValueSize == 1) && getTok().is(AsmToken::EndOfStatement)) {
+ Warning(AlignmentLoc, "p2align directive with no operand(s) is ignored");
+ return parseToken(AsmToken::EndOfStatement);
+ }
if (parseAlign())
return addErrorSuffix(" in directive");
Index: test/MC/AsmParser/directive_align.s
===================================================================
--- test/MC/AsmParser/directive_align.s
+++ test/MC/AsmParser/directive_align.s
@@ -1,4 +1,5 @@
-# RUN: not llvm-mc -triple i386-apple-darwin9 %s | FileCheck %s
+# RUN: not llvm-mc -triple i386-apple-darwin9 %s 2> %t.err | FileCheck %s
+# RUN: FileCheck < %t.err %s --check-prefix=CHECK-WARN
# CHECK: TEST0:
# CHECK: .p2align 1
@@ -14,3 +15,7 @@
# CHECK: .balign 3, 10
TEST2:
.balign 3,10
+
+# CHECK-WARN: p2align directive with no operand(s) is ignored
+TEST3:
+ .p2align
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36060.108831.patch
Type: text/x-patch
Size: 1646 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170730/e390824d/attachment.bin>
More information about the llvm-commits
mailing list