forked from OSchip/llvm-project
[MCParser] Set default alignment value when meeting invalid align
Upon invalid alignment value, still set a default valid alignment value to avoid hitting later asserts. Fix #55273 Differential Revision: https://reviews.llvm.org/D125688
This commit is contained in:
parent
48ea26a387
commit
4d73c46ccf
|
@ -3451,10 +3451,14 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, unsigned ValueSize) {
|
|||
// 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);
|
||||
}
|
||||
if (!isUInt<32>(Alignment)) {
|
||||
ReturnVal |= Error(AlignmentLoc, "alignment must be smaller than 2**32");
|
||||
Alignment = 1u << 31;
|
||||
}
|
||||
}
|
||||
|
||||
// Diagnose non-sensical max bytes to align.
|
||||
|
|
|
@ -12,10 +12,25 @@ TEST1:
|
|||
.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
|
||||
|
||||
# CHECK: TEST5:
|
||||
# CHECK: .p2align 31, 0x90
|
||||
# CHECK-WARN: error: alignment must be a power of 2
|
||||
# CHECK-WARN: error: alignment must be smaller than 2**32
|
||||
TEST5:
|
||||
.balign 0x100000001, 0x90
|
||||
|
||||
|
|
Loading…
Reference in New Issue