From c7292fdabe8fb9d0f08f6e8d811f37c286c64dbb Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Mon, 2 Mar 2015 09:34:59 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230939 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DataLayout.cpp | 3 +++ test/Assembler/invalid-datalayout22.ll | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 test/Assembler/invalid-datalayout22.ll diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp index 4eb6d78d381..b6eaf6f2d99 100644 --- a/lib/IR/DataLayout.cpp +++ b/lib/IR/DataLayout.cpp @@ -312,6 +312,9 @@ void DataLayout::parseSpecifier(StringRef Desc) { "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; diff --git a/test/Assembler/invalid-datalayout22.ll b/test/Assembler/invalid-datalayout22.ll new file mode 100644 index 00000000000..14e4c2822ce --- /dev/null +++ b/test/Assembler/invalid-datalayout22.ll @@ -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 + -- 2.34.1