Skip to content

Commit

Permalink
Teach DataLayout that zero-byte pointer sizes don't make sense.
Browse files Browse the repository at this point in the history
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230936 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
resistor committed Mar 2, 2015
1 parent 0923ca2 commit f212856
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/IR/DataLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 6 additions & 0 deletions test/Assembler/invalid-datalayout19.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; RUN: not llvm-as < %s 2>&1 | FileCheck %s

target datalayout = "p:0:32:32"

; CHECK: Invalid pointer size of 0 bytes

0 comments on commit f212856

Please sign in to comment.