[cfe-commits] r131400 - in /cfe/trunk: lib/CodeGen/CGClass.cpp lib/CodeGen/CGVTT.cpp lib/CodeGen/CGVTables.cpp test/CodeGenCXX/mangle-subst-std.cpp test/CodeGenCXX/skip-vtable-pointer-initialization.cpp test/CodeGenCXX/virtual-base-destructor-call.cpp
Anders Carlsson
andersca at mac.com
Sun May 15 21:08:36 PDT 2011
Author: andersca
Date: Sun May 15 23:08:36 2011
New Revision: 131400
URL: http://llvm.org/viewvc/llvm-project?rev=131400&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGVTT.cpp
cfe/trunk/lib/CodeGen/CGVTables.cpp
cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp
cfe/trunk/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
cfe/trunk/test/CodeGenCXX/virtual-base-destructor-call.cpp
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=131400&r1=131399&r2=131400&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Sun May 15 23:08:36 2011
@@ -812,7 +812,7 @@
/// 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;
Modified: cfe/trunk/lib/CodeGen/CGVTT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTT.cpp?rev=131400&r1=131399&r2=131400&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTT.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTT.cpp Sun May 15 23:08:36 2011
@@ -411,6 +411,8 @@
Out.flush();
llvm::StringRef Name = OutName.str();
+ ComputeVTableRelatedInformation(RD, /*VTableRequired=*/true);
+
VTTBuilder Builder(CGM, RD, /*GenerateDefinition=*/false);
const llvm::Type *Int8PtrTy =
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=131400&r1=131399&r2=131400&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Sun May 15 23:08:36 2011
@@ -3175,7 +3175,7 @@
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 =
Modified: cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp?rev=131400&r1=131399&r2=131400&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-subst-std.cpp Sun May 15 23:08:36 2011
@@ -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(); };
Modified: cfe/trunk/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp?rev=131400&r1=131399&r2=131400&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp Sun May 15 23:08:36 2011
@@ -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 @@
}
}
+
+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() {}
+
+}
Modified: cfe/trunk/test/CodeGenCXX/virtual-base-destructor-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-base-destructor-call.cpp?rev=131400&r1=131399&r2=131400&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/virtual-base-destructor-call.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/virtual-base-destructor-call.cpp Sun May 15 23:08:36 2011
@@ -27,11 +27,6 @@
// 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 @@
// 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: }
More information about the cfe-commits
mailing list