From 5bc2bbe60191aa65faeb0a8f48e94750a826f42b Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Mon, 2 Mar 2015 06:00:02 +0000 Subject: Teach DataLayout that zero-byte pointer sizes don't make sense. Previously this would result in assertion failures or simply crashes at various points in the optimizer when trying to create types of zero bit width. llvm-svn: 230936 --- llvm/lib/IR/DataLayout.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'llvm/lib') diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp index 9c1dee0cfb7..c414e80f410 100644 --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -259,6 +259,8 @@ void DataLayout::parseSpecifier(StringRef Desc) { "Missing size specification for pointer in datalayout string"); Split = split(Rest, ':'); unsigned PointerMemSize = inBytes(getInt(Tok)); + if (!PointerMemSize) + report_fatal_error("Invalid pointer size of 0 bytes"); // ABI alignment. if (Rest.empty()) -- cgit v1.2.3