1# RUN: llc -verify-machineinstrs -start-after=virtregrewriter -filetype=obj -o - %s | llvm-dwarfdump -a - | FileCheck %s
2#
3# This testcase has an implicit def pseudo-instruction with a debug location.
4#
5# CHECK: .debug_info contents:
6# CHECK: DW_TAG_subprogram
7# CHECK:	DW_AT_low_pc (0x0000000000000000)
8# CHECK-NOT: DW_TAG
9# CHECK:	DW_AT_specification {{.*}} "_ZN1C5m_fn3Ev"
10# CHECK-NOT: DW_TAG
11#	     Here should not be an inlined subroutine with 0 length.
12# CHECK: NULL
13#
14# CHECK: Address            Line   Column File   ISA Discriminator Flags
15# CHECK-NEXT:                ---
16# CHECK-NEXT:                 25      0      1   0             0  is_stmt
17# CHECK-NEXT:                 29     28      1   0             0  is_stmt prologue_end
18# CHECK-NEXT:                 29     28      1   0             0  is_stmt end_sequence
19--- |
20  source_filename = "t.ll"
21  target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
22  target triple = "x86_64-apple-macosx"
23
24  %class.E = type { %class.D }
25  %class.D = type { %class.B }
26  %class.B = type { %class.A, %class.A }
27  %class.A = type { i8 }
28  %class.C = type <{ %class.E*, %class.B, [2 x i8] }>
29
30  @a = local_unnamed_addr global %class.E* null, align 4
31
32  define i32 @_ZN1C5m_fn3Ev(%class.C* nocapture) local_unnamed_addr align 2 !dbg !6 {
33    %2 = alloca %class.B, align 1
34    %3 = load %class.E*, %class.E** @a, align 4
35    %4 = icmp eq %class.E* %3, null
36    br i1 %4, label %10, label %5
37
38  ; <label>:5:                                      ; preds = %1
39    %6 = bitcast %class.C* %0 to %class.D**
40    %7 = load %class.D*, %class.D** %6, align 4
41    %8 = bitcast %class.D* %7 to i8*
42    %9 = load i8, i8* %8, align 1
43    br label %10
44
45  ; <label>:10:                                     ; preds = %5, %1
46    %11 = phi i8 [ %9, %5 ], [ undef, %1 ], !dbg !10
47    %12 = getelementptr inbounds %class.C, %class.C* %0, i32 0, i32 1, i32 0, i32 0
48    store i8 %11, i8* %12, align 1, !dbg !14
49    ret i32 undef
50  }
51
52  !llvm.dbg.cu = !{!0}
53  !llvm.module.flags = !{!3, !4, !5}
54
55  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "Apple LLVM version 8.1.0 (clang-802.0.30.3)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2)
56  !1 = !DIFile(filename: "test.ii", directory: "/")
57  !2 = !{}
58  !3 = !{i32 2, !"Dwarf Version", i32 4}
59  !4 = !{i32 2, !"Debug Info Version", i32 3}
60  !5 = !{i32 1, !"PIC Level", i32 2}
61  !6 = distinct !DISubprogram(name: "m_fn3", linkageName: "_ZN1C5m_fn3Ev", scope: !7, file: !1, line: 25, type: !8, isLocal: false, isDefinition: true, scopeLine: 25, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !9, retainedNodes: !2)
62  !7 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !1, line: 14, size: 64, align: 32, elements: !2, identifier: "_ZTS1C")
63  !8 = !DISubroutineType(types: !2)
64  !9 = !DISubprogram(name: "m_fn3", linkageName: "_ZN1C5m_fn3Ev", scope: !7, file: !1, line: 15, type: !8, isLocal: false, isDefinition: false, scopeLine: 15, flags: DIFlagPrototyped, isOptimized: true)
65  !10 = !DILocation(line: 99, column: 9, scope: !11, inlinedAt: !14)
66  !11 = distinct !DISubprogram(name: "m_fn1", linkageName: "_ZN1A5m_fn1Ev", scope: !12, file: !1, line: 5, type: !8, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !13, retainedNodes: !2)
67  !12 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !1, line: 1, size: 8, align: 8, elements: !2, identifier: "_ZTS1A")
68  !13 = !DISubprogram(name: "m_fn1", linkageName: "_ZN1A5m_fn1Ev", scope: !12, file: !1, line: 5, type: !8, isLocal: false, isDefinition: false, scopeLine: 5, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: true)
69  !14 = !DILocation(line: 29, column: 28, scope: !6)
70
71...
72---
73name:            _ZN1C5m_fn3Ev
74alignment:       16
75exposesReturnsTwice: false
76legalized:       false
77regBankSelected: false
78selected:        false
79tracksRegLiveness: true
80liveins:
81  - { reg: '$rdi' }
82frameInfo:
83  isFrameAddressTaken: false
84  isReturnAddressTaken: false
85  hasStackMap:     false
86  hasPatchPoint:   false
87  stackSize:       0
88  offsetAdjustment: 0
89  maxAlignment:    8
90  adjustsStack:    false
91  hasCalls:        false
92  maxCallFrameSize: 0
93  hasOpaqueSPAdjustment: false
94  hasVAStart:      false
95  hasMustTailInVarArgFunc: false
96#stack:
97#  - { id: 0, name: '<unnamed alloca>', offset: -16, size: 2, alignment: 8 }
98body:             |
99  bb.0 (%ir-block.1):
100    successors: %bb.1(0x30000000), %bb.2(0x50000000)
101    liveins: $rdi
102
103    CMP64mi8 $rip, 1, _, @a, _, 0, implicit-def $eflags :: (dereferenceable load (s64) from @a, align 4)
104    JCC_1 %bb.1, 4, implicit $eflags
105
106  bb.2 (%ir-block.5):
107    liveins: $rdi
108
109    $rax = MOV64rm $rdi, 1, _, 0, _ :: (load (s64) from %ir.6, align 4)
110    $al = MOV8rm killed $rax, 1, _, 0, _ :: (load (s8) from %ir.8)
111    MOV8mr killed $rdi, 1, _, 8, _, killed $al, debug-location !14 :: (store (s8) into %ir.12)
112    RET64 undef $eax
113
114  bb.1:
115    liveins: $rdi
116
117    $al = IMPLICIT_DEF debug-location !10
118    MOV8mr killed $rdi, 1, _, 8, _, killed $al, debug-location !14 :: (store (s8) into %ir.12)
119    RET64 undef $eax
120
121...
122