| 1 |
; RUN: llvm-as %s -o %t.bc |
| 2 |
; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 3 |
|
| 4 |
; RUN: llvm-spirv %t.bc -o %t.spv |
| 5 |
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc |
| 6 |
; RUN: llvm-dis -opaque-pointers=0 < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM |
| 7 |
|
| 8 |
; Check that even when FPGA memory extensions are enabled - yet we have |
| 9 |
; UserSemantic decoration be generated |
| 10 |
; RUN: llvm-as %s -o %t.bc |
| 11 |
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_fpga_memory_accesses,+SPV_INTEL_fpga_memory_attributes -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 12 |
|
| 13 |
; CHECK-SPIRV-DAG: Name [[#ClassMember:]] "class.Sample" |
| 14 |
; CHECK-SPIRV-DAG: Decorate [[#Var:]] UserSemantic "var_annotation_a" |
| 15 |
; CHECK-SPIRV-DAG: Decorate [[#Var]] UserSemantic "var_annotation_b2" |
| 16 |
; CHECK-SPIRV-DAG: MemberDecorate [[#ClassMember]] 0 UserSemantic "class_annotation_a" |
| 17 |
; CHECK-SPIRV-DAG: MemberDecorate [[#ClassMember]] 0 UserSemantic "class_annotation_b2" |
| 18 |
; CHECK-SPIRV: Variable [[#]] [[#Var]] [[#]] |
| 19 |
|
| 20 |
; CHECK-LLVM: @[[StrStructA:[0-9_.]+]] = {{.*}}"class_annotation_a\00" |
| 21 |
; CHECK-LLVM: @[[StrStructB:[0-9_.]+]] = {{.*}}"class_annotation_b2\00" |
| 22 |
; CHECK-LLVM: @[[StrA:[0-9_.]+]] = {{.*}}"var_annotation_a\00" |
| 23 |
; CHECK-LLVM: @[[StrB:[0-9_.]+]] = {{.*}}"var_annotation_b2\00" |
| 24 |
; CHECK-LLVM: %[[#StructMember:]] = alloca %class.Sample, align 4 |
| 25 |
; CHECK-LLVM: %[[#GEP1:]] = getelementptr inbounds %class.Sample, %class.Sample* %[[#StructMember]], i32 0, i32 0 |
| 26 |
; CHECK-LLVM: %[[#PtrAnn1:]] = call i32* @llvm.ptr.annotation.p0i32.p0i8(i32* %[[#GEP1:]], i8* getelementptr inbounds ([19 x i8], [19 x i8]* @[[StrStructA]], i32 0, i32 0), i8* undef, i32 undef, i8* undef) |
| 27 |
; CHECK-LLVM: %[[#PtrAnn2:]] = call i32* @llvm.ptr.annotation.p0i32.p0i8(i32* %[[#PtrAnn1]], i8* getelementptr inbounds ([20 x i8], [20 x i8]* @[[StrStructB]], i32 0, i32 0), i8* undef, i32 undef, i8* undef) |
| 28 |
; CHECK-LLVM: [[#Var:]] = alloca i32, align 4 |
| 29 |
; CHECK-LLVM: [[#Bitcast1:]] = bitcast i32* %[[#Var]] to i8* |
| 30 |
; CHECK-LLVM: call void @llvm.var.annotation.p0i8.p0i8(i8* %[[#Bitcast1]], i8* getelementptr inbounds ([17 x i8], [17 x i8]* @[[StrA]], i32 0, i32 0), i8* undef, i32 undef, i8* undef) |
| 31 |
; CHECK-LLVM: [[#Bitcast2:]] = bitcast i32* %[[#Var]] to i8* |
| 32 |
; CHECK-LLVM: call void @llvm.var.annotation.p0i8.p0i8(i8* %[[#Bitcast2]], i8* getelementptr inbounds ([18 x i8], [18 x i8]* @[[StrB]], i32 0, i32 0), i8* undef, i32 undef, i8* undef) |
| 33 |
; CHECK-LLVM: [[#Bitcast3:]] = bitcast i32* %[[#PtrAnn2]] to i8* |
| 34 |
; CHECK-LLVM: [[#Bitcast4:]] = bitcast i8* %[[#Bitcast3]] to i32* |
| 35 |
; CHECK-LLVM: [[#Load1:]] = load i32, i32* %[[#Bitcast4]], align 4 |
| 36 |
; CHECK-LLVM: call spir_func void @_Z3fooi(i32 %[[#Load1]]) |
| 37 |
; CHECK-LLVM: [[#Load2:]] = load i32, i32* %[[#Var]], align 4 |
| 38 |
; CHECK-LLVM: call spir_func void @_Z3fooi(i32 %[[#Load2]]) |
| 39 |
|
| 40 |
|
| 41 |
source_filename = "llvm-link" |
| 42 |
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" |
| 43 |
target triple = "spir64" |
| 44 |
|
| 45 |
%class.Sample = type { i32 } |
| 46 |
|
| 47 |
@.str = private unnamed_addr constant [19 x i8] c"class_annotation_a\00", section "llvm.metadata" |
| 48 |
@.str.1 = private unnamed_addr constant [17 x i8] c"/app/example.cpp\00", section "llvm.metadata" |
| 49 |
@.str.2 = private unnamed_addr constant [20 x i8] c"class_annotation_b2\00", section "llvm.metadata" |
| 50 |
@.str.3 = private unnamed_addr constant [17 x i8] c"var_annotation_a\00", section "llvm.metadata" |
| 51 |
@.str.4 = private unnamed_addr constant [18 x i8] c"var_annotation_b2\00", section "llvm.metadata" |
| 52 |
|
| 53 |
define spir_func void @test() { |
| 54 |
%1 = alloca %class.Sample, align 4 |
| 55 |
%2 = alloca i32, align 4 |
| 56 |
%3 = getelementptr inbounds %class.Sample, ptr %1, i32 0, i32 0 |
| 57 |
%4 = call ptr @llvm.ptr.annotation.p0(ptr %3, ptr @.str, ptr @.str.1, i32 3, ptr null) |
| 58 |
%5 = call ptr @llvm.ptr.annotation.p0(ptr %4, ptr @.str.2, ptr @.str.1, i32 3, ptr null) |
| 59 |
%6 = load i32, ptr %5, align 4 |
| 60 |
call void @_Z3fooi(i32 noundef %6) |
| 61 |
call void @llvm.var.annotation.p0.p0(ptr %2, ptr @.str.3, ptr @.str.1, i32 11, ptr null) |
| 62 |
call void @llvm.var.annotation.p0.p0(ptr %2, ptr @.str.4, ptr @.str.1, i32 11, ptr null) |
| 63 |
store i32 0, ptr %2, align 4 |
| 64 |
%7 = load i32, ptr %2, align 4 |
| 65 |
call void @_Z3fooi(i32 noundef %7) |
| 66 |
ret void |
| 67 |
} |
| 68 |
|
| 69 |
declare dso_local void @_Z3fooi(i32 noundef) |
| 70 |
|
| 71 |
declare ptr @llvm.ptr.annotation.p0(ptr, ptr, ptr, i32, ptr) |
| 72 |
|
| 73 |
declare void @llvm.var.annotation.p0.p0(ptr, ptr, ptr, i32, ptr) |