File: instr-ref-track-clobbers.mir

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (140 lines) | stat: -rw-r--r-- 5,921 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# RUN: llc --run-pass=livedebugvalues %s -o - -experimental-debug-variable-locations | FileCheck %s --check-prefixes=CHECK

# Test that we accurately track variables through transfers and clobbers.

# In this test case, the value of "b" is found in $rax. From there it is moved
# to $r15, $rax is killed, the value is moved back from $r15 into $rax again,
# and then $r15 is killed. Throughout this, we should track "b" and end up with
# DBG_VALUEs pointing to $rax, then $r15, then $rax again.

# CHECK-LABEL: bb.0.entry:
# CHECK: DBG_VALUE $rax,
# CHECK: $r15 = MOV64rr

## Technically it's correct to insert the DBG_VALUE for $r15 either immediately
## after the move to $r15 or immediately after $rax is clobbered, but no later.
# CHECK: DBG_VALUE $r15,
# CHECK: $rax = LEA64r
# CHECK: $rax = MOV64rr

## Again, the DBG_VALUE can come either after the copy to $rax or the kill of
## $r15, but no later.
# CHECK: $r15 = LEA64r
# CHECK: DBG_VALUE $rax,
# CHECK: RET64

--- |
  ; ModuleID = 'test.cpp'
  source_filename = "test.cpp"
  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-unknown-linux-gnu"
  
  ; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
  define dso_local noundef i64 @_Z3fooxx(i64 noundef %a, i64 noundef %b) local_unnamed_addr !dbg !7 {
  entry:
    call void @llvm.dbg.value(metadata i64 %a, metadata !12, metadata !DIExpression()), !dbg !16
    call void @llvm.dbg.value(metadata i64 %b, metadata !13, metadata !DIExpression()), !dbg !16
    %add = add nsw i64 %b, %a, !dbg !17
    call void @llvm.dbg.value(metadata i64 %add, metadata !14, metadata !DIExpression()), !dbg !16
    %mul17 = sub i64 %a, %b, !dbg !18
    %sub = mul i64 %add, %mul17, !dbg !18
    call void @llvm.dbg.value(metadata i64 %sub, metadata !15, metadata !DIExpression()), !dbg !16
    %add2 = add nsw i64 %sub, %add, !dbg !19
    ret i64 %add2, !dbg !20
  }
  
  ; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
  declare void @llvm.dbg.value(metadata, metadata, metadata)
  
  !llvm.dbg.cu = !{!0}
  !llvm.module.flags = !{!2, !3, !4, !5}
  !llvm.ident = !{!6}
  
  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 44673278e029d7a6f56c8a3177247026b831720f)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
  !1 = !DIFile(filename: "test.cpp", directory: "/home/stozer/dev/llvm-project-build", checksumkind: CSK_MD5, checksum: "1e1c19354b0e967af705e204e8740d56")
  !2 = !{i32 7, !"Dwarf Version", i32 5}
  !3 = !{i32 2, !"Debug Info Version", i32 3}
  !4 = !{i32 1, !"wchar_size", i32 4}
  !5 = !{i32 7, !"uwtable", i32 2}
  !6 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git 44673278e029d7a6f56c8a3177247026b831720f)"}
  !7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooxx", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
  !8 = !DISubroutineType(types: !9)
  !9 = !{!10, !10, !10}
  !10 = !DIBasicType(name: "long long", size: 64, encoding: DW_ATE_signed)
  !11 = !{!12, !13, !14, !15}
  !12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 1, type: !10)
  !13 = !DILocalVariable(name: "b", arg: 2, scope: !7, file: !1, line: 1, type: !10)
  !14 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 2, type: !10)
  !15 = !DILocalVariable(name: "d", scope: !7, file: !1, line: 3, type: !10)
  !16 = !DILocation(line: 0, scope: !7)
  !17 = !DILocation(line: 2, column: 19, scope: !7)
  !18 = !DILocation(line: 3, column: 23, scope: !7)
  !19 = !DILocation(line: 4, column: 12, scope: !7)
  !20 = !DILocation(line: 4, column: 3, scope: !7)

...
---
name:            _Z3fooxx
alignment:       16
exposesReturnsTwice: false
legalized:       false
regBankSelected: false
selected:        false
failedISel:      false
tracksRegLiveness: true
hasWinCFI:       false
callsEHReturn:   false
callsUnwindInit: false
hasEHCatchret:   false
hasEHScopes:     false
hasEHFunclets:   false
failsVerification: false
tracksDebugUserValues: true
registers:       []
liveins:
  - { reg: '$rdi', virtual-reg: '' }
  - { reg: '$rsi', virtual-reg: '' }
frameInfo:
  isFrameAddressTaken: false
  isReturnAddressTaken: false
  hasStackMap:     false
  hasPatchPoint:   false
  stackSize:       0
  offsetAdjustment: 0
  maxAlignment:    1
  adjustsStack:    false
  hasCalls:        false
  stackProtector:  ''
  functionContext: ''
  maxCallFrameSize: 0
  cvBytesOfCalleeSavedRegisters: 0
  hasOpaqueSPAdjustment: false
  hasVAStart:      false
  hasMustTailInVarArgFunc: false
  hasTailCall:     false
  localFrameSize:  0
  savePoint:       ''
  restorePoint:    ''
fixedStack:
- { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default, 
    callee-saved-register: '$r15', callee-saved-restored: true, debug-info-variable: '', 
    debug-info-expression: '', debug-info-location: '' }
stack:           []
callSites:       []
debugValueSubstitutions:
  - { srcinst: 1, srcop: 0, dstinst: 3, dstop: 0, subreg: 0 }
constants:       []
machineFunctionInfo: {}
body:             |
  bb.0.entry:
    liveins: $rdi, $rsi
  
    renamable $rax = LEA64r renamable $rsi, 1, renamable $rdi, 0, $noreg, debug-instr-number 3, debug-location !17
    DBG_VALUE $rax, $noreg, !13, !DIExpression(), debug-location !17
    $r15 = MOV64rr killed $rax, debug-location !16
    renamable $rax = LEA64r renamable $rdi, 1, $noreg, 12, $noreg, debug-location !16
    $rax = MOV64rr killed $r15, debug-location !16
    renamable $r15 = LEA64r renamable $rdi, 1, $noreg, 12, $noreg, debug-location !16
    RET64 $r15, debug-location !20

...