[llvm-commits] [PATCH] some cleanup in DataLayout

Patrik Hägglund H patrik.h.hagglund at ericsson.com
Thu Nov 15 06:03:04 PST 2012


Second attempt for patch 2:

Subject: [PATCH] Do not handle void types in DataLayout.

If actually used, an assert seems to fail from r2483 (10 years ago)
and onwards.
---
 include/llvm/DataLayout.h | 1 +
 lib/VMCore/DataLayout.cpp | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/llvm/DataLayout.h b/include/llvm/DataLayout.h
index 7d8eace..e10f9c7 100644
--- a/include/llvm/DataLayout.h
+++ b/include/llvm/DataLayout.h
@@ -281,6 +281,7 @@ public:

   /// getTypeSizeInBits - Return the number of bits necessary to hold the
   /// specified type.  For example, returns 36 for i36 and 80 for x86_fp80.
+  /// The type passed must have a size (Type::isSized() must return true).
   uint64_t getTypeSizeInBits(Type* Ty) const;

   /// getTypeStoreSize - Return the maximum number of bytes that may be
diff --git a/lib/VMCore/DataLayout.cpp b/lib/VMCore/DataLayout.cpp
index 72dcb99..24111be 100644
--- a/lib/VMCore/DataLayout.cpp
+++ b/lib/VMCore/DataLayout.cpp
@@ -537,8 +537,6 @@ uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const {
     return getStructLayout(cast<StructType>(Ty))->getSizeInBits();
   case Type::IntegerTyID:
     return cast<IntegerType>(Ty)->getBitWidth();
-  case Type::VoidTyID:
-    return 8;
   case Type::HalfTyID:
     return 16;
   case Type::FloatTyID:
@@ -600,7 +598,6 @@ unsigned DataLayout::getAlignment(Type *Ty, bool abi_or_pref) const {
     return std::max(Align, Layout->getAlignment());
   }
   case Type::IntegerTyID:
-  case Type::VoidTyID:
     AlignType = INTEGER_ALIGN;
     break;
   case Type::HalfTyID:
--
1.8.0

/Patrik Hägglund

-----Original Message-----
From: Chris Lattner [mailto:clattner at apple.com] 
Sent: den 14 november 2012 08:02
To: Patrik Hägglund H
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] [PATCH] some cleanup in DataLayout


On Nov 13, 2012, at 5:00 AM, Patrik Hägglund H <patrik.h.hagglund at ericsson.com> wrote:

> Here are two minor cleanup patches for DataLayout. (Found during preparing a series of patches for non-8-bit bytes.)
> 
> Subject: [PATCH 1/2] Revert some redundant parts of r142605.
> 
> This seems like redundant leftovers from r142288 - exposing
> TargetData::parseSpecifier to LLParser - which got reverted. Removes
> redunant td != NULL checks in parseSpecifier, and simplifies the
> interface to parseSpecifier and init.

Looks great to me,

> Subject: [PATCH 2/2] Change size of VoidTyID from 8 to 0 bits.
> 
> According to Type.h, VoidTyID is a "type with no size".

 This makes less sense.  Asking for the size of void is nonsensical, and void can only be the result of a function.  I'd rather that this function abort when asked for the size of void, but we'd obviously need to update the docs for the API and make sure no tests fail due to that.

-Chris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Do-not-handle-void-types-in-DataLayout.patch
Type: application/octet-stream
Size: 1751 bytes
Desc: 0001-Do-not-handle-void-types-in-DataLayout.patch
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121115/402da43d/attachment.obj>


More information about the llvm-commits mailing list