[llvm-commits] [llvm-gcc-4.2] r48857 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Devang Patel
dpatel at apple.com
Wed Mar 26 18:51:14 PDT 2008
Author: dpatel
Date: Wed Mar 26 20:51:14 2008
New Revision: 48857
URL: http://llvm.org/viewvc/llvm-project?rev=48857&view=rev
Log:
Redo entire struct layout when packed field is seen as part of non-packed struct.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=48857&r1=48856&r2=48857&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Mar 26 20:51:14 2008
@@ -1759,10 +1759,18 @@
// Handle bit-fields specially.
if (isBitfield(Field)) {
- // Unnamed bitfield type does not contribute in struct alignment
- // computations. Use packed llvm structure in such cases.
- if (!DECL_NAME(Field) && !Info.isPacked())
- return false;
+ // If this field is forcing packed llvm struct then retry entire struct
+ // layout.
+ if (!Info.isPacked()) {
+ // Unnamed bitfield type does not contribute in struct alignment
+ // computations. Use packed llvm structure in such cases.
+ if (!DECL_NAME(Field))
+ return false;
+ // If this field is packed then the struct may need padding fields
+ // before this field.
+ if (DECL_PACKED(Field))
+ return false;
+ }
DecodeStructBitField(Field, Info);
return true;
}
@@ -1810,10 +1818,6 @@
StructTypeConversionInfo &Info) {
unsigned FieldSizeInBits = TREE_INT_CST_LOW(DECL_SIZE(Field));
- if (DECL_PACKED(Field))
- // Individual fields can be packed.
- Info.markAsPacked();
-
if (FieldSizeInBits == 0) // Ignore 'int:0', which just affects layout.
return;
More information about the llvm-commits
mailing list