| 1 |
; REQUIRES: object-emission |
| 2 |
|
| 3 |
; RUN: llvm-as < %s -o %t.bc |
| 4 |
; RUN: llvm-spirv %t.bc -o %t.spv |
| 5 |
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll |
| 6 |
|
| 7 |
; RUN: llc -mtriple=%triple -O0 -filetype=obj < %t.ll | llvm-dwarfdump -v -debug-info - | FileCheck %s |
| 8 |
|
| 9 |
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" |
| 10 |
target triple = "spir64-unknown-unknown" |
| 11 |
|
| 12 |
; Build from the following source with clang -O2. |
| 13 |
|
| 14 |
; The important details are that 'x's abstract definition is first built during |
| 15 |
; the definition of 'b', where the parameter to 'x' is constant and so 'x's 's' |
| 16 |
; variable is optimized away. No abstract definition DIE for 's' is constructed. |
| 17 |
; Then, during 'a' emission, the abstract DbgVariable for 's' is created, but |
| 18 |
; the abstract DIE isn't (since the abstract definition for 'b' is already |
| 19 |
; built). This results in 's' inlined in 'a' being emitted with its name, line, |
| 20 |
; file there, rather than referencing an abstract definition. |
| 21 |
|
| 22 |
; extern int t; |
| 23 |
; |
| 24 |
; void f(int); |
| 25 |
; |
| 26 |
; inline void x(bool b) { |
| 27 |
; if (b) { |
| 28 |
; int s = t; |
| 29 |
; f(s); |
| 30 |
; } |
| 31 |
; f(0); |
| 32 |
; } |
| 33 |
; |
| 34 |
; void b() { |
| 35 |
; x(false); |
| 36 |
; } |
| 37 |
; |
| 38 |
; void a(bool u) { |
| 39 |
; x(u); |
| 40 |
; } |
| 41 |
|
| 42 |
; CHECK: [[X_DECL:.*]]: DW_TAG_subprogram |
| 43 |
; CHECK-NOT: DW_TAG |
| 44 |
; CHECK: DW_AT_name {{.*}} "x" |
| 45 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 46 |
; CHECK: DW_TAG_formal_parameter |
| 47 |
; CHECK-NOT: DW_TAG |
| 48 |
; CHECK: DW_AT_name {{.*}} "b" |
| 49 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 50 |
; CHECK: DW_TAG_lexical_block |
| 51 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 52 |
; CHECK: DW_TAG_variable |
| 53 |
; CHECK-NOT: DW_TAG |
| 54 |
; CHECK: DW_AT_name {{.*}} "s" |
| 55 |
|
| 56 |
; CHECK: DW_TAG_subprogram |
| 57 |
; CHECK-NOT: DW_TAG |
| 58 |
; CHECK: DW_AT_name {{.*}} "b" |
| 59 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 60 |
; CHECK: DW_TAG_inlined_subroutine |
| 61 |
; CHECK-NOT: DW_TAG |
| 62 |
; CHECK: DW_AT_abstract_origin {{.*}} {[[X_DECL]]} |
| 63 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 64 |
; CHECK: DW_TAG_formal_parameter |
| 65 |
; CHECK-NOT: DW_TAG |
| 66 |
; CHECK: DW_AT_abstract_origin {{.*}} "b" |
| 67 |
; Notice 'x's local variable 's' is missing. Not necessarily a bug here, |
| 68 |
; since it's been optimized entirely away and it should be described in |
| 69 |
; abstract subprogram. |
| 70 |
; CHECK-NOT: DW_TAG |
| 71 |
; CHECK: NULL |
| 72 |
; CHECK-NOT: DW_TAG |
| 73 |
; CHECK: NULL |
| 74 |
|
| 75 |
; CHECK: DW_TAG_subprogram |
| 76 |
; CHECK-NOT: DW_TAG |
| 77 |
; CHECK: DW_AT_name {{.*}} "a" |
| 78 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 79 |
; CHECK: DW_TAG_formal_parameter |
| 80 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 81 |
; CHECK: DW_TAG_inlined_subroutine |
| 82 |
; CHECK-NOT: DW_TAG |
| 83 |
; CHECK: DW_AT_abstract_origin {{.*}} {[[X_DECL]]} |
| 84 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 85 |
; FIXME: This formal parameter goes missing at least at -O2 (& on |
| 86 |
; mips/powerpc), maybe before that. Perhaps SelectionDAG is to blame (and |
| 87 |
; fastisel succeeds). |
| 88 |
; CHECK: DW_TAG_formal_parameter |
| 89 |
; CHECK-NOT: DW_TAG |
| 90 |
; CHECK: DW_AT_abstract_origin {{.*}} "b" |
| 91 |
|
| 92 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 93 |
; CHECK: DW_TAG_lexical_block |
| 94 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 95 |
; CHECK: DW_TAG_variable |
| 96 |
; CHECK-NOT: DW_TAG |
| 97 |
; CHECK: DW_AT_abstract_origin {{.*}} "s" |
| 98 |
|
| 99 |
@t = external global i32 |
| 100 |
|
| 101 |
; Function Attrs: uwtable |
| 102 |
define void @_Z1bv() #0 !dbg !4 { |
| 103 |
entry: |
| 104 |
tail call void @llvm.dbg.value(metadata i1 false, metadata !25, metadata !DIExpression()), !dbg !27 |
| 105 |
tail call void @_Z1fi(i32 0), !dbg !28 |
| 106 |
ret void, !dbg !29 |
| 107 |
} |
| 108 |
|
| 109 |
; Function Attrs: uwtable |
| 110 |
define void @_Z1ab(i1 zeroext %u) #0 !dbg !8 { |
| 111 |
entry: |
| 112 |
tail call void @llvm.dbg.value(metadata i1 %u, metadata !13, metadata !DIExpression()), !dbg !30 |
| 113 |
tail call void @llvm.dbg.value(metadata i1 %u, metadata !31, metadata !DIExpression()), !dbg !33 |
| 114 |
br i1 %u, label %if.then.i, label %_Z1xb.exit, !dbg !34 |
| 115 |
|
| 116 |
if.then.i: ; preds = %entry |
| 117 |
%0 = load i32, i32* @t, align 4, !dbg !35, !tbaa !36 |
| 118 |
tail call void @llvm.dbg.value(metadata i32 %0, metadata !40, metadata !DIExpression()), !dbg !35 |
| 119 |
tail call void @_Z1fi(i32 %0), !dbg !41 |
| 120 |
br label %_Z1xb.exit, !dbg !42 |
| 121 |
|
| 122 |
_Z1xb.exit: ; preds = %entry, %if.then.i |
| 123 |
tail call void @_Z1fi(i32 0), !dbg !43 |
| 124 |
ret void, !dbg !44 |
| 125 |
} |
| 126 |
|
| 127 |
declare void @_Z1fi(i32) #1 |
| 128 |
|
| 129 |
; Function Attrs: nounwind readnone |
| 130 |
declare void @llvm.dbg.value(metadata, metadata, metadata) #2 |
| 131 |
|
| 132 |
attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 133 |
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 134 |
attributes #2 = { nounwind readnone } |
| 135 |
|
| 136 |
!llvm.dbg.cu = !{!0} |
| 137 |
!llvm.module.flags = !{!21, !22} |
| 138 |
!llvm.ident = !{!23} |
| 139 |
|
| 140 |
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) |
| 141 |
!1 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo") |
| 142 |
!2 = !{} |
| 143 |
!4 = distinct !DISubprogram(name: "b", linkageName: "_Z1bv", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 13, file: !1, scope: !5, type: !6, retainedNodes: !2) |
| 144 |
!5 = !DIFile(filename: "missing-abstract-variables.cc", directory: "/tmp/dbginfo") |
| 145 |
!6 = !DISubroutineType(types: !7) |
| 146 |
!7 = !{null} |
| 147 |
!8 = distinct !DISubprogram(name: "a", linkageName: "_Z1ab", line: 17, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 17, file: !1, scope: !5, type: !9, retainedNodes: !12) |
| 148 |
!9 = !DISubroutineType(types: !10) |
| 149 |
!10 = !{null, !11} |
| 150 |
!11 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean) |
| 151 |
!12 = !{!13} |
| 152 |
!13 = !DILocalVariable(name: "u", line: 17, arg: 1, scope: !8, file: !5, type: !11) |
| 153 |
!14 = distinct !DISubprogram(name: "x", linkageName: "_Z1xb", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !9, retainedNodes: !15) |
| 154 |
!15 = !{!16, !17} |
| 155 |
!16 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11) |
| 156 |
!17 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20) |
| 157 |
!18 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !19) |
| 158 |
!19 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !14) |
| 159 |
!20 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 160 |
!21 = !{i32 2, !"Dwarf Version", i32 4} |
| 161 |
!22 = !{i32 2, !"Debug Info Version", i32 3} |
| 162 |
!23 = !{!"clang version 3.5.0 "} |
| 163 |
!24 = !{i1 false} |
| 164 |
!25 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11) |
| 165 |
!26 = !DILocation(line: 14, scope: !4) |
| 166 |
!27 = !DILocation(line: 5, scope: !14, inlinedAt: !26) |
| 167 |
!28 = !DILocation(line: 10, scope: !14, inlinedAt: !26) |
| 168 |
!29 = !DILocation(line: 15, scope: !4) |
| 169 |
!30 = !DILocation(line: 17, scope: !8) |
| 170 |
!31 = !DILocalVariable(name: "b", line: 5, arg: 1, scope: !14, file: !5, type: !11) |
| 171 |
!32 = !DILocation(line: 18, scope: !8) |
| 172 |
!33 = !DILocation(line: 5, scope: !14, inlinedAt: !32) |
| 173 |
!34 = !DILocation(line: 6, scope: !19, inlinedAt: !32) |
| 174 |
!35 = !DILocation(line: 7, scope: !18, inlinedAt: !32) |
| 175 |
!36 = !{!37, !37, i64 0} |
| 176 |
!37 = !{!"int", !38, i64 0} |
| 177 |
!38 = !{!"omnipotent char", !39, i64 0} |
| 178 |
!39 = !{!"Simple C/C++ TBAA"} |
| 179 |
!40 = !DILocalVariable(name: "s", line: 7, scope: !18, file: !5, type: !20) |
| 180 |
!41 = !DILocation(line: 8, scope: !18, inlinedAt: !32) |
| 181 |
!42 = !DILocation(line: 9, scope: !18, inlinedAt: !32) |
| 182 |
!43 = !DILocation(line: 10, scope: !14, inlinedAt: !32) |
| 183 |
!44 = !DILocation(line: 19, scope: !8) |