diff options
author | Anders Carlsson <andersca@mac.com> | 2009-07-23 03:17:50 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-07-23 03:17:50 +0000 |
commit | 45372a6fdcd2b0840704569478db456822e02bae (patch) | |
tree | 9b19eda1cf1e031252487ae8a8033dae6ea97106 /lib/CodeGen/CodeGenTypes.cpp | |
parent | f1c8380d26cc392ad8f26e788af176a6e0bf8fd1 (diff) |
Check in CGRecordLayoutBuilder which is a reimplementation of the record layout code. (Yay, no more packed structs unless absolutely necessary). We currently don't use the layouts being built but that will change when the new code is mature enough :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenTypes.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 41d2ba24fe..59463fa24f 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -21,6 +21,7 @@ #include "llvm/Target/TargetData.h" #include "CGCall.h" +#include "CGRecordLayoutBuilder.h" using namespace clang; using namespace CodeGen; @@ -456,21 +457,30 @@ const llvm::Type *CodeGenTypes::ConvertTagDeclType(const TagDecl *TD) { ResultType = llvm::StructType::get(std::vector<const llvm::Type*>()); } else { // Layout fields. - RecordOrganizer RO(*this, *RD); + CGRecordLayout *Layout = + CGRecordLayoutBuilder::ComputeLayout(*this, RD); - if (TD->isStruct() || TD->isClass()) - RO.layoutStructFields(Context.getASTRecordLayout(RD)); - else { - assert(TD->isUnion() && "unknown tag decl kind!"); - RO.layoutUnionFields(Context.getASTRecordLayout(RD)); + if (!Layout) { + // Layout fields. + RecordOrganizer RO(*this, *RD); + + if (TD->isStruct() || TD->isClass()) + RO.layoutStructFields(Context.getASTRecordLayout(RD)); + else { + assert(TD->isUnion() && "unknown tag decl kind!"); + RO.layoutUnionFields(Context.getASTRecordLayout(RD)); + } + + Layout = new CGRecordLayout(RO.getLLVMType(), + RO.getPaddingFields()); } // Get llvm::StructType. const Type *Key = Context.getTagDeclType(const_cast<TagDecl*>(TD)).getTypePtr(); - CGRecordLayouts[Key] = new CGRecordLayout(RO.getLLVMType(), - RO.getPaddingFields()); - ResultType = RO.getLLVMType(); + + CGRecordLayouts[Key] = Layout; + ResultType = Layout->getLLVMType(); } // Refine our Opaque type to ResultType. This can invalidate ResultType, so |