diff options
author | Piotr Padlewski <piotr.padlewski@gmail.com> | 2017-06-01 08:04:05 +0000 |
---|---|---|
committer | Piotr Padlewski <piotr.padlewski@gmail.com> | 2017-06-01 08:04:05 +0000 |
commit | d3b1cbd17fb4b4be18f84cb30d7cb6d9c5e205d6 (patch) | |
tree | e4340fb4030bead69cfc4be12f99278d8b14db9a /clang/test/CodeGenCXX/vtable-available-externally.cpp | |
parent | d602987271add15aac3d6d3c751a219f7b30e067 (diff) | |
download | bcm5719-llvm-d3b1cbd17fb4b4be18f84cb30d7cb6d9c5e205d6.tar.gz bcm5719-llvm-d3b1cbd17fb4b4be18f84cb30d7cb6d9c5e205d6.zip |
Emit available_externally vtables opportunistically
Summary:
We can emit vtable definition having inline function
if they are all emitted.
Reviewers: rjmccall, rsmith
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D33437
llvm-svn: 304394
Diffstat (limited to 'clang/test/CodeGenCXX/vtable-available-externally.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/vtable-available-externally.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/clang/test/CodeGenCXX/vtable-available-externally.cpp b/clang/test/CodeGenCXX/vtable-available-externally.cpp index ae81959a75e..db99f73d9e7 100644 --- a/clang/test/CodeGenCXX/vtable-available-externally.cpp +++ b/clang/test/CodeGenCXX/vtable-available-externally.cpp @@ -12,6 +12,7 @@ // RUN: FileCheck --check-prefix=CHECK-TEST14 %s < %t.opt // RUN: FileCheck --check-prefix=CHECK-TEST15 %s < %t.opt // RUN: FileCheck --check-prefix=CHECK-TEST16 %s < %t.opt +// RUN: FileCheck --check-prefix=CHECK-TEST17 %s < %t.opt #include <typeinfo> @@ -274,8 +275,8 @@ struct C { virtual D& operator=(const D&); }; -// Cannot emit B's vtable available_externally, because we cannot create -// a reference to the inline virtual B::operator= function. +// Cannot emit D's vtable available_externally, because we cannot create +// a reference to the inline virtual D::operator= function. // CHECK-TEST11: @_ZTVN6Test111DE = external unnamed_addr constant struct D : C { virtual void key(); @@ -391,3 +392,30 @@ void test() { } } +namespace Test17 { +// This test checks if we emit vtables opportunistically. +// CHECK-TEST17-DAG: @_ZTVN6Test171AE = available_externally +// CHECK-TEST17-DAG: @_ZTVN6Test171BE = external + +struct A { + virtual void key(); + virtual void bar() {} +}; + +// We won't gonna use deleting destructor for this type, which will disallow +// emitting vtable as available_externally +struct B { + virtual void key(); + virtual ~B() {} +}; + +void testcaseA() { + A a; + a.bar(); // this forces to emit definition of bar +} + +void testcaseB() { + B b; // This only forces emitting of complete object destructor +} + +} // namespace Test17 |