2012-05-10 05:21:49 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck %s
|
2010-07-08 08:05:45 +08:00
|
|
|
|
|
|
|
// CHECK: @foo = common 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
|
|
|
|
|
|
|
// CHECK: @ban = common addrspace(1) global
|
2008-02-04 10:31:56 +08:00
|
|
|
int ban[10] __attribute__((address_space(1)));
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i32 @test1()
|
2010-07-08 08:05:45 +08:00
|
|
|
// CHECK: load i32 addrspace(1)* @foo
|
|
|
|
int test1() { return foo; }
|
2008-02-04 10:31:56 +08:00
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i32 @test2(i32 %i)
|
2010-07-08 08:05:45 +08:00
|
|
|
// CHECK: load i32 addrspace(1)*
|
|
|
|
// 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;
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test3()
|
2010-07-08 08:05:45 +08:00
|
|
|
// CHECK: load i32 addrspace(2)** @B
|
2015-02-15 12:12:22 +08:00
|
|
|
// CHECK: load i32 addrspace(2)*
|
2010-07-08 08:05:45 +08:00
|
|
|
// CHECK: load i32 addrspace(2)** @A
|
|
|
|
// 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;
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test4(
|
2010-07-08 08:23:21 +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;
|
|
|
|
}
|