|
| 1 | +// RUN: %clang_cc1 -fsycl-is-device -triple spir64-unknown-unknown -emit-llvm -no-opaque-pointers -o - %s | FileCheck %s |
| 2 | + |
| 3 | +// This test checks that clang emits @llvm.ptr.annotation intrinsic correctly |
| 4 | +// when attribute annotate is applied to a struct field of integer type. |
| 5 | + |
| 6 | +// CHECK: private unnamed_addr addrspace(1) constant [8 x i8] c"v_ann_{{.}}\00", section "llvm.metadata" |
| 7 | +// CHECK: private unnamed_addr addrspace(1) constant [8 x i8] c"v_ann_{{.}}\00", section "llvm.metadata" |
| 8 | +// CHECK: private unnamed_addr addrspace(1) constant [8 x i8] c"w_ann_{{.}}\00", section "llvm.metadata" |
| 9 | +// CHECK: private unnamed_addr addrspace(1) constant [8 x i8] c"w_ann_{{.}}\00", section "llvm.metadata" |
| 10 | +// CHECK: private unnamed_addr addrspace(1) constant [8 x i8] c"f_ann_{{.}}\00", section "llvm.metadata" |
| 11 | +// CHECK: private unnamed_addr addrspace(1) constant [8 x i8] c"f_ann_{{.}}\00", section "llvm.metadata" |
| 12 | + |
| 13 | +struct foo { |
| 14 | + int v __attribute__((annotate("v_ann_0"))) __attribute__((annotate("v_ann_1"))); |
| 15 | + char w __attribute__((annotate("w_ann_0"))) __attribute__((annotate("w_ann_1"))); |
| 16 | + float f __attribute__((annotate("f_ann_0"))) __attribute__((annotate("f_ann_1"))); |
| 17 | +}; |
| 18 | + |
| 19 | +int __attribute__((sycl_device)) foo() { |
| 20 | + struct foo f; |
| 21 | + f.v = 1; |
| 22 | +// CHECK: getelementptr inbounds %struct.foo, %struct.foo addrspace(4)* %{{.*}}, i32 0, i32 0 |
| 23 | +// CHECK-NEXT: call i32 addrspace(4)* @llvm.ptr.annotation.p4i32.p1i8({{.*}}str{{.*}}str{{.*}}i32 14, i8 addrspace(1)* null) |
| 24 | +// CHECK-NEXT: call i32 addrspace(4)* @llvm.ptr.annotation.p4i32.p1i8({{.*}}str{{.*}}str{{.*}}i32 14, i8 addrspace(1)* null) |
| 25 | + f.w = 42; |
| 26 | +// CHECK: getelementptr inbounds %struct.foo, %struct.foo addrspace(4)* %{{.*}}, i32 0, i32 1 |
| 27 | +// CHECK-NEXT: call i8 addrspace(4)* @llvm.ptr.annotation.p4i8.p1i8({{.*}}str{{.*}}str{{.*}}i32 15, i8 addrspace(1)* null) |
| 28 | +// CHECK-NEXT: call i8 addrspace(4)* @llvm.ptr.annotation.p4i8.p1i8({{.*}}str{{.*}}str{{.*}}i32 15, i8 addrspace(1)* null) |
| 29 | + f.f = 0; |
| 30 | +// CHECK: getelementptr inbounds %struct.foo, %struct.foo addrspace(4)* %{{.*}}, i32 0, i32 2 |
| 31 | +// CHECK-NEXT: bitcast float addrspace(4)* %{{.*}} to i8 addrspace(4)* |
| 32 | +// CHECK-NEXT: call i8 addrspace(4)* @llvm.ptr.annotation.p4i8.p1i8({{.*}}str{{.*}}str{{.*}}i32 16, i8 addrspace(1)* null) |
| 33 | +// CHECK-NEXT: bitcast i8 addrspace(4)* %{{.*}} to float addrspace(4)* |
| 34 | +// CHECK-NEXT: bitcast float addrspace(4)* %{{.*}} to i8 addrspace(4)* |
| 35 | +// CHECK-NEXT: call i8 addrspace(4)* @llvm.ptr.annotation.p4i8.p1i8({{.*}}str{{.*}}str{{.*}}i32 16, i8 addrspace(1)* null) |
| 36 | + return 0; |
| 37 | +} |
0 commit comments