Chris Lattner | 30432fe | 2010-07-08 00:05:45 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s |
Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @A' |
| 3 | // RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @B' |
Chris Lattner | fca0ddd | 2008-06-26 06:27:57 +0000 | [diff] [blame] | 4 | |
Chris Lattner | 30432fe | 2010-07-08 00:05:45 +0000 | [diff] [blame^] | 5 | |
| 6 | // CHECK: @foo = common addrspace(1) global |
Christopher Lamb | ebb97e9 | 2008-02-04 02:31:56 +0000 | [diff] [blame] | 7 | int foo __attribute__((address_space(1))); |
Chris Lattner | 30432fe | 2010-07-08 00:05:45 +0000 | [diff] [blame^] | 8 | |
| 9 | // CHECK: @ban = common addrspace(1) global |
Christopher Lamb | ebb97e9 | 2008-02-04 02:31:56 +0000 | [diff] [blame] | 10 | int ban[10] __attribute__((address_space(1))); |
| 11 | |
Chris Lattner | 30432fe | 2010-07-08 00:05:45 +0000 | [diff] [blame^] | 12 | // CHECK: define i32 @test1() |
| 13 | // CHECK: load i32 addrspace(1)* @foo |
| 14 | int test1() { return foo; } |
Christopher Lamb | ebb97e9 | 2008-02-04 02:31:56 +0000 | [diff] [blame] | 15 | |
Chris Lattner | 30432fe | 2010-07-08 00:05:45 +0000 | [diff] [blame^] | 16 | // CHECK: define i32 @test2(i32 %i) |
| 17 | // CHECK: load i32 addrspace(1)* |
| 18 | // CHECK-NEXT: ret i32 |
| 19 | int test2(int i) { return ban[i]; } |
Chris Lattner | fca0ddd | 2008-06-26 06:27:57 +0000 | [diff] [blame] | 20 | |
| 21 | // Both A and B point into addrspace(2). |
| 22 | __attribute__((address_space(2))) int *A, *B; |
| 23 | |
Chris Lattner | 30432fe | 2010-07-08 00:05:45 +0000 | [diff] [blame^] | 24 | // CHECK: define void @test3() |
| 25 | // CHECK: load i32 addrspace(2)** @B |
| 26 | // CHECK: load i32 addrspace(2)* |
| 27 | // CHECK: load i32 addrspace(2)** @A |
| 28 | // CHECK: store i32 {{.*}}, i32 addrspace(2)* |
Chris Lattner | fca0ddd | 2008-06-26 06:27:57 +0000 | [diff] [blame] | 29 | void test3() { |
| 30 | *A = *B; |
| 31 | } |
| 32 | |