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)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228819 91177308-0d34-0410-b5e6-96231b3b80d8

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

index cde393777a649c93f484b5d0307a3169fef64b02..0dcc8427dcd6fa7ff3570336e4444a4d2b73b8e5 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/test/Assembler/invalid-datalayout14.ll b/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