[llvm] r230936 - Teach DataLayout that zero-byte pointer sizes don't make sense.

Owen Anderson resistor at mac.com
Sun Mar 1 22:00:03 PST 2015


Author: resistor
Date: Mon Mar  2 00:00:02 2015
New Revision: 230936

URL: http://llvm.org/viewvc/llvm-project?rev=230936&view=rev
Log:
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.

Added:
    llvm/trunk/test/Assembler/invalid-datalayout19.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=230936&r1=230935&r2=230936&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DataLayout.cpp (original)
+++ llvm/trunk/lib/IR/DataLayout.cpp Mon Mar  2 00:00:02 2015
@@ -259,6 +259,8 @@ void DataLayout::parseSpecifier(StringRe
             "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())

Added: llvm/trunk/test/Assembler/invalid-datalayout19.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-datalayout19.ll?rev=230936&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-datalayout19.ll (added)
+++ llvm/trunk/test/Assembler/invalid-datalayout19.ll Mon Mar  2 00:00:02 2015
@@ -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
+





More information about the llvm-commits mailing list