[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
|
|
|
// RUN: %clang_cc1 -std=c++11 -S -triple x86_64-none-linux-gnu -emit-llvm -o - %s -fsemantic-interposition | FileCheck %s
|
2012-02-19 20:27:47 +08:00
|
|
|
|
|
|
|
namespace std {
|
|
|
|
typedef decltype(sizeof(int)) size_t;
|
|
|
|
|
|
|
|
// libc++'s implementation with __size_ replaced by __end_
|
|
|
|
template <class _E>
|
|
|
|
class initializer_list
|
|
|
|
{
|
|
|
|
const _E* __begin_;
|
|
|
|
const _E* __end_;
|
|
|
|
|
|
|
|
initializer_list(const _E* __b, const _E* __e)
|
|
|
|
: __begin_(__b),
|
|
|
|
__end_(__e)
|
|
|
|
{}
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef _E value_type;
|
|
|
|
typedef const _E& reference;
|
|
|
|
typedef const _E& const_reference;
|
|
|
|
typedef size_t size_type;
|
|
|
|
|
|
|
|
typedef const _E* iterator;
|
|
|
|
typedef const _E* const_iterator;
|
|
|
|
|
|
|
|
initializer_list() : __begin_(nullptr), __end_(nullptr) {}
|
|
|
|
|
|
|
|
size_t size() const {return __end_ - __begin_;}
|
|
|
|
const _E* begin() const {return __begin_;}
|
|
|
|
const _E* end() const {return __end_;}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-02-20 03:25:17 +08:00
|
|
|
// CHECK: @_ZGR15globalInitList1_ = internal constant [3 x i32] [i32 1, i32 2, i32 3]
|
2015-03-14 02:21:46 +08:00
|
|
|
// CHECK: @globalInitList1 = global {{[^ ]+}} { i32* getelementptr inbounds ([3 x i32], [3 x i32]* @_ZGR15globalInitList1_, {{[^)]*}}), i32*
|
2012-02-26 04:51:20 +08:00
|
|
|
std::initializer_list<int> globalInitList1 = {1, 2, 3};
|
|
|
|
|
2012-02-19 20:27:47 +08:00
|
|
|
void fn1(int i) {
|
[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 @_Z3fn1i
|
2012-02-19 20:27:47 +08:00
|
|
|
// temporary array
|
|
|
|
// CHECK: [[array:%[^ ]+]] = alloca [3 x i32]
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK: getelementptr inbounds [3 x i32], [3 x i32]* [[array]], i{{32|64}} 0
|
2012-02-19 20:27:47 +08:00
|
|
|
// CHECK-NEXT: store i32 1, i32*
|
|
|
|
// CHECK-NEXT: getelementptr
|
|
|
|
// CHECK-NEXT: store
|
|
|
|
// CHECK-NEXT: getelementptr
|
|
|
|
// CHECK-NEXT: load
|
|
|
|
// CHECK-NEXT: store
|
|
|
|
// init the list
|
|
|
|
// CHECK-NEXT: getelementptr
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds [3 x i32], [3 x i32]*
|
2012-02-19 20:27:47 +08:00
|
|
|
// CHECK-NEXT: store i32*
|
|
|
|
// CHECK-NEXT: getelementptr
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: getelementptr inbounds [3 x i32], [3 x i32]* [[array]], i{{32|64}} 0, i{{32|64}} 3
|
2012-02-19 20:27:47 +08:00
|
|
|
// CHECK-NEXT: store i32*
|
|
|
|
std::initializer_list<int> intlist{1, 2, i};
|
|
|
|
}
|
|
|
|
|
|
|
|
struct destroyme1 {
|
|
|
|
~destroyme1();
|
|
|
|
};
|
|
|
|
struct destroyme2 {
|
|
|
|
~destroyme2();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void fn2() {
|
[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 @_Z3fn2v
|
2012-02-19 20:27:47 +08:00
|
|
|
void target(std::initializer_list<destroyme1>);
|
|
|
|
// objects should be destroyed before dm2, after call returns
|
|
|
|
target({ destroyme1(), destroyme1() });
|
|
|
|
// CHECK: call void @_ZN10destroyme1D1Ev
|
|
|
|
destroyme2 dm2;
|
|
|
|
// CHECK: call void @_ZN10destroyme2D1Ev
|
|
|
|
}
|
|
|
|
|
|
|
|
void fn3() {
|
[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 @_Z3fn3v
|
2012-02-19 20:27:47 +08:00
|
|
|
// objects should be destroyed after dm2
|
|
|
|
auto list = { destroyme1(), destroyme1() };
|
|
|
|
destroyme2 dm2;
|
|
|
|
// CHECK: call void @_ZN10destroyme2D1Ev
|
|
|
|
// CHECK: call void @_ZN10destroyme1D1Ev
|
|
|
|
}
|