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();
|
|
|
|
};
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define void @_Z21testExternallyVisiblev()
|
2015-09-16 05:46:55 +08:00
|
|
|
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();
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define void @_Z21testInternallyVisibleb(
|
2015-09-16 05:46:55 +08:00
|
|
|
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()
|
2020-02-04 02:09:39 +08:00
|
|
|
// 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()
|
2020-02-04 02:09:39 +08:00
|
|
|
// CHECK-LABEL: define linkonce_odr void @_ZN1DC2Ev(
|
2018-05-03 19:03:01 +08:00
|
|
|
// CHECK: = call i8* @llvm.launder.invariant.group.p0i8(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]] = !{}
|