[llvm-branch-commits] [llvm] 01d1de8 - [MC] Reject byte alignment if larger than or equal to 2**32
Fangrui Song via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Dec 20 14:21:55 PST 2020
Author: Fangrui Song
Date: 2020-12-20T14:17:00-08:00
New Revision: 01d1de81963d91773c92b29e2d08605293c59750
URL: https://github.com/llvm/llvm-project/commit/01d1de81963d91773c92b29e2d08605293c59750
DIFF: https://github.com/llvm/llvm-project/commit/01d1de81963d91773c92b29e2d08605293c59750.diff
LOG: [MC] Reject byte alignment if larger than or equal to 2**32
This is consistent with the resolution to power-of-2 alignments.
Otherwise, emitCodeAlignment and emitValueToAlignment cannot handle alignments
larger than 2**32 and will trigger assertion failure (PR35218).
Note: GNU as as of 2.35 will use 1 for such a large byte `.align`
Added:
Modified:
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/test/MC/AsmParser/align_invalid.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index bf50a95bc70c..55b0003e9909 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3342,6 +3342,8 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
Alignment = 1;
if (!isPowerOf2_64(Alignment))
ReturnVal |= Error(AlignmentLoc, "alignment must be a power of 2");
+ if (!isUInt<32>(Alignment))
+ ReturnVal |= Error(AlignmentLoc, "alignment must be smaller than 2**32");
}
// Diagnose non-sensical max bytes to align.
diff --git a/llvm/test/MC/AsmParser/align_invalid.s b/llvm/test/MC/AsmParser/align_invalid.s
index 7ffbed42635a..fc9d3207ddab 100644
--- a/llvm/test/MC/AsmParser/align_invalid.s
+++ b/llvm/test/MC/AsmParser/align_invalid.s
@@ -8,3 +8,7 @@
.align 32
# ELF-NOT: error
# DARWIN: error: invalid alignment value
+
+.align 0x100000000
+# ELF: error: alignment must be smaller than 2**32
+# DARWIN: error: invalid alignment value
More information about the llvm-branch-commits
mailing list