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();
|
|
|
|
};
|
|
|
|
|
[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition
Summary:
Clang -fpic defaults to -fno-semantic-interposition (GCC -fpic defaults
to -fsemantic-interposition).
Users need to specify -fsemantic-interposition to get semantic
interposition behavior.
Semantic interposition is currently a best-effort feature. There may
still be some cases where it is not handled well.
Reviewers: peter.smith, rnk, serge-sans-paille, sfertile, jfb, jdoerfert
Subscribers: dschuff, jyknight, dylanmckay, nemanjai, jvesely, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, arphaman, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73865
2020-02-03 04:23:47 +08:00
|
|
|
// CHECK-LABEL: define dso_local 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();
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition
Summary:
Clang -fpic defaults to -fno-semantic-interposition (GCC -fpic defaults
to -fsemantic-interposition).
Users need to specify -fsemantic-interposition to get semantic
interposition behavior.
Semantic interposition is currently a best-effort feature. There may
still be some cases where it is not handled well.
Reviewers: peter.smith, rnk, serge-sans-paille, sfertile, jfb, jdoerfert
Subscribers: dschuff, jyknight, dylanmckay, nemanjai, jvesely, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, arphaman, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73865
2020-02-03 04:23:47 +08:00
|
|
|
// CHECK-LABEL: define dso_local 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()
|
[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition
Summary:
Clang -fpic defaults to -fno-semantic-interposition (GCC -fpic defaults
to -fsemantic-interposition).
Users need to specify -fsemantic-interposition to get semantic
interposition behavior.
Semantic interposition is currently a best-effort feature. There may
still be some cases where it is not handled well.
Reviewers: peter.smith, rnk, serge-sans-paille, sfertile, jfb, jdoerfert
Subscribers: dschuff, jyknight, dylanmckay, nemanjai, jvesely, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, arphaman, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73865
2020-02-03 04:23:47 +08:00
|
|
|
// CHECK-LABEL: define linkonce_odr dso_local 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()
|
[CodeGenModule] Assume dso_local for -fpic -fno-semantic-interposition
Summary:
Clang -fpic defaults to -fno-semantic-interposition (GCC -fpic defaults
to -fsemantic-interposition).
Users need to specify -fsemantic-interposition to get semantic
interposition behavior.
Semantic interposition is currently a best-effort feature. There may
still be some cases where it is not handled well.
Reviewers: peter.smith, rnk, serge-sans-paille, sfertile, jfb, jdoerfert
Subscribers: dschuff, jyknight, dylanmckay, nemanjai, jvesely, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, arphaman, PkmX, jocewei, jsji, Jim, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73865
2020-02-03 04:23:47 +08:00
|
|
|
// CHECK-LABEL: define linkonce_odr dso_local 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]] = !{}
|