[llvm-commits] [llvm-gcc-4.2] r46210 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
Devang Patel
dpatel at apple.com
Mon Jan 21 11:29:54 PST 2008
Author: dpatel
Date: Mon Jan 21 13:29:51 2008
New Revision: 46210
URL: http://llvm.org/viewvc/llvm-project?rev=46210&view=rev
Log:
Used packed struct for
typedef double Al1Double __attribute__((aligned(1)));
struct x { int a:23; Al1Double v; };
test case : http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080121/057396.html
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=46210&r1=46209&r2=46210&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Jan 21 13:29:51 2008
@@ -1260,6 +1260,8 @@
ExtraBitsAvailable = E;
}
+ bool isPacked() { return Packed; }
+
void markAsPacked() {
Packed = true;
}
@@ -1793,7 +1795,15 @@
// ordering. Therefore convert to a packed struct and try again.
Info.convertToPacked();
DecodeStructFields(Field, Info);
- } else
+ }
+ else if (TYPE_USER_ALIGN(TREE_TYPE(Field))
+ && DECL_ALIGN_UNIT(Field) != Info.getTypeAlignment(Ty)
+ && !Info.isPacked()) {
+ // If Field has user defined alignment and it does not match Ty alignment
+ // then convert to a packed struct and try again.
+ Info.convertToPacked();
+ DecodeStructFields(Field, Info);
+ } else
// At this point, we know that adding the element will happen at the right
// offset. Add it.
Info.addElement(Ty, StartOffsetInBytes, Info.getTypeSize(Ty));
More information about the llvm-commits
mailing list