diff options
author | Anders Carlsson <andersca@mac.com> | 2009-09-03 22:56:02 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-09-03 22:56:02 +0000 |
commit | 366200045fc30290795e037ab2cb417ddd3c9933 (patch) | |
tree | 94ff611a9231fa414874d2413768bedf5fac0779 /lib/CodeGen/CGRecordLayoutBuilder.cpp | |
parent | 81499bbeb2bd157a77b60364676ac434aca7a4df (diff) |
If the alignment of the chosen field in a union is greater than the alignment of the union, we need to use a packed LLVM struct. Fixes <rdar://problem/7184250>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80964 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGRecordLayoutBuilder.cpp')
-rw-r--r-- | lib/CodeGen/CGRecordLayoutBuilder.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/CodeGen/CGRecordLayoutBuilder.cpp b/lib/CodeGen/CGRecordLayoutBuilder.cpp index 74ef2eacc9..f2fd885ee4 100644 --- a/lib/CodeGen/CGRecordLayoutBuilder.cpp +++ b/lib/CodeGen/CGRecordLayoutBuilder.cpp @@ -199,8 +199,15 @@ void CGRecordLayoutBuilder::LayoutUnion(const RecordDecl *D) { } // Now add our field. - if (Ty) + if (Ty) { AppendField(0, Ty); + + if (getTypeAlignment(Ty) > Layout.getAlignment() / 8) { + // We need a packed struct. + Packed = true; + Align = 1; + } + } // Append tail padding. if (Layout.getSize() / 8 > Size) |