2019-10-31 23:41:37 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck -enable-var-scope -check-prefixes=CHECK,X86 %s
|
|
|
|
// RUN: %clang_cc1 -triple amdgcn -emit-llvm < %s | FileCheck -enable-var-scope -check-prefixes=CHECK,AMDGCN %s
|
2010-07-08 08:05:45 +08:00
|
|
|
|
[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: @foo = common {{(dso_local )?}}addrspace(1) global
|
2008-02-04 10:31:56 +08:00
|
|
|
int foo __attribute__((address_space(1)));
|
2010-07-08 08:05:45 +08:00
|
|
|
|
[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: @ban = common {{(dso_local )?}}addrspace(1) global
|
2008-02-04 10:31:56 +08:00
|
|
|
int ban[10] __attribute__((address_space(1)));
|
|
|
|
|
[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: @a = common {{(dso_local )?}}global
|
2017-04-12 01:24:23 +08:00
|
|
|
int a __attribute__((address_space(0)));
|
|
|
|
|
[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 )?}}i32 @test1()
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: load i32, i32 addrspace(1)* @foo
|
2010-07-08 08:05:45 +08:00
|
|
|
int test1() { return foo; }
|
2008-02-04 10:31:56 +08:00
|
|
|
|
[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 )?}}i32 @test2(i32 %i)
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: load i32, i32 addrspace(1)*
|
2010-07-08 08:05:45 +08:00
|
|
|
// CHECK-NEXT: ret i32
|
|
|
|
int test2(int i) { return ban[i]; }
|
2008-06-26 14:27:57 +08:00
|
|
|
|
|
|
|
// Both A and B point into addrspace(2).
|
|
|
|
__attribute__((address_space(2))) int *A, *B;
|
|
|
|
|
[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 @test3()
|
2017-07-08 21:24:52 +08:00
|
|
|
// X86: load i32 addrspace(2)*, i32 addrspace(2)** @B
|
2018-02-16 03:12:41 +08:00
|
|
|
// AMDGCN: load i32 addrspace(2)*, i32 addrspace(2)** addrspacecast (i32 addrspace(2)* addrspace(1)* @B to i32 addrspace(2)**)
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: load i32, i32 addrspace(2)*
|
2017-07-08 21:24:52 +08:00
|
|
|
// X86: load i32 addrspace(2)*, i32 addrspace(2)** @A
|
2018-02-16 03:12:41 +08:00
|
|
|
// AMDGCN: load i32 addrspace(2)*, i32 addrspace(2)** addrspacecast (i32 addrspace(2)* addrspace(1)* @A to i32 addrspace(2)**)
|
2010-07-08 08:05:45 +08:00
|
|
|
// CHECK: store i32 {{.*}}, i32 addrspace(2)*
|
2008-06-26 14:27:57 +08:00
|
|
|
void test3() {
|
|
|
|
*A = *B;
|
|
|
|
}
|
|
|
|
|
2010-07-08 08:07:45 +08:00
|
|
|
// PR7437
|
|
|
|
typedef struct {
|
|
|
|
float aData[1];
|
|
|
|
} MyStruct;
|
|
|
|
|
[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 @test4(
|
2018-02-16 03:12:41 +08:00
|
|
|
// CHECK: call void @llvm.memcpy.p0i8.p2i8
|
|
|
|
// CHECK: call void @llvm.memcpy.p2i8.p0i8
|
2010-07-08 08:07:45 +08:00
|
|
|
void test4(MyStruct __attribute__((address_space(2))) *pPtr) {
|
|
|
|
MyStruct s = pPtr[0];
|
|
|
|
pPtr[0] = s;
|
|
|
|
}
|
2019-10-31 23:41:37 +08:00
|
|
|
|
|
|
|
// Make sure the right address space is used when doing arithmetic on a void
|
|
|
|
// pointer. Make sure no invalid bitcast is introduced.
|
|
|
|
|
|
|
|
// CHECK-LABEL: @void_ptr_arithmetic_test(
|
|
|
|
// X86: [[ALLOCA:%.*]] = alloca i8 addrspace(1)*
|
|
|
|
// X86-NEXT: store i8 addrspace(1)* %arg, i8 addrspace(1)** [[ALLOCA]]
|
|
|
|
// X86-NEXT: load i8 addrspace(1)*, i8 addrspace(1)** [[ALLOCA]]
|
|
|
|
// X86-NEXT: getelementptr i8, i8 addrspace(1)*
|
|
|
|
// X86-NEXT: ret i8 addrspace(1)*
|
|
|
|
void __attribute__((address_space(1)))*
|
|
|
|
void_ptr_arithmetic_test(void __attribute__((address_space(1))) *arg) {
|
|
|
|
return arg + 4;
|
|
|
|
}
|