Home | History | Annotate | Download | only in CodeGen
      1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck %s
      2 
      3 // CHECK: @foo = common addrspace(1) global
      4 int foo __attribute__((address_space(1)));
      5 
      6 // CHECK: @ban = common addrspace(1) global
      7 int ban[10] __attribute__((address_space(1)));
      8 
      9 // CHECK-LABEL: define i32 @test1()
     10 // CHECK: load i32, i32 addrspace(1)* @foo
     11 int test1() { return foo; }
     12 
     13 // CHECK-LABEL: define i32 @test2(i32 %i)
     14 // CHECK: load i32, i32 addrspace(1)*
     15 // CHECK-NEXT: ret i32
     16 int test2(int i) { return ban[i]; }
     17 
     18 // Both A and B point into addrspace(2).
     19 __attribute__((address_space(2))) int *A, *B;
     20 
     21 // CHECK-LABEL: define void @test3()
     22 // CHECK: load i32 addrspace(2)*, i32 addrspace(2)** @B
     23 // CHECK: load i32, i32 addrspace(2)*
     24 // CHECK: load i32 addrspace(2)*, i32 addrspace(2)** @A
     25 // CHECK: store i32 {{.*}}, i32 addrspace(2)*
     26 void test3() {
     27   *A = *B;
     28 }
     29 
     30 // PR7437
     31 typedef struct {
     32   float aData[1];
     33 } MyStruct;
     34 
     35 // CHECK-LABEL: define void @test4(
     36 // CHECK: call void @llvm.memcpy.p0i8.p2i8
     37 // CHECK: call void @llvm.memcpy.p2i8.p0i8
     38 void test4(MyStruct __attribute__((address_space(2))) *pPtr) {
     39   MyStruct s = pPtr[0];
     40   pPtr[0] = s;
     41 }
     42