From 70fe9c634663927021a461819585b5f131162726 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 11 Feb 2015 09:13:09 +0000 Subject: [PATCH] DataLayout: Report when the preferred alignment is less than the ABI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228819 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DataLayout.cpp | 3 +++ test/Assembler/invalid-datalayout14.ll | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 test/Assembler/invalid-datalayout14.ll diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp index cde393777a6..0dcc8427dcd 100644 --- a/lib/IR/DataLayout.cpp +++ b/lib/IR/DataLayout.cpp @@ -312,6 +312,9 @@ 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; diff --git a/test/Assembler/invalid-datalayout14.ll b/test/Assembler/invalid-datalayout14.ll new file mode 100644 index 00000000000..84634b52a14 --- /dev/null +++ b/test/Assembler/invalid-datalayout14.ll @@ -0,0 +1,3 @@ +; RUN: not llvm-as < %s 2>&1 | FileCheck %s +target datalayout = "i64:64:16" +; CHECK: Preferred alignment cannot be less than the ABI alignment -- 2.34.1