forked from OSchip/llvm-project
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. llvm-svn: 46802
This commit is contained in:
parent
68be60694e
commit
f6e3669eb2
|
@ -128,23 +128,19 @@ const llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T) {
|
||||||
/// UpdateCompletedType - When we find the full definition for a TagDecl,
|
/// UpdateCompletedType - When we find the full definition for a TagDecl,
|
||||||
/// replace the 'opaque' type we previously made for it if applicable.
|
/// replace the 'opaque' type we previously made for it if applicable.
|
||||||
void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
|
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 =
|
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;
|
llvm::PATypeHolder OpaqueHolder = TDTI->second;
|
||||||
assert(isa<llvm::OpaqueType>(OpaqueHolder.get()) &&
|
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.
|
// Remove it from TagDeclTypes so that it will be regenerated.
|
||||||
TagDeclTypes.erase(TDTI);
|
TagDeclTypes.erase(TDTI);
|
||||||
|
|
||||||
|
QualType NewTy = Context.getTagDeclType(const_cast<TagDecl*>(TD));
|
||||||
const llvm::Type *NT = ConvertNewType(NewTy);
|
const llvm::Type *NT = ConvertNewType(NewTy);
|
||||||
|
|
||||||
// If getting the type didn't itself refine it, refine it to its actual type
|
// If getting the type didn't itself refine it, refine it to its actual type
|
||||||
|
|
Loading…
Reference in New Issue