summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DataLayout.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-02-16 05:41:53 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-02-16 05:41:53 +0000
commit1b9fc3a186aed6ec120688e4d957466f72db3ed5 (patch)
treed26ec6d16ac285d6a9ee1332fbfafaf39dfe669a /llvm/lib/IR/DataLayout.cpp
parent40574cc569c83faf4285c52e2279a5e26858f779 (diff)
downloadbcm5719-llvm-1b9fc3a186aed6ec120688e4d957466f72db3ed5.tar.gz
bcm5719-llvm-1b9fc3a186aed6ec120688e4d957466f72db3ed5.zip
DataLayout: Report when the datalayout type alignment/width is too large
llvm-svn: 229354
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r--llvm/lib/IR/DataLayout.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 0dcc8427dcd..d1506b20cff 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/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) {
OpenPOWER on IntegriCloud