File: default-address-space.c

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (42 lines) | stat: -rw-r--r-- 1,339 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// RUN: %clang_cc1 -triple amdgcn---amdgiz -emit-llvm < %s | FileCheck -check-prefixes=CHECK %s

// CHECK-DAG: @foo ={{.*}} addrspace(1) global i32 0
int foo;

// CHECK-DAG: @ban ={{.*}} addrspace(1) global [10 x i32] zeroinitializer
int ban[10];

// CHECK-DAG: @A ={{.*}} addrspace(1) global ptr null
// CHECK-DAG: @B ={{.*}} addrspace(1) global ptr null
int *A;
int *B;

// CHECK-LABEL: define{{.*}} i32 @test1()
// CHECK: load i32, ptr addrspacecast{{[^@]+}} @foo
int test1(void) { return foo; }

// CHECK-LABEL: define{{.*}} i32 @test2(i32 noundef %i)
// CHECK: %[[addr:.*]] = getelementptr
// CHECK: load i32, ptr %[[addr]]
// CHECK-NEXT: ret i32
int test2(int i) { return ban[i]; }

// CHECK-LABEL: define{{.*}} void @test3()
// CHECK: load ptr, ptr addrspacecast{{.*}} @B
// CHECK: load i32, ptr
// CHECK: load ptr, ptr addrspacecast{{.*}} @A
// CHECK: store i32 {{.*}}, ptr
void test3(void) {
  *A = *B;
}

// CHECK-LABEL: define{{.*}} void @test4(ptr noundef %a)
// CHECK: %[[alloca:.*]] = alloca ptr, align 8, addrspace(5)
// CHECK: %[[a_addr:.*]] ={{.*}} addrspacecast{{.*}} %[[alloca]] to ptr
// CHECK: store ptr %a, ptr %[[a_addr]]
// CHECK: %[[r0:.*]] = load ptr, ptr %[[a_addr]]
// CHECK: %[[arrayidx:.*]] = getelementptr inbounds i32, ptr %[[r0]]
// CHECK: store i32 0, ptr %[[arrayidx]]
void test4(int *a) {
  a[0] = 0;
}