mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-23 11:49:50 +00:00
DataLayout: Report when the datalayout type alignment/width is too large
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6de0a12927
commit
c859e73a24
@ -312,9 +312,6 @@ void DataLayout::parseSpecifier(StringRef Desc) {
|
||||
PrefAlign = inBytes(getInt(Tok));
|
||||
}
|
||||
|
||||
if (ABIAlign > PrefAlign)
|
||||
report_fatal_error(
|
||||
"Preferred alignment cannot be less than the ABI alignment");
|
||||
setAlignment(AlignType, ABIAlign, PrefAlign, Size);
|
||||
|
||||
break;
|
||||
@ -391,9 +388,17 @@ bool DataLayout::operator==(const DataLayout &Other) const {
|
||||
void
|
||||
DataLayout::setAlignment(AlignTypeEnum align_type, unsigned abi_align,
|
||||
unsigned pref_align, uint32_t bit_width) {
|
||||
assert(abi_align <= pref_align && "Preferred alignment worse than ABI!");
|
||||
assert(pref_align < (1 << 16) && "Alignment doesn't fit in bitfield");
|
||||
assert(bit_width < (1 << 24) && "Bit width doesn't fit in bitfield");
|
||||
if (!isUInt<24>(bit_width))
|
||||
report_fatal_error("Invalid bit width, must be a 24bit integer");
|
||||
if (!isUInt<16>(abi_align))
|
||||
report_fatal_error("Invalid ABI alignment, must be a 16bit integer");
|
||||
if (!isUInt<16>(pref_align))
|
||||
report_fatal_error("Invalid preferred alignment, must be a 16bit integer");
|
||||
|
||||
if (pref_align < abi_align)
|
||||
report_fatal_error(
|
||||
"Preferred alignment cannot be less than the ABI alignment");
|
||||
|
||||
for (LayoutAlignElem &Elem : Alignments) {
|
||||
if (Elem.AlignType == (unsigned)align_type &&
|
||||
Elem.TypeBitWidth == bit_width) {
|
||||
|
3
test/Assembler/invalid-datalayout15.ll
Normal file
3
test/Assembler/invalid-datalayout15.ll
Normal file
@ -0,0 +1,3 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
target datalayout = "i64:16:16777216"
|
||||
; CHECK: Invalid preferred alignment, must be a 16bit integer
|
3
test/Assembler/invalid-datalayout16.ll
Normal file
3
test/Assembler/invalid-datalayout16.ll
Normal file
@ -0,0 +1,3 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
target datalayout = "i64:16777216:16777216"
|
||||
; CHECK: Invalid ABI alignment, must be a 16bit integer
|
3
test/Assembler/invalid-datalayout17.ll
Normal file
3
test/Assembler/invalid-datalayout17.ll
Normal file
@ -0,0 +1,3 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
target datalayout = "i16777216:16:16"
|
||||
; CHECK: Invalid bit width, must be a 24bit integer
|
Loading…
Reference in New Issue
Block a user