diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-02-16 05:41:53 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-02-16 05:41:53 +0000 |
commit | c859e73a24cc6a7be15dd219112e80241d8d818d (patch) | |
tree | 44cb8e90c0166ff11f66572f31c9be8e58c44b33 /lib/IR/DataLayout.cpp | |
parent | 6de0a12927845ca49cd5cb1da9206fe503b565ec (diff) |
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
Diffstat (limited to 'lib/IR/DataLayout.cpp')
-rw-r--r-- | lib/IR/DataLayout.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp index 0dcc8427dcd..d1506b20cff 100644 --- a/lib/IR/DataLayout.cpp +++ b/lib/IR/DataLayout.cpp @@ -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) { |