|
| 1 | +; RUN: llc -O2 %s -o - -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=OPTS |
| 2 | +; RUN: llc -O0 %s -o - -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=UNOPT |
| 3 | + |
| 4 | +;; Test that, even though there are no source locations attached to the foo |
| 5 | +;; function, we still give it the start-of-function source location of the |
| 6 | +;; definition line. Otherwise, this function would have no entry in the |
| 7 | +;; line table at all. |
| 8 | + |
| 9 | +; OPTS-LABEL: foo: |
| 10 | +; OPTS-NEXT: .Lfunc_begin0: |
| 11 | +; OPTS-NEXT: .file 0 "." "foobar.c" |
| 12 | +; OPTS-NEXT: .loc 0 1 0 |
| 13 | +; OPTS-LABEL: bar: |
| 14 | + |
| 15 | +define dso_local noundef i32 @foo(ptr nocapture noundef writeonly %bar) local_unnamed_addr !dbg !10 { |
| 16 | +entry: |
| 17 | + store i32 0, ptr %bar, align 4 |
| 18 | + ret i32 0 |
| 19 | +} |
| 20 | + |
| 21 | +;; In a function with no source location, but multiple blocks, there will be |
| 22 | +;; an opening scope-line, but it'll be automagically terminated when we switch |
| 23 | +;; to a new block. Test for this behaviour, and preserve the unconditional |
| 24 | +;; branch by compiling -O0. |
| 25 | + |
| 26 | +; UNOPT-LABEL: bar: |
| 27 | +; UNOPT-NEXT: .Lfunc_begin1: |
| 28 | +; UNOPT-NEXT: .loc 0 11 0 |
| 29 | +; UNOPT-LABEL: %bb.0: |
| 30 | +; UNOPT-NEXT: movq %rdi, -8(%rsp) |
| 31 | +; UNOPT-NEXT: jmp .LBB1_1 |
| 32 | +; UNOPT-LABEL: .LBB1_1: |
| 33 | +; UNOPT-NEXT: .loc 1 0 0 is_stmt 0 |
| 34 | +; UNOPT-NEXT: movq -8(%rsp), %rax |
| 35 | + |
| 36 | +define dso_local noundef i32 @bar(ptr nocapture noundef writeonly %baz) local_unnamed_addr !dbg !20 { |
| 37 | +entry: |
| 38 | + br label %bb1 |
| 39 | +bb1: |
| 40 | + store i32 0, ptr %baz, align 4 |
| 41 | + ret i32 0 |
| 42 | +} |
| 43 | + |
| 44 | +!llvm.dbg.cu = !{!0} |
| 45 | +!llvm.module.flags = !{!2, !3} |
| 46 | +!llvm.ident = !{!9} |
| 47 | + |
| 48 | +!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) |
| 49 | +!1 = !DIFile(filename: "foobar.c", directory: ".") |
| 50 | +!2 = !{i32 7, !"Dwarf Version", i32 5} |
| 51 | +!3 = !{i32 2, !"Debug Info Version", i32 3} |
| 52 | +!9 = !{!"clang"} |
| 53 | +!10 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) |
| 54 | +!11 = !DISubroutineType(types: !12) |
| 55 | +!12 = !{!13, !14} |
| 56 | +!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) |
| 57 | +!14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64) |
| 58 | +!15 = !{!16} |
| 59 | +!16 = !DILocalVariable(name: "bar", arg: 1, scope: !10, file: !1, line: 1, type: !14) |
| 60 | +!17 = !DILocation(line: 0, scope: !10) |
| 61 | +!18 = !DILocation(line: 2, column: 8, scope: !10) |
| 62 | +!20 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 11, type: !11, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !25) |
| 63 | +!25 = !{!26} |
| 64 | +!26 = !DILocalVariable(name: "bar", arg: 1, scope: !20, file: !1, line: 11, type: !14) |
| 65 | +!27 = !DILocation(line: 0, scope: !20) |
| 66 | +!28 = !DILocation(line: 12, column: 8, scope: !20) |
| 67 | + |
0 commit comments