[cfe-commits] r46802 - /cfe/trunk/CodeGen/CodeGenTypes.cpp

Chris Lattner sabre at nondot.org
Tue Feb 5 21:12:09 PST 2008


Author: lattner
Date: Tue Feb  5 23:12:09 2008
New Revision: 46802

URL: http://llvm.org/viewvc/llvm-project?rev=46802&view=rev
Log:
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.

Modified:
    cfe/trunk/CodeGen/CodeGenTypes.cpp

Modified: cfe/trunk/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.cpp?rev=46802&r1=46801&r2=46802&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/CodeGen/CodeGenTypes.cpp Tue Feb  5 23:12:09 2008
@@ -128,23 +128,19 @@
 /// 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





More information about the cfe-commits mailing list