[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 07:07:49 PDT 2022
serge-sans-paille created this revision.
serge-sans-paille added reviewers: aaron.ballman, nicolas17.
Herald added a subscriber: hiraditya.
Herald added a project: All.
serge-sans-paille requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Upon invalid alignment value, still set a default valid alignment value to avoid
hitting later asserts.
Fix #55273
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125688
Files:
llvm/lib/MC/MCParser/AsmParser.cpp
Index: llvm/lib/MC/MCParser/AsmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/AsmParser.cpp
+++ llvm/lib/MC/MCParser/AsmParser.cpp
@@ -3451,10 +3451,14 @@
// up to one.
if (Alignment == 0)
Alignment = 1;
- if (!isPowerOf2_64(Alignment))
+ 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125688.429706.patch
Type: text/x-patch
Size: 719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220516/26d3089f/attachment.bin>
More information about the llvm-commits
mailing list