File: debuginfo-sink.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (111 lines) | stat: -rw-r--r-- 4,940 bytes parent folder | download | duplicates (6)
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
; RUN: opt  %s -instcombine -S | FileCheck %s

; Test sinking of dbg.values when instcombine sinks associated instructions.

declare void @llvm.dbg.value(metadata, metadata, metadata)

; This GEP is sunk, but can be folded into a DIExpression. Check that it
; gets folded. The dbg.value should be duplicated in the block its sunk
; into, to maximise liveness.
;
; CHECK-LABEL: define i32 @foo(i32*
; CHECK:       call void @llvm.dbg.value(metadata i32* %a, metadata !{{[0-9]+}},
; CHECK-SAME:  metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value))
; CHECK-NEXT:  br label %sink1

define i32 @foo(i32 *%a) !dbg !7 {
entry:
  %gep = getelementptr i32, i32 *%a, i32 1
  call void @llvm.dbg.value(metadata i32 *%gep, metadata !16, metadata !12), !dbg !15
  br label %sink1

sink1:
; CHECK-LABEL: sink1:
; CHECK:       call void @llvm.dbg.value(metadata i32* %gep,
; CHECK-SAME:                    metadata !{{[0-9]+}}, metadata !DIExpression())
; CHECK-NEXT:  load
  %0 = load i32, i32* %gep, align 4, !dbg !15
  ret i32 %0, !dbg !15
}

; In this example the GEP cannot (yet) be salvaged. Check that not only is the
; dbg.value sunk, but an undef dbg.value is left to terminate any earlier
; value range.

; CHECK-LABEL: define i32 @bar(
; CHECK:       call void @llvm.dbg.value(metadata <vscale x 4 x i32>* undef,
; CHECK-NEXT:  br label %sink2

define i32 @bar(<vscale x 4 x i32>* %a, i32 %b) !dbg !70 {
entry:
  %gep = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* %a, i32 %b
  call void @llvm.dbg.value(metadata <vscale x 4 x i32>* %gep, metadata !73, metadata !12), !dbg !74
  br label %sink2

sink2:
; CHECK-LABEL: sink2:
; CHECK:       call void @llvm.dbg.value(metadata <vscale x 4 x i32>* %gep,
; CHECK-SAME:                    metadata !{{[0-9]+}}, metadata !DIExpression())
; CHECK-NEXT:  load
; CHECK-NEXT:  extractelement
; CHECK-NEXT:  ret
  %0 = load <vscale x 4 x i32>, <vscale x 4 x i32>* %gep
  %extract = extractelement <vscale x 4 x i32> %0, i32 1
  ret i32 %extract
}

; This GEP is sunk, and has multiple debug uses in the same block. Check that
; only the last use is cloned into the sunk block, and that both of the
; original dbg.values are salvaged.
;
; CHECK-LABEL: define i32 @baz(i32*
; CHECK:       call void @llvm.dbg.value(metadata i32* %a, metadata !{{[0-9]+}},
; CHECK-SAME:  metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value))
; CHECK-NEXT:  call void @llvm.dbg.value(metadata i32* %a, metadata !{{[0-9]+}},
; CHECK-SAME:  metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_plus_uconst, 5, DW_OP_stack_value))
; CHECK-NEXT:  br label %sink1

define i32 @baz(i32 *%a) !dbg !80 {
entry:
  %gep = getelementptr i32, i32 *%a, i32 1
  call void @llvm.dbg.value(metadata i32 *%gep, metadata !83, metadata !12), !dbg !84
  call void @llvm.dbg.value(metadata i32 *%gep, metadata !83, metadata !DIExpression(DW_OP_plus_uconst, 5)), !dbg !85
  br label %sink1

sink1:
; CHECK-LABEL: sink1:
; CHECK:       call void @llvm.dbg.value(metadata i32* %gep,
; CHECK-SAME:  metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_plus_uconst, 5))
; CHECK-NEXT:  load
  %0 = load i32, i32* %gep, align 4, !dbg !85
  ret i32 %0, !dbg !85
}

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}

!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
!1 = !DIFile(filename: "a.c", directory: ".")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"PIC Level", i32 2}
!6 = !{!"clang"}
!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
!8 = !DISubroutineType(types: !9)
!9 = !{!10, !10}
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!11 = !DILocalVariable(name: "j", scope: !7, file: !1, line: 2, type: !10)
!12 = !DIExpression()
!15 = !DILocation(line: 5, column: 3, scope: !7)
!16 = !DILocalVariable(name: "h", scope: !7, file: !1, line: 4, type: !10)
!70 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !71, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
!71 = !DISubroutineType(types: !72)
!72 = !{!10, !10, !10}
!73 = !DILocalVariable(name: "k", scope: !70, file: !1, line: 2, type: !10)
!74 = !DILocation(line: 5, column: 3, scope: !70)
!80 = distinct !DISubprogram(name: "baz", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
!83 = !DILocalVariable(name: "l", scope: !80, file: !1, line: 2, type: !10)
!84 = !DILocation(line: 5, column: 3, scope: !80)
!85 = !DILocation(line: 6, column: 3, scope: !80)