[cfe-commits] r131103 - in /cfe/trunk: lib/AST/RecordLayoutBuilder.cpp test/CodeGen/ms_struct-bitfield-3.c
Fariborz Jahanian
fjahanian at apple.com
Mon May 9 15:03:17 PDT 2011
Author: fjahanian
Date: Mon May 9 17:03:17 2011
New Revision: 131103
URL: http://llvm.org/viewvc/llvm-project?rev=131103&view=rev
Log:
'long long' requires special treatment in ms_struct
structs (impacts 32-bit only though).
Modified:
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=131103&r1=131102&r2=131103&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Mon May 9 17:03:17 2011
@@ -1286,9 +1286,15 @@
Context.getTypeInfo(FD->getType());
uint64_t TypeSize = FieldInfo.first;
unsigned FieldAlign = FieldInfo.second;
+ // This check is needed for 'long long' in -m32 mode.
+ if (TypeSize > FieldAlign)
+ FieldAlign = TypeSize;
FieldInfo = Context.getTypeInfo(LastFD->getType());
uint64_t TypeSizeLastFD = FieldInfo.first;
unsigned FieldAlignLastFD = FieldInfo.second;
+ // This check is needed for 'long long' in -m32 mode.
+ if (TypeSizeLastFD > FieldAlignLastFD)
+ FieldAlignLastFD = TypeSizeLastFD;
if (TypeSizeLastFD != TypeSize) {
uint64_t UnpaddedFieldOffset =
getDataSizeInBits() - UnfilledBitsInLastByte;
@@ -1382,6 +1388,10 @@
uint64_t TypeSize = FieldInfo.first;
unsigned FieldAlign = FieldInfo.second;
+ // This check is needed for 'long long' in -m32 mode.
+ if (IsMsStruct && (TypeSize > FieldAlign))
+ FieldAlign = TypeSize;
+
if (ZeroLengthBitfield) {
// If a zero-length bitfield is inserted after a bitfield,
// and the alignment of the zero-length bitfield is
Modified: cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c?rev=131103&r1=131102&r2=131103&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c (original)
+++ cfe/trunk/test/CodeGen/ms_struct-bitfield-3.c Mon May 9 17:03:17 2011
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-darwin9 %s
+// RUN: %clang_cc1 -emit-llvm-only -triple i386-apple-darwin9 %s
// rdar://8823265
#define ATTR __attribute__((__ms_struct__))
@@ -37,3 +37,13 @@
struct_1 test_struct_1 = { 18557917, 'a', 3, 'b' };
static int a1[(size_struct_1 == sizeof (struct_1)) -1];
+
+struct ten {
+ long long a:3;
+ long long b:3;
+ char c;
+} __attribute__ ((ms_struct));
+
+#define size_struct_2 16
+
+static int a2[(size_struct_2 == sizeof (struct ten)) -1];
More information about the cfe-commits
mailing list