[llvm] r230939 - Teach DataLayout that ABI alignments for non-aggregate types must be non-zero.

Owen Anderson resistor at mac.com
Mon Mar 2 01:35:00 PST 2015


Author: resistor
Date: Mon Mar  2 03:34:59 2015
New Revision: 230939

URL: http://llvm.org/viewvc/llvm-project?rev=230939&view=rev
Log:
Teach DataLayout that ABI alignments for non-aggregate types must be non-zero.

This manifested as assertions and/or crashes in later phases of optimization,
depending on the build configuration.

Added:
    llvm/trunk/test/Assembler/invalid-datalayout22.ll
Modified:
    llvm/trunk/lib/IR/DataLayout.cpp

Modified: llvm/trunk/lib/IR/DataLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DataLayout.cpp?rev=230939&r1=230938&r2=230939&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DataLayout.cpp (original)
+++ llvm/trunk/lib/IR/DataLayout.cpp Mon Mar  2 03:34:59 2015
@@ -312,6 +312,9 @@ void DataLayout::parseSpecifier(StringRe
             "Missing alignment specification in datalayout string");
       Split = split(Rest, ':');
       unsigned ABIAlign = inBytes(getInt(Tok));
+      if (AlignType != AGGREGATE_ALIGN && !ABIAlign)
+        report_fatal_error(
+            "ABI alignment specification must be >0 for non-aggregate types");
 
       // Preferred alignment.
       unsigned PrefAlign = ABIAlign;

Added: llvm/trunk/test/Assembler/invalid-datalayout22.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-datalayout22.ll?rev=230939&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-datalayout22.ll (added)
+++ llvm/trunk/test/Assembler/invalid-datalayout22.ll Mon Mar  2 03:34:59 2015
@@ -0,0 +1,6 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+target datalayout = "v128:0:128"
+
+; CHECK: ABI alignment specification must be >0 for non-aggregate types
+





More information about the llvm-commits mailing list