[llvm-commits] [llvm-gcc-4.0] r42518 - /llvm-gcc-4.0/trunk/gcc/llvm-types.cpp

Devang Patel dpatel at apple.com
Mon Oct 1 17:41:17 PDT 2007


Author: dpatel
Date: Mon Oct  1 19:41:16 2007
New Revision: 42518

URL: http://llvm.org/viewvc/llvm-project?rev=42518&view=rev
Log:
If LLVM struct size matches GCC struct size then do not
removing trailing 'extra' padding bytes.

Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20071001/054142.html


Modified:
    llvm-gcc-4.0/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.0/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-types.cpp?rev=42518&r1=42517&r2=42518&view=diff

==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-types.cpp Mon Oct  1 19:41:16 2007
@@ -1160,7 +1160,7 @@
 
   // If this is a Packed struct and ExtraBitsAvailable is not zero then
   // remove Extra bytes if ExtraBitsAvailable > 8.
-  void RemoveExtraBytes () {
+  void RemoveExtraBytes (unsigned GCCTypeSize) {
 
     unsigned NoOfBytesToRemove = ExtraBitsAvailable/8;
     
@@ -1170,6 +1170,10 @@
     if (NoOfBytesToRemove == 0)
       return;
 
+    unsigned OriginalSize = ElementSizeInBytes.back();
+    if (OriginalSize == GCCTypeSize)
+      return;
+
     const Type *LastType = Elements.back();
     unsigned PadBytes = 0;
 
@@ -1191,7 +1195,6 @@
     Elements.pop_back();
     Elements.push_back(Pad);
 
-    unsigned OriginalSize = ElementSizeInBytes.back();
     ElementSizeInBytes.pop_back();
     ElementSizeInBytes.push_back(OriginalSize - NoOfBytesToRemove);
   }
@@ -1667,12 +1670,12 @@
   for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))
     DecodeStructFields(Field, *Info);
 
-  Info->RemoveExtraBytes();
+  uint64_t GCCTypeSize = ((uint64_t)TREE_INT_CST_LOW(TYPE_SIZE(type))+7)/8;
+  Info->RemoveExtraBytes(GCCTypeSize);
   // If the LLVM struct requires explicit tail padding to be the same size as
   // the GCC struct, insert tail padding now.  This handles, e.g., "{}" in C++.
   if (TYPE_SIZE(type) && TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST) {
     uint64_t LLVMStructSize = Info->getSizeAsLLVMStruct();
-    uint64_t GCCTypeSize = ((uint64_t)TREE_INT_CST_LOW(TYPE_SIZE(type))+7)/8;
     
     if (LLVMStructSize != GCCTypeSize) {
       assert(LLVMStructSize < GCCTypeSize &&





More information about the llvm-commits mailing list