diff options
author | Chris Lattner <sabre@nondot.org> | 2008-02-06 05:12:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-02-06 05:12:09 +0000 |
commit | 6ef58e36bbbfa232fe8b50309361e841985abfc6 (patch) | |
tree | 065a59e33747713a8ac74dc2474bd3691ffb3e4f /CodeGen/CodeGenTypes.cpp | |
parent | c5b8806cda286cf41866176ef98011fdaa68da01 (diff) |
only update the llvm type for a struct when we used the struct
previously in an opaque context. If we didn't do this,
computing its layout could be wasted: just be lazy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CodeGenTypes.cpp')
-rw-r--r-- | CodeGen/CodeGenTypes.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/CodeGen/CodeGenTypes.cpp b/CodeGen/CodeGenTypes.cpp index 6ef11dba04..f81df0d0f6 100644 --- a/CodeGen/CodeGenTypes.cpp +++ b/CodeGen/CodeGenTypes.cpp @@ -128,23 +128,19 @@ const llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T) { /// UpdateCompletedType - When we find the full definition for a TagDecl, /// replace the 'opaque' type we previously made for it if applicable. void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) { - // Get the LLVM type for this TagDecl. If it is non-opaque or if this decl - // is still a forward declaration, just return. - QualType NewTy = Context.getTagDeclType(const_cast<TagDecl *>(TD)); - const llvm::Type *T = ConvertType(NewTy); - if (!isa<llvm::OpaqueType>(T)) - return; - - // Remember the opaque LLVM type for this tagdecl. llvm::DenseMap<const TagDecl*, llvm::PATypeHolder>::iterator TDTI = - TagDeclTypes.find(TD); + TagDeclTypes.find(TD); + if (TDTI == TagDeclTypes.end()) return; + + // Remember the opaque LLVM type for this tagdecl. llvm::PATypeHolder OpaqueHolder = TDTI->second; assert(isa<llvm::OpaqueType>(OpaqueHolder.get()) && - "Forcing compilation of non-opaque type?"); + "Updating compilation of an already non-opaque type?"); // Remove it from TagDeclTypes so that it will be regenerated. TagDeclTypes.erase(TDTI); + QualType NewTy = Context.getTagDeclType(const_cast<TagDecl*>(TD)); const llvm::Type *NT = ConvertNewType(NewTy); // If getting the type didn't itself refine it, refine it to its actual type |