From 2b022d53a380776eaf955b55387a55aa665bfc7a Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 16 Feb 2015 05:41:55 +0000 Subject: [PATCH] DataLayout: Validate that the pref alignment is at least the ABI align git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229355 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DataLayout.cpp | 5 ++++- test/Assembler/invalid-datalayout18.ll | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/Assembler/invalid-datalayout18.ll diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp index d1506b20cff..9c1dee0cfb7 100644 --- a/lib/IR/DataLayout.cpp +++ b/lib/IR/DataLayout.cpp @@ -424,7 +424,10 @@ DataLayout::findPointerLowerBound(uint32_t AddressSpace) { void DataLayout::setPointerAlignment(uint32_t AddrSpace, unsigned ABIAlign, unsigned PrefAlign, uint32_t TypeByteWidth) { - assert(ABIAlign <= PrefAlign && "Preferred alignment worse than ABI!"); + if (PrefAlign < ABIAlign) + report_fatal_error( + "Preferred alignment cannot be less than the ABI alignment"); + PointersTy::iterator I = findPointerLowerBound(AddrSpace); if (I == Pointers.end() || I->AddressSpace != AddrSpace) { Pointers.insert(I, PointerAlignElem::get(AddrSpace, ABIAlign, PrefAlign, diff --git a/test/Assembler/invalid-datalayout18.ll b/test/Assembler/invalid-datalayout18.ll new file mode 100644 index 00000000000..b9956f98c9c --- /dev/null +++ b/test/Assembler/invalid-datalayout18.ll @@ -0,0 +1,3 @@ +; RUN: not llvm-as < %s 2>&1 | FileCheck %s +target datalayout = "p:32:32:16" +; CHECK: Preferred alignment cannot be less than the ABI alignment -- 2.34.1