diff options
author | Piotr Padlewski <prazek@google.com> | 2015-09-10 20:18:30 +0000 |
---|---|---|
committer | Piotr Padlewski <prazek@google.com> | 2015-09-10 20:18:30 +0000 |
commit | 4bed31b9bffedfdcbf7177ceb465da7f04cc08b5 (patch) | |
tree | 2915b111207042b146523b59045ea90daed69596 /clang/test | |
parent | 4eb5d5a02d8bca389aae3d43a317e3d0bdeba2de (diff) | |
download | bcm5719-llvm-4bed31b9bffedfdcbf7177ceb465da7f04cc08b5.tar.gz bcm5719-llvm-4bed31b9bffedfdcbf7177ceb465da7f04cc08b5.zip |
Revert "Generating assumption loads of vptr after ctor call (fixed)"
It seems that there is small bug, and we can't generate assume loads
when some virtual functions have internal visibiliy
This reverts commit 982bb7d966947812d216489b3c519c9825cacbf2.
llvm-svn: 247332
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CodeGen/available-externally-hidden.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/ctor-globalopt.cpp | 4 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/thunks.cpp | 30 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/virtual-base-ctor.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/vtable-assume-load.cpp | 293 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/vtable-available-externally.cpp | 25 |
6 files changed, 24 insertions, 332 deletions
diff --git a/clang/test/CodeGen/available-externally-hidden.cpp b/clang/test/CodeGen/available-externally-hidden.cpp index 88ebfa9684a..dc13f26b752 100644 --- a/clang/test/CodeGen/available-externally-hidden.cpp +++ b/clang/test/CodeGen/available-externally-hidden.cpp @@ -27,6 +27,6 @@ class TestSyncMessageFilter : public SyncMessageFilter { }; int main() { - TestSyncMessageFilter *f = new TestSyncMessageFilter; +TestSyncMessageFilter* f = new TestSyncMessageFilter; f->Send(new Message); } diff --git a/clang/test/CodeGenCXX/ctor-globalopt.cpp b/clang/test/CodeGenCXX/ctor-globalopt.cpp index 0951278d317..5ba868fb1be 100644 --- a/clang/test/CodeGenCXX/ctor-globalopt.cpp +++ b/clang/test/CodeGenCXX/ctor-globalopt.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s -O2 | opt - -S -globalopt -o - | FileCheck %s --check-prefix=O1 +// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s -O1 | FileCheck %s --check-prefix=O1 // RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s -O2 | opt - -S -globalopt -o - | FileCheck %s --check-prefix=O1 +// RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s -O1 | FileCheck %s --check-prefix=O1 // Check that GlobalOpt can eliminate static constructors for simple implicit // constructors. This is a targeted integration test to make sure that LLVM's diff --git a/clang/test/CodeGenCXX/thunks.cpp b/clang/test/CodeGenCXX/thunks.cpp index 3a598b90afe..38afb9d0dbf 100644 --- a/clang/test/CodeGenCXX/thunks.cpp +++ b/clang/test/CodeGenCXX/thunks.cpp @@ -1,9 +1,5 @@ -// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o %t -// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o %t.opt -O1 -disable-llvm-optzns -// RUN: FileCheck %s < %t -// RUN: FileCheck %s < %t.opt -// RUN: FileCheck --check-prefix=CHECK-NONOPT %s < %t -// RUN: FileCheck --check-prefix=CHECK-OPT %s < %t.opt +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple=x86_64-pc-linux-gnu -munwind-tables -emit-llvm -o - -O1 -disable-llvm-optzns | FileCheck %s namespace Test1 { @@ -384,25 +380,13 @@ D::~D() {} /**** The following has to go at the end of the file ****/ -// checking without opt -// CHECK-NONOPT-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv( -// CHECK-NONOPT-NOT: comdat - -// This is from Test5: -// CHECK-NONOPT-LABEL: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv - -// This is from Test10: -// CHECK-NONOPT-LABEL: define linkonce_odr void @_ZN6Test101C3fooEv -// CHECK-NONOPT-LABEL: define linkonce_odr void @_ZThn8_N6Test101C3fooEv - -// Checking with opt -// CHECK-OPT-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv(%"struct.Test4B::(anonymous namespace)::C"* %this) unnamed_addr #0 align 2 - // This is from Test5: -// CHECK-OPT-LABEL: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv +// CHECK-LABEL: define internal void @_ZThn8_N6Test4B12_GLOBAL__N_11C1fEv( +// CHECK-NOT: comdat +// CHECK-LABEL: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv // This is from Test10: -// CHECK-OPT-LABEL: define linkonce_odr void @_ZN6Test101C3fooEv -// CHECK-OPT-LABEL: define linkonce_odr void @_ZThn8_N6Test101C3fooEv +// CHECK-LABEL: define linkonce_odr void @_ZN6Test101C3fooEv +// CHECK-LABEL: define linkonce_odr void @_ZThn8_N6Test101C3fooEv // CHECK: attributes [[NUW]] = { nounwind uwtable{{.*}} } diff --git a/clang/test/CodeGenCXX/virtual-base-ctor.cpp b/clang/test/CodeGenCXX/virtual-base-ctor.cpp index 20a88cd3710..8c28965c5c2 100644 --- a/clang/test/CodeGenCXX/virtual-base-ctor.cpp +++ b/clang/test/CodeGenCXX/virtual-base-ctor.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -o - -O2 | opt - -S -globalopt -o - | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -triple %itanium_abi_triple -o - -O2 | FileCheck %s struct B; extern B x; diff --git a/clang/test/CodeGenCXX/vtable-assume-load.cpp b/clang/test/CodeGenCXX/vtable-assume-load.cpp deleted file mode 100644 index d527ab0a1a0..00000000000 --- a/clang/test/CodeGenCXX/vtable-assume-load.cpp +++ /dev/null @@ -1,293 +0,0 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o %t.ll -O1 -disable-llvm-optzns -fms-extensions -// RUN: %clang_cc1 %s -triple i686-pc-win32 -emit-llvm -o %t.ms.ll -O1 -disable-llvm-optzns -fms-extensions - -// RUN: FileCheck --check-prefix=CHECK1 --input-file=%t.ll %s -// RUN: FileCheck --check-prefix=CHECK2 --input-file=%t.ll %s -// RUN: FileCheck --check-prefix=CHECK3 --input-file=%t.ll %s -// RUN: FileCheck --check-prefix=CHECK4 --input-file=%t.ll %s -// RUN: FileCheck --check-prefix=CHECK-MS --input-file=%t.ms.ll %s -// RUN: FileCheck --check-prefix=CHECK6 --input-file=%t.ll %s -// RUN: FileCheck --check-prefix=CHECK7 --input-file=%t.ll %s -// RUN: FileCheck --check-prefix=CHECK8 --input-file=%t.ll %s -namespace test1 { - -struct A { - A(); - virtual void foo(); -}; - -struct B : A { - virtual void foo(); -}; - -void g(A *a) { a->foo(); } - -// CHECK1-LABEL: define void @_ZN5test14fooAEv() -// CHECK1: call void @_ZN5test11AC1Ev(%"struct.test1::A"* -// CHECK1: %[[VTABLE:.*]] = load i8**, i8*** %{{.*}} -// CHECK1: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5test11AE, i64 0, i64 2) -// CHECK1: call void @llvm.assume(i1 %[[CMP]]) -// CHECK1-LABEL: } - -void fooA() { - A a; - g(&a); -} - -// CHECK1-LABEL: define void @_ZN5test14fooBEv() -// CHECK1: call void @_ZN5test11BC1Ev(%"struct.test1::B"* %{{.*}}) -// CHECK1: %[[VTABLE:.*]] = load i8**, i8*** %{{.*}} -// CHECK1: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([3 x i8*], [3 x i8*]* @_ZTVN5test11BE, i64 0, i64 2) -// CHECK1: call void @llvm.assume(i1 %[[CMP]]) -// CHECK1-LABEL: } - -void fooB() { - B b; - g(&b); -} -// there should not be any assumes in the ctor that calls base ctor -// CHECK1-LABEL: define linkonce_odr void @_ZN5test11BC2Ev(%"struct.test1::B"* -// CHECK1-NOT: @llvm.assume( -// CHECK1-LABEL: } -} -namespace test2 { -struct A { - A(); - virtual void foo(); -}; - -struct B { - B(); - virtual void bar(); -}; - -struct C : A, B { - C(); - virtual void foo(); -}; -void g(A *a) { a->foo(); } -void h(B *b) { b->bar(); } - -// CHECK2-LABEL: define void @_ZN5test24testEv() -// CHECK2: call void @_ZN5test21CC1Ev(%"struct.test2::C"* -// CHECK2: %[[VTABLE:.*]] = load i8**, i8*** {{.*}} -// CHECK2: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTVN5test21CE, i64 0, i64 2) -// CHECK2: call void @llvm.assume(i1 %[[CMP]]) - -// CHECK2: %[[V2:.*]] = bitcast %"struct.test2::C"* %{{.*}} to i8* -// CHECK2: %[[ADD_PTR:.*]] = getelementptr inbounds i8, i8* %[[V2]], i64 8 -// CHECK2: %[[V3:.*]] = bitcast i8* %[[ADD_PTR]] to i8*** -// CHECK2: %[[VTABLE2:.*]] = load i8**, i8*** %[[V3]] -// CHECK2: %[[CMP2:.*]] = icmp eq i8** %[[VTABLE2]], getelementptr inbounds ([6 x i8*], [6 x i8*]* @_ZTVN5test21CE, i64 0, i64 5) -// CHECK2: call void @llvm.assume(i1 %[[CMP2]]) - -// CHECK2: call void @_ZN5test21gEPNS_1AE( -// CHECK2-LABEL: } - -void test() { - C c; - g(&c); - h(&c); -} -} - -namespace test3 { -struct A { - A(); -}; - -struct B : A { - B(); - virtual void foo(); -}; - -struct C : virtual A, B { - C(); - virtual void foo(); -}; -void g(B *a) { a->foo(); } - -// CHECK3-LABEL: define void @_ZN5test34testEv() -// CHECK3: call void @_ZN5test31CC1Ev(%"struct.test3::C"* -// CHECK3: %[[CMP:.*]] = icmp eq i8** %{{.*}}, getelementptr inbounds ([4 x i8*], [4 x i8*]* @_ZTVN5test31CE, i64 0, i64 3) -// CHECK3: call void @llvm.assume(i1 %[[CMP]]) -// CHECK3-LABLEL: } -void test() { - C c; - g(&c); -} -} // test3 - -namespace test4 { -struct A { - A(); - virtual void foo(); -}; - -struct B : virtual A { - B(); - virtual void foo(); -}; -struct C : B { - C(); - virtual void foo(); -}; - -void g(C *c) { c->foo(); } - -// CHECK4-LABEL: define void @_ZN5test44testEv() -// CHECK4: call void @_ZN5test41CC1Ev(%"struct.test4::C"* -// CHECK4: %[[VTABLE:.*]] = load i8**, i8*** %{{.*}} -// CHECK4: %[[CMP:.*]] = icmp eq i8** %[[VTABLE]], getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5test41CE, i64 0, i64 4) -// CHECK4: call void @llvm.assume(i1 %[[CMP]] - -// CHECK4: %[[VTABLE2:.*]] = load i8**, i8*** %{{.*}} -// CHECK4: %[[CMP2:.*]] = icmp eq i8** %[[VTABLE2]], getelementptr inbounds ([5 x i8*], [5 x i8*]* @_ZTVN5test41CE, i64 0, i64 4) -// CHECK4: call void @llvm.assume(i1 %[[CMP2]]) -// CHECK4-LABEL: } - -void test() { - C c; - g(&c); -} -} // test4 - -namespace testMS { - -struct __declspec(novtable) S { - virtual void foo(); -}; - -void g(S &s) { s.foo(); } - -// if struct has novtable specifier, then we can't generate assumes -// CHECK-MS-LABEL: define void @"\01?test@testMS@@YAXXZ"() -// CHECK-MS: call x86_thiscallcc %"struct.testMS::S"* @"\01??0S@testMS@@QAE@XZ"( -// CHECK-MS-NOT: @llvm.assume -// CHECK-MS-LABEL: } - -void test() { - S s; - g(s); -} - -} // testMS - -namespace test6 { -// CHECK6: @_ZTVN5test61AE = external -struct A { - A(); - virtual void foo(); - virtual ~A() {} -}; -struct B : A { - B(); -}; -// Because A's vtable is external, it's safe to generate assumption loads. -// CHECK6-LABEL: define void @_ZN5test61gEv() -// CHECK6: call void @_ZN5test61AC1Ev( -// CHECK6: call void @llvm.assume( - -// We can't emit assumption loads for B, because if we would refer to vtable -// it would refer to functions that will not be able to find (like implicit -// inline destructor). - -// CHECK6-LABEL: call void @_ZN5test61BC1Ev( -// CHECK6-NOT: call void @llvm.assume( -// CHECK6-LABEL: } -void g() { - A *a = new A; - B *b = new B; -} -} - -namespace test7 { -// Because A's key function is defined here, vtable is generated in this TU -// CHECK7: @_ZTVN5test71AE = unnamed_addr constant -struct A { - A(); - virtual void foo(); - virtual void bar(); -}; -void A::foo() {} - -// CHECK7-LABEL: define void @_ZN5test71gEv() -// CHECK7: call void @_ZN5test71AC1Ev( -// CHECK7: call void @llvm.assume( -// CHECK7-LABEL: } -void g() { - A *a = new A(); - a->bar(); -} -} - -namespace test8 { - -struct A { - virtual void foo(); - virtual void bar(); -}; - -// CHECK8-DAG: @_ZTVN5test81BE = available_externally unnamed_addr constant -struct B : A { - B(); - void foo(); - void bar(); -}; - -// CHECK8-DAG: @_ZTVN5test81CE = linkonce_odr unnamed_addr constant -struct C : A { - C(); - void bar(); - void foo() {} -}; -inline void C::bar() {} - -// CHECK8-DAG: @_ZTVN5test81DE = external unnamed_addr constant -struct D : A { - D(); - void foo(); - void inline bar(); -}; -void D::bar() {} - -// CHECK8-DAG: @_ZTVN5test81EE = linkonce_odr unnamed_addr constant -struct E : A { - E(); -}; - -// CHECK8-LABEL: define void @_ZN5test81bEv() -// CHECK8: call void @llvm.assume( -// CHECK8-LABEL: } -void b() { - B b; - b.bar(); -} - -// FIXME: C has inline virtual functions which prohibits as from generating -// assumption loads, but because vtable is generated in this TU (key function -// defined here) it would be correct to refer to it. -// CHECK8-LABEL: define void @_ZN5test81cEv() -// CHECK8-NOT: call void @llvm.assume( -// CHECK8-LABEL: } -void c() { - C c; - c.bar(); -} - -// CHECK8-LABEL: define void @_ZN5test81dEv() -// CHECK8: call void @llvm.assume( -// CHECK8-LABEL: } -void d() { - D d; - d.bar(); -} - -// CHECK8-LABEL: define void @_ZN5test81eEv() -// CHECK8: call void @llvm.assume( -// CHECK8-LABEL: } -void e() { - E e; - e.bar(); -} -} diff --git a/clang/test/CodeGenCXX/vtable-available-externally.cpp b/clang/test/CodeGenCXX/vtable-available-externally.cpp index ba56499f674..4527efca96f 100644 --- a/clang/test/CodeGenCXX/vtable-available-externally.cpp +++ b/clang/test/CodeGenCXX/vtable-available-externally.cpp @@ -184,10 +184,10 @@ void f() { } // Test8 namespace Test9 { -// All virtual functions are outline, so we can assume that it will -// be generated in translation unit where foo is defined. -// CHECK-TEST9-DAG: @_ZTVN5Test91AE = available_externally unnamed_addr constant -// CHECK-TEST9-DAG: @_ZTVN5Test91BE = available_externally unnamed_addr constant +// all virtual functions are outline, so we can assume that it will +// be generated in translation unit where foo is defined +// CHECK-TEST9: @_ZTVN5Test91AE = available_externally unnamed_addr constant +// CHECK-TEST9: @_ZTVN5Test91BE = available_externally unnamed_addr constant struct A { virtual void foo(); virtual void bar(); @@ -210,22 +210,22 @@ void g() { namespace Test10 { // because A's key function is defined here, vtable is generated in this TU -// CHECK-TEST10-DAG: @_ZTVN6Test101AE = unnamed_addr constant +// CHECK-TEST10: @_ZTVN6Test101AE = unnamed_addr constant struct A { virtual void foo(); virtual void bar(); }; void A::foo() {} -// Because key function is inline we will generate vtable as linkonce_odr. -// CHECK-TEST10-DAG: @_ZTVN6Test101DE = linkonce_odr unnamed_addr constant +// Because key function is inline we will generate vtable as linkonce_odr +// CHECK-TEST10: @_ZTVN6Test101DE = linkonce_odr unnamed_addr constant struct D : A { void bar(); }; inline void D::bar() {} -// Because B has outline all virtual functions, we can refer to them. -// CHECK-TEST10-DAG: @_ZTVN6Test101BE = available_externally unnamed_addr constant +// because B has outline key function then we can refer to +// CHECK-TEST10: @_ZTVN6Test101BE = available_externally unnamed_addr constant struct B : A { void foo(); void bar(); @@ -233,8 +233,8 @@ struct B : A { // C's key function (car) is outline, but C has inline virtual function so we // can't guarantee that we will be able to refer to bar from name -// so (at the moment) we can't emit vtable available_externally. -// CHECK-TEST10-DAG: @_ZTVN6Test101CE = external unnamed_addr constant +// so (at the moment) we can't emit vtable available_externally +// CHECK-TEST10: @_ZTVN6Test101CE = external unnamed_addr constant struct C : A { void bar() {} // defined in body - not key function virtual inline void gar(); // inline in body - not key function @@ -242,7 +242,7 @@ struct C : A { }; // no key function, vtable will be generated everywhere it will be used -// CHECK-TEST10-DAG: @_ZTVN6Test101EE = linkonce_odr unnamed_addr constant +// CHECK-TEST10: @_ZTVN6Test101EE = linkonce_odr unnamed_addr constant struct E : A {}; void g(A& a) { @@ -365,3 +365,4 @@ void test() { } } + |