2016-12-23 08:23:01 +08:00
|
|
|
// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -emit-llvm %s -fstrict-vtable-pointers -O1 -o - -disable-llvm-passes | FileCheck %s
|
2015-09-16 05:46:55 +08:00
|
|
|
|
|
|
|
struct A {
|
|
|
|
virtual void foo();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct D : A {
|
|
|
|
void foo();
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @_Z21testExternallyVisiblev()
|
|
|
|
void testExternallyVisible() {
|
|
|
|
A *a = new A;
|
|
|
|
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: load {{.*}} !invariant.group ![[MD:[0-9]+]]
|
2015-09-16 05:46:55 +08:00
|
|
|
a->foo();
|
|
|
|
|
|
|
|
D *d = new D;
|
|
|
|
// CHECK: call void @_ZN1DC1Ev(
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: load {{.*}} !invariant.group ![[MD]]
|
2015-09-16 05:46:55 +08:00
|
|
|
d->foo();
|
|
|
|
A *a2 = d;
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: load {{.*}} !invariant.group ![[MD]]
|
2015-09-16 05:46:55 +08:00
|
|
|
a2->foo();
|
|
|
|
}
|
2016-12-14 04:40:39 +08:00
|
|
|
// CHECK-LABEL: {{^}}}
|
2015-09-16 05:46:55 +08:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
struct B {
|
|
|
|
virtual void bar();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct C : B {
|
|
|
|
void bar();
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @_Z21testInternallyVisibleb(
|
|
|
|
void testInternallyVisible(bool p) {
|
|
|
|
B *b = new B;
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: = load {{.*}}, !invariant.group ![[MD]]
|
2015-09-16 05:46:55 +08:00
|
|
|
b->bar();
|
|
|
|
|
|
|
|
// CHECK: call void @_ZN12_GLOBAL__N_11CC1Ev(
|
|
|
|
C *c = new C;
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: = load {{.*}}, !invariant.group ![[MD]]
|
2015-09-16 05:46:55 +08:00
|
|
|
c->bar();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checking A::A()
|
|
|
|
// CHECK-LABEL: define linkonce_odr void @_ZN1AC2Ev(
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: store {{.*}}, !invariant.group ![[MD]]
|
2016-12-14 04:40:39 +08:00
|
|
|
// CHECK-LABEL: {{^}}}
|
2015-09-16 05:46:55 +08:00
|
|
|
|
|
|
|
// Checking D::D()
|
|
|
|
// CHECK-LABEL: define linkonce_odr void @_ZN1DC2Ev(
|
|
|
|
// CHECK: = call i8* @llvm.invariant.group.barrier(i8*
|
2015-10-03 06:12:40 +08:00
|
|
|
// CHECK: call void @_ZN1AC2Ev(%struct.A*
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: store {{.*}} !invariant.group ![[MD]]
|
2015-09-16 05:46:55 +08:00
|
|
|
|
|
|
|
// Checking B::B()
|
|
|
|
// CHECK-LABEL: define internal void @_ZN12_GLOBAL__N_11BC2Ev(
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: store {{.*}}, !invariant.group ![[MD]]
|
2015-09-16 05:46:55 +08:00
|
|
|
|
|
|
|
// Checking C::C()
|
|
|
|
// CHECK-LABEL: define internal void @_ZN12_GLOBAL__N_11CC2Ev(
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: store {{.*}}, !invariant.group ![[MD]]
|
2015-09-16 05:46:55 +08:00
|
|
|
|
2017-04-24 20:58:43 +08:00
|
|
|
// CHECK: ![[MD]] = !{}
|