DataLayout: Report when the preferred alignment is less than the ABI
authorDavid Majnemer <david.majnemer@gmail.com>
Wed, 11 Feb 2015 09:13:09 +0000 (09:13 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Wed, 11 Feb 2015 09:13:09 +0000 (09:13 +0000)
llvm-svn: 228819

llvm/lib/IR/DataLayout.cpp
llvm/test/Assembler/invalid-datalayout14.ll [new file with mode: 0644]

index cde3937..0dcc842 100644 (file)
@@ -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/llvm/test/Assembler/invalid-datalayout14.ll b/llvm/test/Assembler/invalid-datalayout14.ll
new file mode 100644 (file)
index 0000000..84634b5
--- /dev/null
@@ -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