1; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji < %s | FileCheck %s 2 3; Make sure we do not crash during scheduling when DBG_VALUE is the first 4; instruction in the basic block. 5 6; LLVM IR generated with the following command and OpenCL source: 7; 8; $clang -cl-std=CL2.0 -g -O2 -target amdgcn-amd-amdhsa -S -emit-llvm <path-to-file> 9; 10; kernel void kernel1(global int *A, global int *B) { 11; if (*A == 1) { 12; *B = 12; 13; } 14; if (*A == 2) { 15; *B = 13; 16; } 17; } 18 19declare void @llvm.dbg.value(metadata, metadata, metadata) 20 21; CHECK-LABEL: {{^}}kernel1: 22define amdgpu_kernel void @kernel1( 23 i32 addrspace(1)* nocapture readonly %A, 24 i32 addrspace(1)* nocapture %B) !dbg !7 { 25entry: 26 tail call void @llvm.dbg.value(metadata i32 addrspace(1)* %A, metadata !13, metadata !19), !dbg !20 27 tail call void @llvm.dbg.value(metadata i32 addrspace(1)* %B, metadata !14, metadata !19), !dbg !21 28 %0 = load i32, i32 addrspace(1)* %A, align 4, !dbg !22, !tbaa !24 29 %cmp = icmp eq i32 %0, 1, !dbg !28 30 br i1 %cmp, label %if.then, label %if.end, !dbg !29 31 32if.then: ; preds = %entry 33 store i32 12, i32 addrspace(1)* %B, align 4, !dbg !30, !tbaa !24 34 %.pr = load i32, i32 addrspace(1)* %A, align 4, !dbg !32, !tbaa !24 35 br label %if.end, !dbg !34 36 37if.end: ; preds = %if.then, %entry 38 %1 = phi i32 [ %.pr, %if.then ], [ %0, %entry ], !dbg !32 39 %cmp1 = icmp eq i32 %1, 2, !dbg !35 40 br i1 %cmp1, label %if.then2, label %if.end3, !dbg !36 41 42if.then2: ; preds = %if.end 43 store i32 13, i32 addrspace(1)* %B, align 4, !dbg !37, !tbaa !24 44 br label %if.end3, !dbg !39 45 46if.end3: ; preds = %if.then2, %if.end 47 ret void, !dbg !40 48} 49 50!llvm.dbg.cu = !{!0} 51!opencl.ocl.version = !{!3} 52!llvm.module.flags = !{!4, !5} 53!llvm.ident = !{!6} 54 55!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 56!1 = !DIFile(filename: "dbg-value-sched-crash.cl", directory: "/some/random/directory") 57!2 = !{} 58!3 = !{i32 2, i32 0} 59!4 = !{i32 2, !"Dwarf Version", i32 2} 60!5 = !{i32 2, !"Debug Info Version", i32 3} 61!6 = !{!"clang version 4.0 "} 62!7 = distinct !DISubprogram(name: "kernel1", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12) 63!8 = !DISubroutineType(types: !9) 64!9 = !{null, !10, !10} 65!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64) 66!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 67!12 = !{!13, !14} 68!13 = !DILocalVariable(name: "A", arg: 1, scope: !7, file: !1, line: 1, type: !10) 69!14 = !DILocalVariable(name: "B", arg: 2, scope: !7, file: !1, line: 1, type: !10) 70!15 = !{i32 1, i32 1} 71!16 = !{!"none", !"none"} 72!17 = !{!"int*", !"int*"} 73!18 = !{!"", !""} 74!19 = !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef) 75!20 = !DILocation(line: 1, column: 33, scope: !7) 76!21 = !DILocation(line: 1, column: 48, scope: !7) 77!22 = !DILocation(line: 2, column: 7, scope: !23) 78!23 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2, column: 7) 79!24 = !{!25, !25, i64 0} 80!25 = !{!"int", !26, i64 0} 81!26 = !{!"omnipotent char", !27, i64 0} 82!27 = !{!"Simple C/C++ TBAA"} 83!28 = !DILocation(line: 2, column: 10, scope: !23) 84!29 = !DILocation(line: 2, column: 7, scope: !7) 85!30 = !DILocation(line: 3, column: 8, scope: !31) 86!31 = distinct !DILexicalBlock(scope: !23, file: !1, line: 2, column: 16) 87!32 = !DILocation(line: 5, column: 7, scope: !33) 88!33 = distinct !DILexicalBlock(scope: !7, file: !1, line: 5, column: 7) 89!34 = !DILocation(line: 4, column: 3, scope: !31) 90!35 = !DILocation(line: 5, column: 10, scope: !33) 91!36 = !DILocation(line: 5, column: 7, scope: !7) 92!37 = !DILocation(line: 6, column: 8, scope: !38) 93!38 = distinct !DILexicalBlock(scope: !33, file: !1, line: 5, column: 16) 94!39 = !DILocation(line: 7, column: 3, scope: !38) 95!40 = !DILocation(line: 8, column: 1, scope: !7) 96