• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llc -run-pass=livedebugvalues %s -o - | FileCheck %s
2#
3# This test tests tracking variables value transferring from one register to another.
4# This example is altered additionally in order to test transferring from one float register
5# to another. The altered instructions are labeled below.
6#
7# CHECK: ![[ARG1:.*]] = !DILocalVariable(name: "arg1"
8# CHECK: DBG_VALUE debug-use $ebx, debug-use $noreg, ![[ARG1]], !DIExpression(), debug-location
9# CHECK: $r12d = MOV32rr killed $ebx, implicit-def $r12
10# CHECK-NEXT: DBG_VALUE debug-use $r12d, debug-use $noreg, ![[ARG1]], !DIExpression(), debug-location
11--- |
12  ; ModuleID = 'live-debug-values-reg-copy.ll'
13  source_filename = "live-debug-values-reg-copy.c"
14  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
15  target triple = "x86_64-unknown-linux-gnu"
16
17  define dso_local i32 @foo(i32 %arg1) local_unnamed_addr !dbg !7 {
18  entry:
19    %local1 = alloca i32, align 4
20    call void @llvm.dbg.value(metadata i32 %arg1, metadata !12, metadata !DIExpression()), !dbg !15
21    %0 = bitcast i32* %local1 to i8*, !dbg !15
22    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0), !dbg !15
23    call void @init(i32* nonnull %local1), !dbg !15
24    %1 = load i32, i32* %local1, align 4, !dbg !15, !tbaa !20
25    %add = add nsw i32 %1, %arg1, !dbg !15
26    %call = call i32 @coeficient(i32 %add), !dbg !15
27    %cmp = icmp sgt i32 %call, 32, !dbg !15
28    br i1 %cmp, label %if.then, label %if.else, !dbg !15
29
30  if.then:                                          ; preds = %entry
31    %call1 = call i32 @externFunc(i32 %arg1), !dbg !15
32    %2 = load i32, i32* %local1, align 4, !dbg !15, !tbaa !20
33    %add2 = add nsw i32 %2, %call1, !dbg !15
34    br label %if.end, !dbg !15
35
36  if.else:                                          ; preds = %entry
37    %call3 = call i32 @externFunc2(i32 %arg1), !dbg !15
38    %3 = load i32, i32* %local1, align 4, !dbg !15, !tbaa !20
39    %add4 = add nsw i32 %3, %call3, !dbg !15
40    br label %if.end
41
42  if.end:                                           ; preds = %if.else, %if.then
43    %storemerge = phi i32 [ %add4, %if.else ], [ %add2, %if.then ]
44    %4 = bitcast i32* %local1 to i8*
45    %mul = shl nsw i32 %arg1, 2, !dbg !15
46    %add5 = add nsw i32 %storemerge, %mul, !dbg !15
47    %mul6 = mul nsw i32 %add5, %call, !dbg !15
48    call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4), !dbg !15
49    ret i32 %mul6, !dbg !15
50  }
51
52  ; Function Attrs: argmemonly nounwind
53  declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #0
54
55  declare dso_local void @init(i32*) local_unnamed_addr
56
57  declare dso_local i32 @coeficient(i32) local_unnamed_addr
58
59  declare dso_local i32 @externFunc(i32) local_unnamed_addr
60
61  declare dso_local i32 @externFunc2(i32) local_unnamed_addr
62
63  ; Function Attrs: argmemonly nounwind
64  declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #0
65
66  ; Function Attrs: nounwind readnone speculatable
67  declare void @llvm.dbg.value(metadata, metadata, metadata) #1
68
69  ; Function Attrs: nounwind
70  declare void @llvm.stackprotector(i8*, i8**) #2
71
72  attributes #0 = { argmemonly nounwind }
73  attributes #1 = { nounwind readnone speculatable }
74  attributes #2 = { nounwind }
75
76  !llvm.dbg.cu = !{!0}
77  !llvm.module.flags = !{!3, !4, !5}
78  !llvm.ident = !{!6}
79
80  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
81  !1 = !DIFile(filename: "live-debug-values-reg-copy.c", directory: "/")
82  !2 = !{}
83  !3 = !{i32 2, !"Dwarf Version", i32 4}
84  !4 = !{i32 2, !"Debug Info Version", i32 3}
85  !5 = !{i32 1, !"wchar_size", i32 4}
86  !6 = !{!"clang version 7.0.0 "}
87  !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 6, type: !8, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
88  !8 = !DISubroutineType(types: !9)
89  !9 = !{!10, !10}
90  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
91  !11 = !{!12}
92  !12 = !DILocalVariable(name: "arg1", arg: 1, scope: !7, file: !1, line: 6, type: !10)
93  !15 = !DILocation(line: 6, column: 13, scope: !7)
94  !20 = !{!21, !21, i64 0}
95  !21 = !{!"int", !22, i64 0}
96  !22 = !{!"omnipotent char", !23, i64 0}
97  !23 = !{!"Simple C/C++ TBAA"}
98
99...
100---
101name:            foo
102alignment:       4
103exposesReturnsTwice: false
104legalized:       false
105regBankSelected: false
106selected:        false
107tracksRegLiveness: true
108registers:
109liveins:
110  - { reg: '$edi', virtual-reg: '' }
111frameInfo:
112  isFrameAddressTaken: false
113  isReturnAddressTaken: false
114  hasStackMap:     false
115  hasPatchPoint:   false
116  stackSize:       24
117  offsetAdjustment: 0
118  maxAlignment:    4
119  adjustsStack:    true
120  hasCalls:        true
121  stackProtector:  ''
122  maxCallFrameSize: 0
123  hasOpaqueSPAdjustment: false
124  hasVAStart:      false
125  hasMustTailInVarArgFunc: false
126  savePoint:       ''
127  restorePoint:    ''
128fixedStack:
129  - { id: 0, type: spill-slot, offset: -24, size: 8, alignment: 8, stack-id: 0,
130      callee-saved-register: '$rbx', callee-saved-restored: true }
131  - { id: 1, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: 0,
132      callee-saved-register: '$rbp', callee-saved-restored: true }
133stack:
134  - { id: 0, name: local1, type: default, offset: -28, size: 4, alignment: 4,
135      stack-id: 0, callee-saved-register: '', callee-saved-restored: true,
136      debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
137constants:
138body:             |
139  bb.0.entry:
140    successors: %bb.1(0x40000000), %bb.2(0x40000000)
141    liveins: $edi, $rbp, $rbx
142
143    frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
144    CFI_INSTRUCTION def_cfa_offset 16
145    frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
146    CFI_INSTRUCTION def_cfa_offset 24
147    frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
148    CFI_INSTRUCTION def_cfa_offset 32
149    CFI_INSTRUCTION offset $rbx, -24
150    CFI_INSTRUCTION offset $rbp, -16
151    DBG_VALUE debug-use $edi, debug-use $noreg, !12, !DIExpression(), debug-location !15
152    $ebx = MOV32rr $edi, implicit-def $rbx
153    DBG_VALUE debug-use $ebx, debug-use $noreg, !12, !DIExpression(), debug-location !15
154    renamable $rdi = LEA64r $rsp, 1, $noreg, 4, $noreg
155    CALL64pcrel32 @init, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, debug-location !15
156    renamable $edi = MOV32rm $rsp, 1, $noreg, 4, $noreg :: (dereferenceable load 4 from %ir.local1, !tbaa !20)
157    renamable $edi = ADD32rr killed renamable $edi, renamable $ebx, implicit-def dead $eflags, debug-location !15
158    CALL64pcrel32 @coeficient, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15
159    $ebp = MOV32rr $eax, debug-location !15
160    $edi = MOV32rr $ebx, debug-location !15
161    CMP32ri8 renamable $ebp, 33, implicit-def $eflags, debug-location !15
162    JL_1 %bb.2, implicit killed $eflags, debug-location !15
163
164  bb.1.if.then:
165    successors: %bb.3(0x80000000)
166    liveins: $ebp, $edi
167
168    CALL64pcrel32 @externFunc, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15
169    JMP_1 %bb.3
170
171  bb.2.if.else:
172    successors: %bb.3(0x80000000)
173    liveins: $ebp, $edi
174
175    CALL64pcrel32 @externFunc2, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !15
176
177  bb.3.if.end:
178    liveins: $ebp, $ebx, $eax
179    ; Instruction below is added in order to test moving variable's value from one register to another.
180    $r12d = MOV32rr killed $ebx, implicit-def $r12
181    renamable $eax = KILL $eax, implicit-def $rax
182    renamable $eax = ADD32rm renamable $eax, $rsp, 1, $noreg, 4, $noreg, implicit-def dead $eflags, implicit killed $rax, implicit-def $rax :: (dereferenceable load 4 from %ir.local1, !tbaa !20)
183    renamable $eax = LEA64_32r killed renamable $rax, 4, killed renamable $r12, 0, $noreg, debug-location !15
184    renamable $eax = IMUL32rr killed renamable $eax, killed renamable $ebp, implicit-def dead $eflags, debug-location !15
185    $rsp = frame-destroy ADD64ri8 $rsp, 8, implicit-def dead $eflags, debug-location !15
186    $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15
187    $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !15
188    RETQ $eax, debug-location !15
189
190...
191