summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/destructors.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-02-23 00:48:20 +0000
committerJohn McCall <rjmccall@apple.com>2010-02-23 00:48:20 +0000
commitf8ff7b9fd1d087c421d0eb1c9cb3104739f7c33a (patch)
treef229d2b5be17ec853b0f84115c68efa65064aa98 /clang/test/CodeGenCXX/destructors.cpp
parent886915e3bb7fef8666be60f278dbe982db272870 (diff)
downloadbcm5719-llvm-f8ff7b9fd1d087c421d0eb1c9cb3104739f7c33a.tar.gz
bcm5719-llvm-f8ff7b9fd1d087c421d0eb1c9cb3104739f7c33a.zip
Perform two more constructor/destructor code-size optimizations:
1) emit base destructors as aliases to their unique base class destructors under some careful conditions. This is enabled for the same targets that can support complete-to-base aliases, i.e. not darwin. 2) Emit non-variadic complete constructors for classes with no virtual bases as calls to the base constructor. This is enabled on all targets and in theory can trigger in situations that the alias optimization can't (mostly involving virtual bases, mostly not yet supported). These are bundled together because I didn't think it worthwhile to split them, not because they really need to be. llvm-svn: 96842
Diffstat (limited to 'clang/test/CodeGenCXX/destructors.cpp')
-rw-r--r--clang/test/CodeGenCXX/destructors.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/clang/test/CodeGenCXX/destructors.cpp b/clang/test/CodeGenCXX/destructors.cpp
index f06661a7447..accd1b34986 100644
--- a/clang/test/CodeGenCXX/destructors.cpp
+++ b/clang/test/CodeGenCXX/destructors.cpp
@@ -1,4 +1,11 @@
// RUN: %clang_cc1 %s -emit-llvm -o - -mconstructor-aliases | FileCheck %s
+
+// CHECK: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
+// CHECK: @_ZN5test11MD2Ev = alias {{.*}} @_ZN5test11AD2Ev
+// CHECK: @_ZN5test11ND2Ev = alias {{.*}} @_ZN5test11AD2Ev
+// CHECK: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev
+// CHECK: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev
+
struct A {
int a;
@@ -60,7 +67,7 @@ namespace test0 {
// The function-try-block won't suppress -mconstructor-aliases here.
A::~A() try { } catch (int i) {}
-// CHECK: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
+// complete destructor alias tested above
// CHECK: define void @_ZN5test01AD2Ev
// CHECK: invoke void @_ZN5test06MemberD1Ev
@@ -89,3 +96,40 @@ namespace test0 {
// CHECK: invoke void @_ZN5test04BaseD2Ev
// CHECK: unwind label [[BASE_UNWIND:%[a-zA-Z0-9.]+]]
}
+
+// Test base-class aliasing.
+namespace test1 {
+ struct A { ~A(); char ***m; }; // non-trivial destructor
+ struct B { ~B(); }; // non-trivial destructor
+ struct Empty { }; // trivial destructor, empty
+ struct NonEmpty { int x; }; // trivial destructor, non-empty
+
+ struct M : A { ~M(); };
+ M::~M() {} // alias tested above
+
+ struct N : A, Empty { ~N(); };
+ N::~N() {} // alias tested above
+
+ struct O : Empty, A { ~O(); };
+ O::~O() {} // alias tested above
+
+ struct P : NonEmpty, A { ~P(); };
+ P::~P() {} // CHECK: define void @_ZN5test11PD2Ev
+
+ struct Q : A, B { ~Q(); };
+ Q::~Q() {} // CHECK: define void @_ZN5test11QD2Ev
+
+ struct R : A { ~R(); };
+ R::~R() { A a; } // CHECK: define void @_ZN5test11RD2Ev
+
+ struct S : A { ~S(); int x; };
+ S::~S() {} // alias tested above
+
+ struct T : A { ~T(); B x; };
+ T::~T() {} // CHECK: define void @_ZN5test11TD2Ev
+
+ // The VTT parameter prevents this. We could still make this work
+ // for calling conventions that are safe against extra parameters.
+ struct U : A, virtual B { ~U(); };
+ U::~U() {} // CHECK: define void @_ZN5test11UD2Ev
+}
OpenPOWER on IntegriCloud