|
| 1 | +; RUN: sycl-post-link --device-globals --ir-output-only -S %s -o %t.ll |
| 2 | +; RUN: FileCheck %s -input-file=%t.ll |
| 3 | +; |
| 4 | +; TODO: Remove --device-globals once other features start using compile-time |
| 5 | +; properties. |
| 6 | +; |
| 7 | +; Tests the translation of "sycl-properties" pointer annotations to pointer |
| 8 | +; annotations the SPIR-V translator will produce decorations from. |
| 9 | +; NOTE: These use SYCL property meta-names that are currently only intended for |
| 10 | +; use in attributes-to-metadata translations, but sycl-post-link does not |
| 11 | +; currently make the distinction so we will use them for the purpose of |
| 12 | +; testing the transformations. |
| 13 | + |
| 14 | +target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" |
| 15 | +target triple = "spir64-unknown-unknown" |
| 16 | + |
| 17 | +%struct.foo = type { i32 addrspace(4)*, i32 addrspace(4)*, i32 addrspace(4)*, i32 addrspace(4)*, i32 addrspace(4)*, i32 addrspace(4)*, i32 addrspace(4)* } |
| 18 | + |
| 19 | +$_ZTSZ4mainEUlvE_ = comdat any |
| 20 | + |
| 21 | +@.str = private unnamed_addr constant [16 x i8] c"sycl-properties\00", section "llvm.metadata" |
| 22 | +@.str.1 = private unnamed_addr constant [36 x i8] c"sycl-properties-ptr-annotations.cpp\00", section "llvm.metadata" |
| 23 | +@.str.2 = private unnamed_addr constant [15 x i8] c"sycl-init-mode\00", section "llvm.metadata" |
| 24 | +@.str.3 = private unnamed_addr constant [2 x i8] c"1\00", section "llvm.metadata" |
| 25 | +@.str.4 = private unnamed_addr constant [22 x i8] c"sycl-implement-in-csr\00", section "llvm.metadata" |
| 26 | +@.str.5 = private unnamed_addr constant [5 x i8] c"true\00", section "llvm.metadata" |
| 27 | +@.args = private unnamed_addr constant { [15 x i8]*, [2 x i8]*, [22 x i8]*, [5 x i8]* } { [15 x i8]* @.str.2, [2 x i8]*@.str.3, [22 x i8]* @.str.4, [5 x i8]* @.str.5 }, section "llvm.metadata" |
| 28 | +@.args.6 = private unnamed_addr constant { [15 x i8]*, [2 x i8]* } { [15 x i8]* @.str.2, [2 x i8]* @.str.3 }, section "llvm.metadata" |
| 29 | +@.args.7 = private unnamed_addr constant { [22 x i8]*, [5 x i8]* } { [22 x i8]* @.str.4, [5 x i8]* @.str.5 }, section "llvm.metadata" |
| 30 | +@.args.8 = private unnamed_addr constant { [15 x i8]*, [2 x i8]*, [22 x i8]*, [5 x i8]* } { [15 x i8]* @.str.2, [2 x i8]* @.str.3, [22 x i8]* @.str.4, [5 x i8]* @.str.5 }, section "llvm.metadata" |
| 31 | +@.str.9 = private unnamed_addr constant [18 x i8] c"sycl-unrecognized\00", section "llvm.metadata" |
| 32 | +@.args.10 = private unnamed_addr constant { [15 x i8]*, [2 x i8]*, [18 x i8]*, i8* } { [15 x i8]* @.str.2, [2 x i8]* @.str.3, [18 x i8]* @.str.9, i8* null }, section "llvm.metadata" |
| 33 | +@.args.11 = private unnamed_addr constant { [18 x i8]*, i8* } { [18 x i8]* @.str.9, i8* null }, section "llvm.metadata" |
| 34 | + |
| 35 | +;CHECK: @[[NewAnnotStr1:.*]] = private unnamed_addr constant [24 x i8] c"{6148:\221\22}{6149:\22true\22}\00", section "llvm.metadata" |
| 36 | +;CHECK: @[[NewAnnotStr2:.*]] = private unnamed_addr constant [11 x i8] c"{6148:\221\22}\00", section "llvm.metadata" |
| 37 | +;CHECK: @[[NewAnnotStr3:.*]] = private unnamed_addr constant [14 x i8] c"{6149:\22true\22}\00", section "llvm.metadata" |
| 38 | + |
| 39 | +; Function Attrs: mustprogress norecurse |
| 40 | +define weak_odr dso_local spir_kernel void @_ZTSZ4mainEUlvE_() local_unnamed_addr #0 comdat !kernel_arg_buffer_location !7 !sycl_kernel_omit_args !7 { |
| 41 | +entry: |
| 42 | + %x.i = alloca %struct.foo, align 8 |
| 43 | + %x.ascast.i = addrspacecast %struct.foo* %x.i to %struct.foo addrspace(4)* |
| 44 | + %0 = bitcast %struct.foo* %x.i to i8* |
| 45 | + %1 = addrspacecast i8* %0 to i8 addrspace(4)* |
| 46 | + %2 = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %1, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 5, i8* bitcast ({ [15 x i8]*, [2 x i8]*, [22 x i8]*, [5 x i8]* }* @.args to i8*)) #2 |
| 47 | +; CHECK: %{{.*}} = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @[[NewAnnotStr1]], i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 5, i8* null) |
| 48 | + %b.i = getelementptr inbounds %struct.foo, %struct.foo addrspace(4)* %x.ascast.i, i64 0, i32 1 |
| 49 | + %3 = bitcast i32 addrspace(4)* addrspace(4)* %b.i to i8 addrspace(4)* |
| 50 | + %4 = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %3, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 6, i8* bitcast ({ [15 x i8]*, [2 x i8]* }* @.args.6 to i8*)) #2 |
| 51 | +; CHECK: %{{.*}} = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @[[NewAnnotStr2]], i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 6, i8* null) |
| 52 | + %c.i = getelementptr inbounds %struct.foo, %struct.foo addrspace(4)* %x.ascast.i, i64 0, i32 2 |
| 53 | + %5 = bitcast i32 addrspace(4)* addrspace(4)* %c.i to i8 addrspace(4)* |
| 54 | + %6 = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %5, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 7, i8* bitcast ({ [22 x i8]*, [5 x i8]* }* @.args.7 to i8*)) #2 |
| 55 | +; CHECK: %{{.*}} = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %5, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @[[NewAnnotStr3]], i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 7, i8* null) |
| 56 | + %d.i = getelementptr inbounds %struct.foo, %struct.foo addrspace(4)* %x.ascast.i, i64 0, i32 3 |
| 57 | + %7 = bitcast i32 addrspace(4)* addrspace(4)* %d.i to i8 addrspace(4)* |
| 58 | + %8 = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 8, i8* bitcast ({ [15 x i8]*, [2 x i8]*, [22 x i8]*, [5 x i8]* }* @.args.8 to i8*)) #2 |
| 59 | +; CHECK: %{{.*}} = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @[[NewAnnotStr1]], i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 8, i8* null) |
| 60 | + %e.i = getelementptr inbounds %struct.foo, %struct.foo addrspace(4)* %x.ascast.i, i64 0, i32 4 |
| 61 | + %9 = bitcast i32 addrspace(4)* addrspace(4)* %e.i to i8 addrspace(4)* |
| 62 | + %10 = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 9, i8* bitcast ({ [15 x i8]*, [2 x i8]*, [18 x i8]*, i8* }* @.args.10 to i8*)) #2 |
| 63 | +; CHECK: %{{.*}} = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %9, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @[[NewAnnotStr2]], i32 0, i32 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 9, i8* null) |
| 64 | + %f.i = getelementptr inbounds %struct.foo, %struct.foo addrspace(4)* %x.ascast.i, i64 0, i32 5 |
| 65 | + %11 = bitcast i32 addrspace(4)* addrspace(4)* %f.i to i8 addrspace(4)* |
| 66 | + %12 = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 10, i8* bitcast ({ [18 x i8]*, i8* }* @.args.11 to i8*)) #2 |
| 67 | +; CHECK-NOT: %{{.*}} = call i8 addrspace(4)* @llvm.ptr.annotation. |
| 68 | + %g.i = getelementptr inbounds %struct.foo, %struct.foo addrspace(4)* %x.ascast.i, i64 0, i32 6 |
| 69 | + %13 = bitcast i32 addrspace(4)* addrspace(4)* %g.i to i8 addrspace(4)* |
| 70 | + %14 = call i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)* %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 11, i8* null) #2 |
| 71 | + ret void |
| 72 | +} |
| 73 | + |
| 74 | +; Function Attrs: inaccessiblememonly nofree nosync nounwind willreturn |
| 75 | +declare i8 addrspace(4)* @llvm.ptr.annotation.p4i8(i8 addrspace(4)*, i8*, i8*, i32, i8*) #1 |
| 76 | + |
| 77 | +attributes #0 = { mustprogress norecurse "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="sycl-properties-ptr-annotations.cpp" "uniform-work-group-size"="true" } |
| 78 | +attributes #1 = { inaccessiblememonly nofree nosync nounwind willreturn } |
| 79 | +attributes #2 = { nounwind } |
| 80 | + |
| 81 | +!opencl.spir.version = !{!0, !0, !0, !0, !0, !0} |
| 82 | +!spirv.Source = !{!1, !1, !1, !1, !1, !1} |
| 83 | +!llvm.ident = !{!2, !3, !3, !3, !4, !3} |
| 84 | +!llvm.module.flags = !{!5, !6} |
| 85 | + |
| 86 | +!0 = !{i32 1, i32 2} |
| 87 | +!1 = !{i32 4, i32 100000} |
| 88 | +!2 = !{!"clang version 15.0.0"} |
| 89 | +!3 = !{!"clang version 15.0.0"} |
| 90 | +!4 = !{!"clang version 15.0.0"} |
| 91 | +!5 = !{i32 1, !"wchar_size", i32 4} |
| 92 | +!6 = !{i32 7, !"frame-pointer", i32 2} |
| 93 | +!7 = !{} |
0 commit comments