[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 09:36:26 PDT 2022
serge-sans-paille updated this revision to Diff 429747.
serge-sans-paille added a comment.
+ 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/Assembler/invalid-module-asm.ll
Index: llvm/test/Assembler/invalid-module-asm.ll
===================================================================
--- /dev/null
+++ llvm/test/Assembler/invalid-module-asm.ll
@@ -0,0 +1,5 @@
+; RUN: not opt < %s 2>&1 | FileCheck %s
+
+; CHECK: alignment must be a power of 2
+module asm "\09.align\093"
+
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.429747.patch
Type: text/x-patch
Size: 1026 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220516/920001f8/attachment.bin>
More information about the llvm-commits
mailing list