| 1 |
; RUN: llvm-as < %s -o %t.bc |
| 2 |
; RUN: llvm-spirv %t.bc -o %t.spv |
| 3 |
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll |
| 4 |
|
| 5 |
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %t.ll | llvm-dwarfdump -v -debug-info - | FileCheck %s |
| 6 |
|
| 7 |
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" |
| 8 |
target triple = "spir64-unknown-unknown" |
| 9 |
|
| 10 |
;; This test checks that Inlined DILexicalBlockFile with local decl entry |
| 11 |
;; is skipped and only one DW_TAG_lexical_block is generated. |
| 12 |
;; This test is special because it contains DILexicalBlockFile that has a |
| 13 |
;; DILexicalBlockFile as a parent scope. |
| 14 |
;; |
| 15 |
;; This test was generated by running following command: |
| 16 |
;; clang -cc1 -O0 -debug-info-kind=limited -dwarf-version=4 -emit-llvm test.cpp |
| 17 |
;; Where test.cpp |
| 18 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 19 |
;;namespace N {} |
| 20 |
;; __attribute__((always_inline)) int bar() { |
| 21 |
;; { |
| 22 |
;; int y; |
| 23 |
;;#line 1 "test.h" |
| 24 |
;; using namespace N; |
| 25 |
;; while (y < 0) return 2; |
| 26 |
;; return 0; |
| 27 |
;; } |
| 28 |
;;} |
| 29 |
;;int foo() { |
| 30 |
;; return bar(); |
| 31 |
;;} |
| 32 |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 33 |
|
| 34 |
;; Concrete "bar" function |
| 35 |
; CHECK: DW_TAG_subprogram |
| 36 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 37 |
; CHECK: DW_AT_abstract_origin {{.*}} {[[Offset_bar:0x[0-9abcdef]+]]} |
| 38 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 39 |
; CHECK: DW_TAG_lexical_block |
| 40 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 41 |
; CHECK: DW_TAG_variable |
| 42 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 43 |
; CHECK: DW_TAG_imported_module |
| 44 |
|
| 45 |
;; Abstract "bar" function |
| 46 |
; CHECK: [[Offset_bar]]: DW_TAG_subprogram |
| 47 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 48 |
; CHECK: DW_AT_name {{.*}} "bar" |
| 49 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 50 |
; CHECK: DW_AT_inline |
| 51 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 52 |
; CHECK: DW_TAG_lexical_block |
| 53 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 54 |
; CHECK: DW_TAG_variable |
| 55 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 56 |
; CHECK: DW_TAG_imported_module |
| 57 |
|
| 58 |
; CHECK: DW_TAG_subprogram |
| 59 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 60 |
; CHECK: DW_AT_name {{.*}} "foo" |
| 61 |
; CHECK-NOT: {{NULL}} |
| 62 |
|
| 63 |
;; Inlined "bar" function |
| 64 |
; CHECK: DW_TAG_inlined_subroutine |
| 65 |
; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]} |
| 66 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 67 |
; CHECK: DW_TAG_lexical_block |
| 68 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 69 |
; CHECK: DW_TAG_variable |
| 70 |
; CHECK-NOT: {{DW_TAG|NULL}} |
| 71 |
; CHECK: DW_TAG_imported_module |
| 72 |
|
| 73 |
|
| 74 |
; Function Attrs: alwaysinline nounwind |
| 75 |
define i32 @_Z3barv() #0 !dbg !4 { |
| 76 |
entry: |
| 77 |
%retval = alloca i32, align 4 |
| 78 |
%y = alloca i32, align 4 |
| 79 |
call void @llvm.dbg.declare(metadata i32* %y, metadata !18, metadata !19), !dbg !20 |
| 80 |
br label %while.cond, !dbg !21 |
| 81 |
|
| 82 |
while.cond: ; preds = %entry |
| 83 |
%0 = load i32, i32* %y, align 4, !dbg !22 |
| 84 |
%cmp = icmp slt i32 %0, 0, !dbg !22 |
| 85 |
br i1 %cmp, label %while.body, label %while.end, !dbg !22 |
| 86 |
|
| 87 |
while.body: ; preds = %while.cond |
| 88 |
store i32 2, i32* %retval, align 4, !dbg !24 |
| 89 |
br label %return, !dbg !24 |
| 90 |
|
| 91 |
while.end: ; preds = %while.cond |
| 92 |
store i32 0, i32* %retval, align 4, !dbg !26 |
| 93 |
br label %return, !dbg !26 |
| 94 |
|
| 95 |
return: ; preds = %while.end, %while.body |
| 96 |
%1 = load i32, i32* %retval, align 4, !dbg !27 |
| 97 |
ret i32 %1, !dbg !27 |
| 98 |
} |
| 99 |
|
| 100 |
; Function Attrs: nounwind readnone |
| 101 |
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 102 |
|
| 103 |
; Function Attrs: nounwind |
| 104 |
define i32 @_Z3foov() #2 !dbg !8 { |
| 105 |
entry: |
| 106 |
%retval.i = alloca i32, align 4 |
| 107 |
%y.i = alloca i32, align 4 |
| 108 |
call void @llvm.dbg.declare(metadata i32* %y.i, metadata !18, metadata !19), !dbg !29 |
| 109 |
%0 = load i32, i32* %y.i, align 4, !dbg !31 |
| 110 |
%cmp.i = icmp slt i32 %0, 0, !dbg !31 |
| 111 |
br i1 %cmp.i, label %while.body.i, label %while.end.i, !dbg !31 |
| 112 |
|
| 113 |
while.body.i: ; preds = %entry |
| 114 |
store i32 2, i32* %retval.i, align 4, !dbg !32 |
| 115 |
br label %_Z3barv.exit, !dbg !32 |
| 116 |
|
| 117 |
while.end.i: ; preds = %entry |
| 118 |
store i32 0, i32* %retval.i, align 4, !dbg !33 |
| 119 |
br label %_Z3barv.exit, !dbg !33 |
| 120 |
|
| 121 |
_Z3barv.exit: ; preds = %while.end.i, %while.body.i |
| 122 |
%1 = load i32, i32* %retval.i, align 4, !dbg !34 |
| 123 |
ret i32 %1, !dbg !35 |
| 124 |
} |
| 125 |
|
| 126 |
attributes #0 = { alwaysinline nounwind } |
| 127 |
attributes #1 = { nounwind readnone } |
| 128 |
attributes #2 = { nounwind } |
| 129 |
|
| 130 |
!llvm.dbg.cu = !{!0} |
| 131 |
!llvm.module.flags = !{!15, !16} |
| 132 |
!llvm.ident = !{!17} |
| 133 |
|
| 134 |
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 264349)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, imports: !10) |
| 135 |
!1 = !DIFile(filename: "test.cpp", directory: "/") |
| 136 |
!2 = !{} |
| 137 |
!4 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) |
| 138 |
!5 = !DISubroutineType(types: !6) |
| 139 |
!6 = !{!7} |
| 140 |
!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 141 |
!8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !9, file: !9, line: 6, type: !5, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) |
| 142 |
!9 = !DIFile(filename: "test.h", directory: "/") |
| 143 |
!10 = !{!11} |
| 144 |
!11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !12, entity: !14, file: !1, line: 1) |
| 145 |
!12 = !DILexicalBlockFile(scope: !13, file: !9, discriminator: 0) |
| 146 |
!13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3) |
| 147 |
!14 = !DINamespace(name: "N", scope: null) |
| 148 |
!15 = !{i32 2, !"Dwarf Version", i32 4} |
| 149 |
!16 = !{i32 2, !"Debug Info Version", i32 3} |
| 150 |
!17 = !{!"clang version 3.9.0 (trunk 264349)"} |
| 151 |
!18 = !DILocalVariable(name: "y", scope: !13, file: !1, line: 4, type: !7) |
| 152 |
!19 = !DIExpression() |
| 153 |
!20 = !DILocation(line: 4, scope: !13) |
| 154 |
!21 = !DILocation(line: 2, scope: !12) |
| 155 |
!22 = !DILocation(line: 2, scope: !23) |
| 156 |
!23 = !DILexicalBlockFile(scope: !12, file: !9, discriminator: 1) |
| 157 |
!24 = !DILocation(line: 2, scope: !25) |
| 158 |
!25 = !DILexicalBlockFile(scope: !12, file: !9, discriminator: 2) |
| 159 |
!26 = !DILocation(line: 3, scope: !12) |
| 160 |
!27 = !DILocation(line: 5, scope: !28) |
| 161 |
!28 = !DILexicalBlockFile(scope: !4, file: !9, discriminator: 0) |
| 162 |
!29 = !DILocation(line: 4, scope: !13, inlinedAt: !30) |
| 163 |
!30 = distinct !DILocation(line: 7, scope: !8) |
| 164 |
!31 = !DILocation(line: 2, scope: !23, inlinedAt: !30) |
| 165 |
!32 = !DILocation(line: 2, scope: !25, inlinedAt: !30) |
| 166 |
!33 = !DILocation(line: 3, scope: !12, inlinedAt: !30) |
| 167 |
!34 = !DILocation(line: 5, scope: !28, inlinedAt: !30) |
| 168 |
!35 = !DILocation(line: 7, scope: !8) |