[PATCH] D125688: [MCParser] Set default alignment value when meeting invalid align
serge via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 12:35:34 PDT 2022
serge-sans-paille updated this revision to Diff 429816.
serge-sans-paille added a comment.
Update existing test case
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125688/new/
https://reviews.llvm.org/D125688
Files:
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/MC/AsmParser/directive_align.s
Index: llvm/test/MC/AsmParser/directive_align.s
===================================================================
--- llvm/test/MC/AsmParser/directive_align.s
+++ llvm/test/MC/AsmParser/directive_align.s
@@ -12,10 +12,18 @@
.align32 3,,2
# CHECK: TEST2:
-# CHECK: .balign 3, 10
+# CHECK-WARN: error: alignment must be a power of 2
+# CHECK: .p2align 1, 0xa
TEST2:
.balign 3,10
# CHECK-WARN: p2align directive with no operand(s) is ignored
TEST3:
.p2align
+
+# CHECK: TEST4:
+# CHECK: .p2align 31, 0x90
+# CHECK-WARN: error: alignment must be smaller than 2**32
+TEST4:
+ .balign 0x100000000, 0x90
+
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3451,10 +3451,13 @@
// up to one.
if (Alignment == 0)
Alignment = 1;
- if (!isPowerOf2_64(Alignment))
+ else if (!isPowerOf2_64(Alignment)) {
ReturnVal |= Error(AlignmentLoc, "alignment must be a power of 2");
- if (!isUInt<32>(Alignment))
+ Alignment = PowerOf2Floor(Alignment);
+ } else if (!isUInt<32>(Alignment)) {
ReturnVal |= Error(AlignmentLoc, "alignment must be smaller than 2**32");
+ Alignment = 1u << 31;
+ }
}
// Diagnose non-sensical max bytes to align.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125688.429816.patch
Type: text/x-patch
Size: 1374 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220516/c8416827/attachment.bin>
More information about the llvm-commits
mailing list