| 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 -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 |
; bool f(); |
| 13 |
; inline __attribute__((always_inline)) int f1() { |
| 14 |
; if (bool b = f()) |
| 15 |
; return 1; |
| 16 |
; return 2; |
| 17 |
; } |
| 18 |
; |
| 19 |
; inline __attribute__((always_inline)) int f2() { |
| 20 |
; # 2 "y.cc" |
| 21 |
; if (bool b = f()) |
| 22 |
; return 3; |
| 23 |
; return 4; |
| 24 |
; } |
| 25 |
; |
| 26 |
; int main() { |
| 27 |
; f1(); |
| 28 |
; f2(); |
| 29 |
; } |
| 30 |
|
| 31 |
; Ensure that lexical_blocks within inlined_subroutines are preserved/emitted. |
| 32 |
; CHECK: DW_TAG_inlined_subroutine |
| 33 |
; CHECK-NOT: DW_TAG |
| 34 |
; CHECK-NOT: NULL |
| 35 |
; CHECK: DW_TAG_lexical_block |
| 36 |
; CHECK-NOT: DW_TAG |
| 37 |
; CHECK-NOT: NULL |
| 38 |
; CHECK: DW_TAG_variable |
| 39 |
; Ensure that file changes don't interfere with creating inlined subroutines. |
| 40 |
; (see the line directive inside 'f2' in thesource) |
| 41 |
; CHECK: DW_TAG_inlined_subroutine |
| 42 |
; CHECK: DW_TAG_variable |
| 43 |
; CHECK-NOT: DW_TAG |
| 44 |
; CHECK: DW_AT_abstract_origin |
| 45 |
|
| 46 |
; Function Attrs: uwtable |
| 47 |
define i32 @main() #0 !dbg !4 { |
| 48 |
entry: |
| 49 |
%retval.i2 = alloca i32, align 4 |
| 50 |
%b.i3 = alloca i8, align 1 |
| 51 |
%retval.i = alloca i32, align 4 |
| 52 |
%b.i = alloca i8, align 1 |
| 53 |
call void @llvm.dbg.declare(metadata i8* %b.i, metadata !16, metadata !DIExpression()), !dbg !19 |
| 54 |
%call.i = call zeroext i1 @_Z1fv(), !dbg !19 |
| 55 |
%frombool.i = zext i1 %call.i to i8, !dbg !19 |
| 56 |
store i8 %frombool.i, i8* %b.i, align 1, !dbg !19 |
| 57 |
%0 = load i8, i8* %b.i, align 1, !dbg !19 |
| 58 |
%tobool.i = trunc i8 %0 to i1, !dbg !19 |
| 59 |
br i1 %tobool.i, label %if.then.i, label %if.end.i, !dbg !19 |
| 60 |
|
| 61 |
if.then.i: ; preds = %entry |
| 62 |
store i32 1, i32* %retval.i, !dbg !21 |
| 63 |
br label %_Z2f1v.exit, !dbg !21 |
| 64 |
|
| 65 |
if.end.i: ; preds = %entry |
| 66 |
store i32 2, i32* %retval.i, !dbg !22 |
| 67 |
br label %_Z2f1v.exit, !dbg !22 |
| 68 |
|
| 69 |
_Z2f1v.exit: ; preds = %if.then.i, %if.end.i |
| 70 |
%1 = load i32, i32* %retval.i, !dbg !23 |
| 71 |
call void @llvm.dbg.declare(metadata i8* %b.i3, metadata !24, metadata !DIExpression()), !dbg !27 |
| 72 |
%call.i4 = call zeroext i1 @_Z1fv(), !dbg !27 |
| 73 |
%frombool.i5 = zext i1 %call.i4 to i8, !dbg !27 |
| 74 |
store i8 %frombool.i5, i8* %b.i3, align 1, !dbg !27 |
| 75 |
%2 = load i8, i8* %b.i3, align 1, !dbg !27 |
| 76 |
%tobool.i6 = trunc i8 %2 to i1, !dbg !27 |
| 77 |
br i1 %tobool.i6, label %if.then.i7, label %if.end.i8, !dbg !27 |
| 78 |
|
| 79 |
if.then.i7: ; preds = %_Z2f1v.exit |
| 80 |
store i32 3, i32* %retval.i2, !dbg !29 |
| 81 |
br label %_Z2f2v.exit, !dbg !29 |
| 82 |
|
| 83 |
if.end.i8: ; preds = %_Z2f1v.exit |
| 84 |
store i32 4, i32* %retval.i2, !dbg !30 |
| 85 |
br label %_Z2f2v.exit, !dbg !30 |
| 86 |
|
| 87 |
_Z2f2v.exit: ; preds = %if.then.i7, %if.end.i8 |
| 88 |
%3 = load i32, i32* %retval.i2, !dbg !31 |
| 89 |
ret i32 0, !dbg !32 |
| 90 |
} |
| 91 |
|
| 92 |
; Function Attrs: nounwind readnone |
| 93 |
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 94 |
|
| 95 |
declare zeroext i1 @_Z1fv() #2 |
| 96 |
|
| 97 |
attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 98 |
attributes #1 = { nounwind readnone } |
| 99 |
attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 100 |
|
| 101 |
!llvm.dbg.cu = !{!0} |
| 102 |
!llvm.module.flags = !{!13, !14} |
| 103 |
!llvm.ident = !{!15} |
| 104 |
|
| 105 |
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) |
| 106 |
!1 = !DIFile(filename: "inline-scopes.cpp", directory: "/tmp/dbginfo") |
| 107 |
!2 = !{} |
| 108 |
!4 = distinct !DISubprogram(name: "main", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !5, scope: !6, type: !7, retainedNodes: !2) |
| 109 |
!5 = !DIFile(filename: "y.cc", directory: "/tmp/dbginfo") |
| 110 |
!6 = !DIFile(filename: "y.cc", directory: "/tmp/dbginfo") |
| 111 |
!7 = !DISubroutineType(types: !8) |
| 112 |
!8 = !{!9} |
| 113 |
!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 114 |
!10 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", line: 8, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 8, file: !1, scope: !11, type: !7, retainedNodes: !2) |
| 115 |
!11 = !DIFile(filename: "inline-scopes.cpp", directory: "/tmp/dbginfo") |
| 116 |
!12 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !11, type: !7, retainedNodes: !2) |
| 117 |
!13 = !{i32 2, !"Dwarf Version", i32 4} |
| 118 |
!14 = !{i32 1, !"Debug Info Version", i32 3} |
| 119 |
!15 = !{!"clang version 3.5.0 "} |
| 120 |
!16 = !DILocalVariable(name: "b", line: 3, scope: !17, file: !11, type: !18) |
| 121 |
!17 = distinct !DILexicalBlock(line: 3, column: 0, file: !1, scope: !12) |
| 122 |
!18 = !DIBasicType(tag: DW_TAG_base_type, name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean) |
| 123 |
!19 = !DILocation(line: 3, scope: !17, inlinedAt: !20) |
| 124 |
!20 = !DILocation(line: 8, scope: !4) |
| 125 |
!21 = !DILocation(line: 4, scope: !17, inlinedAt: !20) |
| 126 |
!22 = !DILocation(line: 5, scope: !12, inlinedAt: !20) |
| 127 |
!23 = !DILocation(line: 6, scope: !12, inlinedAt: !20) |
| 128 |
!24 = !DILocalVariable(name: "b", line: 2, scope: !25, file: !6, type: !18) |
| 129 |
!25 = distinct !DILexicalBlock(line: 2, column: 0, file: !5, scope: !26) |
| 130 |
!26 = !DILexicalBlockFile(discriminator: 0, file: !5, scope: !10) |
| 131 |
!27 = !DILocation(line: 2, scope: !25, inlinedAt: !28) |
| 132 |
!28 = !DILocation(line: 9, scope: !4) |
| 133 |
!29 = !DILocation(line: 3, scope: !25, inlinedAt: !28) |
| 134 |
!30 = !DILocation(line: 4, scope: !26, inlinedAt: !28) |
| 135 |
!31 = !DILocation(line: 5, scope: !26, inlinedAt: !28) |
| 136 |
!32 = !DILocation(line: 10, scope: !4) |