diff options
author | Anders Carlsson <andersca@mac.com> | 2011-05-16 04:08:36 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2011-05-16 04:08:36 +0000 |
commit | d6f1518cc905cffa641a0ced3be943664cb5e8e6 (patch) | |
tree | 8661cdd3bfe4ecba1a76ce8787881ee68f659fc6 /clang | |
parent | 2050af838d717c1bc06fd1f340f8839c092e694a (diff) | |
download | bcm5719-llvm-d6f1518cc905cffa641a0ced3be943664cb5e8e6.tar.gz bcm5719-llvm-d6f1518cc905cffa641a0ced3be943664cb5e8e6.zip |
Fix another regression from the "skip vtable pointer initialization"
optimization. Make sure to require a vtable when trying to get the address
of a VTT, otherwise we would never end up emitting the VTT.
llvm-svn: 131400
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CGClass.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGVTT.cpp | 2 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGVTables.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/mangle-subst-std.cpp | 3 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp | 14 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/virtual-base-destructor-call.cpp | 10 |
6 files changed, 25 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 8b4684cb387..0d2500894e9 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -812,7 +812,7 @@ FieldHasTrivialDestructorBody(ASTContext &Context, /// CanSkipVTablePointerInitialization - Check whether we need to initialize /// any vtable pointers before calling this destructor. static bool CanSkipVTablePointerInitialization(ASTContext &Context, - const CXXDestructorDecl *Dtor) { + const CXXDestructorDecl *Dtor) { if (!Dtor->hasTrivialBody()) return false; diff --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp index a6849f8f3d2..aefc41e5000 100644 --- a/clang/lib/CodeGen/CGVTT.cpp +++ b/clang/lib/CodeGen/CGVTT.cpp @@ -411,6 +411,8 @@ llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) { Out.flush(); llvm::StringRef Name = OutName.str(); + ComputeVTableRelatedInformation(RD, /*VTableRequired=*/true); + VTTBuilder Builder(CGM, RD, /*GenerateDefinition=*/false); const llvm::Type *Int8PtrTy = diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index c7ef9c74183..9ac5e67ada4 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -3175,7 +3175,7 @@ llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTable(const CXXRecordDecl *RD) { Out.flush(); llvm::StringRef Name = OutName.str(); - ComputeVTableRelatedInformation(RD, true); + ComputeVTableRelatedInformation(RD, /*VTableRequired=*/true); const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext()); llvm::ArrayType *ArrayType = diff --git a/clang/test/CodeGenCXX/mangle-subst-std.cpp b/clang/test/CodeGenCXX/mangle-subst-std.cpp index c54d3e5297f..837d4fa8570 100644 --- a/clang/test/CodeGenCXX/mangle-subst-std.cpp +++ b/clang/test/CodeGenCXX/mangle-subst-std.cpp @@ -8,9 +8,10 @@ // CHECK: @_ZTCSd0_Si = linkonce_odr unnamed_addr constant // CHECK: @_ZTCSd16_So = linkonce_odr unnamed_addr constant // CHECK: @_ZTTSo = linkonce_odr unnamed_addr constant -// CHECK: @_ZTTSi = linkonce_odr unnamed_addr constant // CHECK: @_ZTVSo = linkonce_odr unnamed_addr constant +// CHECK: @_ZTTSi = linkonce_odr unnamed_addr constant // CHECK: @_ZTVSi = linkonce_odr unnamed_addr constant + namespace std { struct A { A(); }; diff --git a/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp b/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp index 3520b912cf9..84697be4a4c 100644 --- a/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp +++ b/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp @@ -1,5 +1,7 @@ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// See Test9 for test description. +// CHECK: @_ZTTN5Test91BE = linkonce_odr unnamed_addr constant namespace Test1 { // Check that we don't initialize the vtable pointer in A::~A(), since the destructor body is trivial. @@ -184,3 +186,15 @@ A::~A() } } + +namespace Test9 { + +// Check that we emit a VTT for B, even though we don't initialize the vtable pointer in the destructor. +struct A { virtual ~A () { } }; +struct B : virtual A {}; +struct C : virtual B { + virtual ~C(); +}; +C::~C() {} + +} diff --git a/clang/test/CodeGenCXX/virtual-base-destructor-call.cpp b/clang/test/CodeGenCXX/virtual-base-destructor-call.cpp index 807eaff0d1d..f028e4c733f 100644 --- a/clang/test/CodeGenCXX/virtual-base-destructor-call.cpp +++ b/clang/test/CodeGenCXX/virtual-base-destructor-call.cpp @@ -27,11 +27,6 @@ int main() { // CHECK: call void @_ZN13basic_istreamIcED2Ev // CHECK: } -// basic_istream's base dtor is a no-op. -// CHECK: define linkonce_odr void @_ZN13basic_istreamIcED2Ev(%struct.basic_istream* %this, i8** %vtt) unnamed_addr -// CHECK-NOT: call -// CHECK: } - // basic_iostream's deleting dtor calls its complete dtor, then // operator delete(). // CHECK: define linkonce_odr void @_ZN14basic_iostreamIcED0Ev(%struct.basic_iostream* %this) unnamed_addr @@ -49,3 +44,8 @@ int main() { // CHECK: define linkonce_odr void @_ZN13basic_istreamIcED0Ev(%struct.basic_istream* %this) unnamed_addr // CHECK: call void @_ZN13basic_istreamIcED1Ev // CHECK: call void @_ZdlPv + +// basic_istream's base dtor is a no-op. +// CHECK: define linkonce_odr void @_ZN13basic_istreamIcED2Ev(%struct.basic_istream* %this, i8** %vtt) unnamed_addr +// CHECK-NOT: call +// CHECK: } |