[cfe-commits] r101536 - in /cfe/trunk: lib/CodeGen/CGExprConstant.cpp test/CodeGen/decl.c
Chris Lattner
sabre at nondot.org
Fri Apr 16 14:02:32 PDT 2010
Author: lattner
Date: Fri Apr 16 16:02:32 2010
New Revision: 101536
URL: http://llvm.org/viewvc/llvm-project?rev=101536&view=rev
Log:
fix a bogus assertion exposed by a recent change: packing the
struct may cause it to shrink more than one byte. Before
my recent changes we compiled the new test into:
%0 = type { [6 x i8] }
@x = global %0 { [6 x i8] undef }, align 2 ; <%0*> [#uses=0]
which is obviously bogus. Now we compile it into:
%0 = type <{ i32, i8, i8 }>
@x = global %0 zeroinitializer, align 2 ; <%0*> [#uses=0]
Where the last byte only is tail padding.
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/test/CodeGen/decl.c
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=101536&r1=101535&r2=101536&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Apr 16 16:02:32 2010
@@ -372,7 +372,7 @@
assert(!Packed && "Size mismatch!");
ConvertStructToPacked();
- assert(NextFieldOffsetInBytes == LayoutSizeInBytes &&
+ assert(NextFieldOffsetInBytes <= LayoutSizeInBytes &&
"Converting to packed did not help!");
}
Modified: cfe/trunk/test/CodeGen/decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/decl.c?rev=101536&r1=101535&r2=101536&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/decl.c (original)
+++ cfe/trunk/test/CodeGen/decl.c Fri Apr 16 16:02:32 2010
@@ -84,3 +84,8 @@
{4},
};
+// rdar://7872531
+#pragma pack(push, 2)
+struct test8s { int f0; char f1; } test8g = {};
+
+
More information about the cfe-commits
mailing list