• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llc -debug-entry-values -run-pass=livedebugvalues -march=x86-64 -o - %s | FileCheck %s
2#
3# The test case was artificially adjusted, in order to make proper diamond basic
4# block structure relevant to the debug entry values clobbering.
5#
6# CHECK: ![[ARG_B:.*]] = !DILocalVariable(name: "b"
7# CHECK: bb.0.entry
8# CHECK: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression()
9# CHECK: bb.1.if.then
10# CHECK: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression()
11# CHECK: $ebx = MOV32rr $esi
12# CHECK-NEXT: DBG_VALUE $ebx, $noreg, ![[ARG_B]], !DIExpression()
13# CHECK-NEXT: $esi = MOV32ri 5
14# CHECK-NEXT: $ebx = MOV32ri 1
15# CHECK-NEXT: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression(DW_OP_LLVM_entry_value, 1)
16# CHECK: bb.2.if.else
17# CHECK: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression()
18# CHECK: $ebp = MOV32rr $esi
19# CHECK: DBG_VALUE $ebp, $noreg, ![[ARG_B]], !DIExpression()
20# CHECK-NEXT: $esi = MOV32ri 1
21# CHECK-NEXT: $ebp = MOV32ri 2
22# CHECK-NEXT: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression(DW_OP_LLVM_entry_value, 1)
23# CHECK: bb.3.if.end
24# CHECK-NOT: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression(DW_OP_LLVM_entry_value, 1)
25#
26--- |
27  ; ModuleID = 'test.c'
28  source_filename = "test.c"
29  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
30  target triple = "x86_64-unknown-linux-gnu"
31
32  ; Function Attrs: noinline nounwind uwtable
33  define dso_local i32 @fn2(i32 %a, i32 %b, i32 %c) local_unnamed_addr !dbg !12 {
34  entry:
35    call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !DIExpression()), !dbg !20
36    call void @llvm.dbg.value(metadata i32 %b, metadata !17, metadata !DIExpression()), !dbg !20
37    call void @llvm.dbg.value(metadata i32 %c, metadata !18, metadata !DIExpression()), !dbg !20
38    %add = add nsw i32 %a, 2, !dbg !21
39    call void @llvm.dbg.value(metadata i32 %add, metadata !19, metadata !DIExpression()), !dbg !20
40    tail call void @fn1(i32 5, i32 6, i32 %add), !dbg !22
41    %cmp = icmp slt i32 %b, 17, !dbg !23
42    br i1 %cmp, label %if.then, label %if.else, !dbg !25
43
44  if.then:                                          ; preds = %entry
45    %add1 = add nsw i32 %b, 7, !dbg !26
46    call void @llvm.dbg.value(metadata i32 %add1, metadata !17, metadata !DIExpression()), !dbg !20
47    tail call void @fn1(i32 5, i32 %add1, i32 %c), !dbg !28
48    br label %if.end, !dbg !29
49
50  if.else:                                          ; preds = %entry
51    %add2 = add nuw nsw i32 %b, 1, !dbg !30
52    call void @llvm.dbg.value(metadata i32 %add2, metadata !17, metadata !DIExpression()), !dbg !20
53    tail call void @fn1(i32 1, i32 %add2, i32 %c), !dbg !32
54    br label %if.end
55
56  if.end:                                           ; preds = %if.else, %if.then
57    %b.addr.0 = phi i32 [ %add1, %if.then ], [ %add2, %if.else ], !dbg !33
58    call void @llvm.dbg.value(metadata i32 %b.addr.0, metadata !17, metadata !DIExpression()), !dbg !20
59    ret i32 %b.addr.0, !dbg !34
60  }
61
62  declare !dbg !4 dso_local void @fn1(i32, i32, i32) local_unnamed_addr
63
64  ; Function Attrs: nounwind readnone speculatable willreturn
65  declare void @llvm.dbg.value(metadata, metadata, metadata)
66
67  !llvm.dbg.cu = !{!0}
68  !llvm.module.flags = !{!8, !9, !10}
69  !llvm.ident = !{!11}
70
71  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
72  !1 = !DIFile(filename: "test.c", directory: "/dir")
73  !2 = !{}
74  !3 = !{!4}
75  !4 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
76  !5 = !DISubroutineType(types: !6)
77  !6 = !{null, !7, !7, !7}
78  !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
79  !8 = !{i32 2, !"Dwarf Version", i32 4}
80  !9 = !{i32 2, !"Debug Info Version", i32 3}
81  !10 = !{i32 1, !"wchar_size", i32 4}
82  !11 = !{!"clang version 10.0.0"}
83  !12 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 5, type: !13, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
84  !13 = !DISubroutineType(types: !14)
85  !14 = !{!7, !7, !7, !7}
86  !15 = !{!16, !17, !18, !19}
87  !16 = !DILocalVariable(name: "a", arg: 1, scope: !12, file: !1, line: 5, type: !7)
88  !17 = !DILocalVariable(name: "b", arg: 2, scope: !12, file: !1, line: 5, type: !7)
89  !18 = !DILocalVariable(name: "c", arg: 3, scope: !12, file: !1, line: 5, type: !7)
90  !19 = !DILocalVariable(name: "q", scope: !12, file: !1, line: 7, type: !7)
91  !20 = !DILocation(line: 0, scope: !12)
92  !21 = !DILocation(line: 7, column: 15, scope: !12)
93  !22 = !DILocation(line: 9, column: 5, scope: !12)
94  !23 = !DILocation(line: 11, column: 11, scope: !24)
95  !24 = distinct !DILexicalBlock(scope: !12, file: !1, line: 11, column: 9)
96  !25 = !DILocation(line: 11, column: 9, scope: !12)
97  !26 = !DILocation(line: 12, column: 13, scope: !27)
98  !27 = distinct !DILexicalBlock(scope: !24, file: !1, line: 11, column: 17)
99  !28 = !DILocation(line: 13, column: 8, scope: !27)
100  !29 = !DILocation(line: 14, column: 5, scope: !27)
101  !30 = !DILocation(line: 15, column: 13, scope: !31)
102  !31 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 12)
103  !32 = !DILocation(line: 16, column: 7, scope: !31)
104  !33 = !DILocation(line: 0, scope: !24)
105  !34 = !DILocation(line: 19, column: 5, scope: !12)
106
107...
108---
109name:            fn2
110alignment:       16
111fixedStack:
112  - { id: 0, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: default,
113      callee-saved-register: '$rbx', callee-saved-restored: true, debug-info-variable: '',
114      debug-info-expression: '', debug-info-location: '' }
115  - { id: 1, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default,
116      callee-saved-register: '$rbp', callee-saved-restored: true, debug-info-variable: '',
117      debug-info-expression: '', debug-info-location: '' }
118body:             |
119  bb.0.entry:
120    successors: %bb.1(0x40000000), %bb.2(0x40000000)
121    liveins: $edi, $edx, $esi, $rbp, $rbx
122
123    DBG_VALUE $edi, $noreg, !16, !DIExpression(), debug-location !20
124    DBG_VALUE $esi, $noreg, !17, !DIExpression(), debug-location !20
125    DBG_VALUE $edx, $noreg, !18, !DIExpression(), debug-location !20
126    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
127    CFI_INSTRUCTION def_cfa_offset 16
128    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
129    CFI_INSTRUCTION def_cfa_offset 24
130    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
131    CFI_INSTRUCTION def_cfa_offset 32
132    CFI_INSTRUCTION offset $rbx, -24
133    CFI_INSTRUCTION offset $rbp, -16
134    $ebp = MOV32rr $edx
135    DBG_VALUE $ebp, $noreg, !18, !DIExpression(), debug-location !20
136    renamable $edi = KILL $edi, implicit-def $rdi
137    DBG_VALUE $edi, $noreg, !16, !DIExpression(), debug-location !20
138    renamable $edx = LEA64_32r killed renamable $rdi, 1, $noreg, 2, $noreg, debug-location !21
139    DBG_VALUE $edx, $noreg, !19, !DIExpression(), debug-location !20
140    $edi = MOV32ri 5, debug-location !22
141    CMP32ri8 renamable $ebp, 16, implicit-def $eflags, debug-location !23
142    JCC_1 %bb.2, 15, implicit killed $eflags, debug-location !25
143
144  bb.1.if.then:
145    successors: %bb.3(0x80000000)
146    liveins: $ebp, $ebx, $esi
147
148    $ebx = MOV32rr $esi
149    DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20
150    $esi = MOV32ri 5, debug-location !28
151    $ebx = MOV32ri 1
152    JMP_1 %bb.3
153
154  bb.2.if.else:
155    successors: %bb.3(0x80000000)
156    liveins: $ebp, $ebx, $esi
157
158    $ebp = MOV32rr $esi
159    DBG_VALUE $ebp, $noreg, !17, !DIExpression(), debug-location !20
160    $esi = MOV32ri 1, debug-location !32
161    $ebp = MOV32ri 2
162
163  bb.3.if.end:
164    liveins: $ebx, $edi, $ebp
165
166    $esi = MOV32rr $ebx, debug-location !33
167    $edx = MOV32rr killed $ebp, debug-location !33
168    CALL64pcrel32 @fn1, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit $edx, implicit-def $rsp, implicit-def $ssp, debug-location !33
169    DBG_VALUE $ebx, $noreg, !17, !DIExpression(), debug-location !20
170    $eax = MOV32rr killed $ebx, debug-location !34
171    $rsp = frame-destroy ADD64ri8 $rsp, 8, implicit-def dead $eflags, debug-location !34
172    CFI_INSTRUCTION def_cfa_offset 24, debug-location !34
173    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34
174    CFI_INSTRUCTION def_cfa_offset 16, debug-location !34
175    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !34
176    CFI_INSTRUCTION def_cfa_offset 8, debug-location !34
177    RETQ killed $eax, debug-location !34
178
179...
180
181