]> granicus.if.org Git - clang/commitdiff
implement a nice new optimization: CodeGenTypes::UpdateCompletedType
authorChris Lattner <sabre@nondot.org>
Sun, 10 Jul 2011 06:03:22 +0000 (06:03 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 10 Jul 2011 06:03:22 +0000 (06:03 +0000)
is called whenever a tag type is completed.  We previously used that
as the sign to layout the codegen representation for the tag type,
which worked but meant that we laid out *every* completed type, whether
it was used or not.

Now we just lay out the type if we've already seen it somehow else.
This means that we lay out types we've used but haven't seen a body
for, but we don't lay out tons of stuff that noone cares about.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134866 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenTypes.cpp
test/CodeGenCXX/template-anonymous-types.cpp

index 16946b64b3d8cb99e2cd30cf4382c0701db5ace9..967cd709c896f3cc61d2b0a95a577f088edb3509 100644 (file)
@@ -167,7 +167,7 @@ void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
 
   // Only complete it if we converted it already.  If we haven't converted it
   // yet, we'll just do it lazily.
// if (RecordDeclTypes.count(Context.getTagDeclType(RD).getTypePtr()))
+  if (RecordDeclTypes.count(Context.getTagDeclType(RD).getTypePtr()))
     ConvertRecordDeclType(RD);
 }
 
index c684fa798cdeda83ff72927586b4e17c586a631d..72fe090ceb7fd3e2e52f6edd286babffed8d23cd 100644 (file)
@@ -28,10 +28,10 @@ void test() {
   // reverse order.
   //
   // BAR's instantiation of X:
-  // CHECK: define internal i32 @"_ZN1XIN1S3$_1EE1fEv"(%struct.X.0* %this)
-  // CHECK: define internal void @"_ZN1XIN1S3$_1EEC2ES1_"(%struct.X.0* %this, i32 %t) unnamed_addr
+  // CHECK: define internal i32 @"_ZN1XIN1S3$_1EE1fEv"(%struct.X* %this)
+  // CHECK: define internal void @"_ZN1XIN1S3$_1EEC2ES1_"(%struct.X* %this, i32 %t) unnamed_addr
   //
   // FOO's instantiation of X:
-  // CHECK: define internal i32 @"_ZN1XIN1S3$_0EE1fEv"(%struct.X* %this)
-  // CHECK: define internal void @"_ZN1XIN1S3$_0EEC2ES1_"(%struct.X* %this, i32 %t) unnamed_addr
+  // CHECK: define internal i32 @"_ZN1XIN1S3$_0EE1fEv"(%struct.X.0* %this)
+  // CHECK: define internal void @"_ZN1XIN1S3$_0EEC2ES1_"(%struct.X.0* %this, i32 %t) unnamed_addr
 }