From 18ca0475d718b199432a3813d97b002190bb8d74 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 10 Jul 2011 06:03:22 +0000 Subject: [PATCH] implement a nice new optimization: CodeGenTypes::UpdateCompletedType 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. llvm-svn: 134866 --- clang/lib/CodeGen/CodeGenTypes.cpp | 2 +- clang/test/CodeGenCXX/template-anonymous-types.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index 16946b64b3d8..967cd709c896 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -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); } diff --git a/clang/test/CodeGenCXX/template-anonymous-types.cpp b/clang/test/CodeGenCXX/template-anonymous-types.cpp index c684fa798cde..72fe090ceb7f 100644 --- a/clang/test/CodeGenCXX/template-anonymous-types.cpp +++ b/clang/test/CodeGenCXX/template-anonymous-types.cpp @@ -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 }