|
| 1 | +;; The test checks, that Fortran dynamic arrays are being correctly represented |
| 2 | +;; by SPIR-V debug information |
| 3 | +;; Unlike 'static' arrays dynamic can have following parameters of |
| 4 | +;; DICompositeType metadata with DW_TAG_array_type tag: |
| 5 | +;; Data Location, Associated, Allocated and Rank which can be represented |
| 6 | +;; by either DIExpression or DIVariable (both local and global). |
| 7 | +;; This test if for expression representation. |
| 8 | +;; FortranDynamicArrayVar.ll is for variable representation. |
| 9 | + |
| 10 | +; RUN: llvm-as %s -o %t.bc |
| 11 | +; RUN: llvm-spirv %t.bc -spirv-text --spirv-debug-info-version=nonsemantic-kernel-100 -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 12 | +; RUN: llvm-spirv %t.bc -o %t.spv --spirv-debug-info-version=nonsemantic-kernel-100 |
| 13 | +; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc |
| 14 | +; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM |
| 15 | + |
| 16 | +; CHECK-SPIRV-DAG: ExtInstImport [[#Import:]] "NonSemantic.Kernel.DebugInfo.100" |
| 17 | +; CHECK-SPIRV-DAG: String [[#BasicTName:]] "INTEGER*4" |
| 18 | +; CHECK-SPIRV-DAG: TypeInt [[#Int32T:]] 32 0 |
| 19 | +; CHECK-SPIRV-DAG: Constant [[#Int32T]] [[#IntConst:]] 32 |
| 20 | +; CHECK-SPIRV-DAG: TypeVoid [[#VoidT:]] |
| 21 | +; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgInfoNone:]] [[#Import]] DebugInfoNone |
| 22 | +; CHECK-SPIRV: ExtInst [[#VoidT]] [[#ArrayBasicT:]] [[#Import]] DebugTypeBasic [[#BasicTName]] [[#IntConst]] 4 |
| 23 | +; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprLocation:]] [[#Import]] DebugExpression [[#]] [[#]] {{$}} |
| 24 | +; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprAssociated:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] [[#]] {{$}} |
| 25 | +; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprLowerBound:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] {{$}} |
| 26 | +; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprUpperBound:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] [[#]] {{$}} |
| 27 | +; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgExprCount:]] [[#Import]] DebugExpression [[#]] [[#]] [[#]] {{$}} |
| 28 | +; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgSubRangeId:]] [[#Import]] DebugTypeSubrange [[#DbgInfoNone]] [[#DbgExprLowerBound]] [[#DbgExprUpperBound]] [[#DbgExprCount]] |
| 29 | +; CHECK-SPIRV: ExtInst [[#VoidT]] [[#DbgArrayId:]] [[#Import]] DebugTypeArrayDynamic [[#ArrayBasicT]] [[#DbgExprLocation]] [[#DbgExprAssociated]] [[#DbgInfoNone]] [[#DbgInfoNone]] [[#DbgSubRangeId]] |
| 30 | + |
| 31 | +; CHECK-LLVM: %[[#Array:]] = alloca |
| 32 | +; CHECK-LLVM: call void @llvm.dbg.value(metadata ptr %[[#Array]], metadata ![[#DbgLVar:]] |
| 33 | +; CHECK-LLVM: ![[#DbgLVar]] = !DILocalVariable(name: "pint", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#DbgLVarT:]]) |
| 34 | +; CHECK-LLVM: ![[#DbgLVarT]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[#DbgArrayT:]], size: 64) |
| 35 | +; CHECK-LLVM: ![[#DbgArrayT]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[#DbgArrayBaseT:]], size: 32, elements: ![[#Elements:]], dataLocation: !DIExpression(DW_OP_push_object_address, DW_OP_deref), associated: !DIExpression(DW_OP_push_object_address, DW_OP_deref, DW_OP_constu, 0, DW_OP_or)) |
| 36 | +; CHECK-LLVM: ![[#DbgArrayBaseT]] = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed) |
| 37 | +; CHECK-LLVM: ![[#Elements]] = !{![[#SubRange:]]} |
| 38 | +; CHECK-LLVM: ![[#SubRange]] = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref)) |
| 39 | + |
| 40 | + |
| 41 | +; ModuleID = 'reproducer.ll' |
| 42 | +source_filename = "test.f90" |
| 43 | +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" |
| 44 | +target triple = "spir64" |
| 45 | + |
| 46 | +%qnca = type { i32 addrspace(4)*, i64, i64, i64, i64, i64, [1 x { i64, i64, i64 }] } |
| 47 | + |
| 48 | +; Function Attrs: noinline nounwind optnone |
| 49 | +define weak dso_local spir_kernel void @TEST() #0 !dbg !5 { |
| 50 | +newFuncRoot: |
| 51 | + %0 = alloca %qnca, align 8 |
| 52 | + call void @llvm.dbg.value(metadata %qnca* %0, metadata !8, metadata !DIExpression()), !dbg !14 |
| 53 | + ret void |
| 54 | +} |
| 55 | + |
| 56 | +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn |
| 57 | +declare void @llvm.dbg.value(metadata, metadata, metadata) #1 |
| 58 | + |
| 59 | +attributes #0 = { noinline nounwind optnone } |
| 60 | +attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } |
| 61 | + |
| 62 | +!llvm.module.flags = !{!0, !1} |
| 63 | +!llvm.dbg.cu = !{!2} |
| 64 | +!spirv.Source = !{!4} |
| 65 | + |
| 66 | +!0 = !{i32 2, !"Debug Info Version", i32 3} |
| 67 | +!1 = !{i32 2, !"Dwarf Version", i32 4} |
| 68 | +!2 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3, producer: "fortran", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug) |
| 69 | +!3 = !DIFile(filename: "test.f90", directory: "/path/to") |
| 70 | +!4 = !{i32 4, i32 200000} |
| 71 | +!5 = distinct !DISubprogram(name: "test", linkageName: "MAIN__", scope: !3, file: !3, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !2) |
| 72 | +!6 = !DISubroutineType(types: !7) |
| 73 | +!7 = !{null} |
| 74 | +!8 = !DILocalVariable(name: "pint", scope: !5, file: !3, line: 3, type: !9) |
| 75 | +!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64) |
| 76 | +!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, elements: !12, dataLocation: !DIExpression(DW_OP_push_object_address, DW_OP_deref), associated: !DIExpression(DW_OP_push_object_address, DW_OP_deref, DW_OP_constu, 0, DW_OP_or)) |
| 77 | +!11 = !DIBasicType(name: "INTEGER*4", size: 32, encoding: DW_ATE_signed) |
| 78 | +!12 = !{!13} |
| 79 | +!13 = !DISubrange(lowerBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref), upperBound: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 64, DW_OP_deref, DW_OP_push_object_address, DW_OP_plus_uconst, 48, DW_OP_deref, DW_OP_plus, DW_OP_constu, 1, DW_OP_minus), stride: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 56, DW_OP_deref)) |
| 80 | +!14 = !DILocation(line: 1, scope: !5) |
| 81 | + |
0 commit comments