1
1
; RUN: opt -S -lcssa < %s | FileCheck %s
2
2
3
- target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4
- target triple = "x86_64-unknown-linux-gnu"
5
-
6
3
; Reproducer for PR39019.
7
4
;
8
- ; Verify that the llvm.dbg.value in the %for.cond.cleanup2 block is rewritten
9
- ; to use the PHI node for %add that is created by LCSSA.
5
+ ; Verify that the llvm.dbg.values are updated to use the PHI nodes inserted by
6
+ ; LCSSA.
10
7
11
- ; CHECK-LABEL: for.cond.cleanup2:
12
- ; CHECK-NEXT: [[PN:%[^ ]*]] = phi i32 [ %add.lcssa, %for.cond.cleanup1 ]
13
- ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[PN]], metadata [[VAR:![0-9]+]], metadata !DIExpression())
14
- ; CHECK-NEXT: call void @bar(i32 [[PN]])
8
+ ; For the test case @single_exit, we can rewrite all llvm.dbg.value calls
9
+ ; to use the inserted PHI.
15
10
16
- ; CHECK-LABEL: for.body:
11
+ ; CHECK-LABEL: @single_exit(
12
+
13
+ ; CHECK-LABEL: inner.body:
17
14
; CHECK: %add = add nsw i32 0, 2
18
- ; CHECK: call void @llvm.dbg.value(metadata i32 %add, metadata [[VAR]], metadata !DIExpression())
15
+ ; CHECK: call void @llvm.dbg.value(metadata i32 %add, metadata [[VAR:![0-9]+ ]], metadata !DIExpression())
19
16
20
- ; CHECK: [[VAR]] = !DILocalVariable(name: "sum",
21
17
22
- ; Function Attrs: nounwind
23
- define void @foo () #0 !dbg !6 {
18
+ ; CHECK-LABEL: outer.exit:
19
+ ; CHECK-NEXT: [[PN:%[^ ]*]] = phi i32 [ %add.lcssa, %outer.latch ]
20
+ ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[PN]], metadata [[VAR]], metadata !DIExpression())
21
+ ; CHECK-NEXT: call void @bar(i32 [[PN]])
22
+
23
+ ; CHECK-LABEL: exit:
24
+ ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[PN]], metadata [[VAR]], metadata !DIExpression())
25
+
26
+ define void @single_exit () !dbg !6 {
24
27
entry:
25
- br label %for.cond.preheader , !dbg !12
28
+ br label %outer.header , !dbg !12
26
29
27
- for.cond.preheader : ; preds = %for.cond.cleanup1 , %entry
28
- br label %for .body , !dbg !12
30
+ outer.header : ; preds = %outer.latch , %entry
31
+ br label %inner .body , !dbg !12
29
32
30
- for.cond.cleanup2: ; preds = %for.cond.cleanup1
33
+ inner.body: ; preds = %inner.body, %outer.header
34
+ %add = add nsw i32 0 , 2 , !dbg !12
31
35
call void @llvm.dbg.value (metadata i32 %add , metadata !9 , metadata !DIExpression ()), !dbg !12
32
- tail call void @bar (i32 %add ) #0 , !dbg !12
33
- ret void , !dbg !12
36
+ br i1 false , label %inner.body , label %inner.exit , !dbg !12
34
37
35
- for.cond.cleanup1 : ; preds = %for .body
36
- br i1 false , label %for.cond.preheader , label %for.cond.cleanup2 , !dbg !12
38
+ inner.exit : ; preds = %inner .body
39
+ br label %outer.latch
37
40
38
- for.body: ; preds = %for.body, %for.cond.preheader
39
- %add = add nsw i32 0 , 2 , !dbg !12
41
+ outer.latch: ; preds = %inner.exit
42
+ br i1 false , label %outer.header , label %outer.exit , !dbg !12
43
+
44
+ outer.exit: ; preds = %outer.latch
45
+ call void @llvm.dbg.value (metadata i32 %add , metadata !9 , metadata !DIExpression ()), !dbg !12
46
+ tail call void @bar (i32 %add ), !dbg !12
47
+ br label %exit
48
+
49
+ exit: ; preds = %outer.exit
40
50
call void @llvm.dbg.value (metadata i32 %add , metadata !9 , metadata !DIExpression ()), !dbg !12
41
- br i1 false , label %for.body , label %for.cond.cleanup1 , !dbg !12
51
+ ret void , !dbg !12
42
52
}
43
53
44
- ; Function Attrs: nounwind
45
- declare void @bar (i32 ) #0
54
+ ; For the test case @multi_exit, we cannot update the llvm.dbg.value call in exit,
55
+ ; because LCSSA did not insert a PHI node in %exit, as there is no non-debug
56
+ ; use.
57
+
58
+ ; CHECK-LABEL: @multi_exit()
59
+
60
+ ; CHECK-LABEL: for.header:
61
+ ; CHECK-NEXT: %add = add nsw i32 0, 2
62
+ ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %add, metadata [[VAR2:![0-9]+]], metadata !DIExpression())
63
+
64
+ ; CHECK-LABEL: for.exit1:
65
+ ; CHECK-NEXT: [[PN1:%[^ ]*]] = phi i32 [ %add, %for.header ]
66
+ ; CHECK-NEXT: br label %for.exit1.succ
67
+
68
+ ; CHECK-LABEL: for.exit1.succ:
69
+ ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[PN1]], metadata [[VAR2]], metadata !DIExpression())
70
+ ; CHECK-NEXT: call void @bar(i32 [[PN1]])
71
+
72
+ ; CHECK-LABEL: for.exit2:
73
+ ; CHECK-NEXT: [[PN2:%[^ ]*]] = phi i32 [ %add, %for.latch ]
74
+ ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[PN2]], metadata [[VAR2]], metadata !DIExpression())
75
+ ; CHECK-NEXT: call void @bar(i32 [[PN2]])
76
+
77
+ ; CHECK-LABEL: exit:
78
+ ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %add, metadata [[VAR2]], metadata !DIExpression())
79
+
80
+ define void @multi_exit () !dbg !13 {
81
+ entry:
82
+ br label %for.header , !dbg !14
83
+
84
+ for.header: ; preds = %for.latch, %entry
85
+ %add = add nsw i32 0 , 2 , !dbg !14
86
+ call void @llvm.dbg.value (metadata i32 %add , metadata !16 , metadata !DIExpression ()), !dbg !14
87
+ br i1 false , label %for.latch , label %for.exit1 , !dbg !14
88
+
89
+ for.latch: ; preds = %for.header
90
+ br i1 false , label %for.header , label %for.exit2 , !dbg !14
91
+
92
+ for.exit1: ; preds = %for.header
93
+ br label %for.exit1.succ
94
+
95
+ for.exit1.succ: ; preds = %for.exit1
96
+ call void @llvm.dbg.value (metadata i32 %add , metadata !16 , metadata !DIExpression ()), !dbg !14
97
+ tail call void @bar (i32 %add ), !dbg !14
98
+ br label %exit
99
+
100
+ for.exit2: ; preds = %for.latch
101
+ call void @llvm.dbg.value (metadata i32 %add , metadata !16 , metadata !DIExpression ()), !dbg !14
102
+ tail call void @bar (i32 %add ), !dbg !14
103
+ br label %exit
104
+
105
+ exit: ; preds = %for.exit2, %for.exit1.succ
106
+ call void @llvm.dbg.value (metadata i32 %add , metadata !16 , metadata !DIExpression ()), !dbg !14
107
+ ret void , !dbg !14
108
+ }
109
+
110
+ ; CHECK: [[VAR]] = !DILocalVariable(name: "sum",
111
+ ; CHECK: [[VAR2]] = !DILocalVariable(name: "sum2",
46
112
47
- ; Function Attrs: nounwind readnone speculatable
48
- declare void @llvm.dbg.value (metadata , metadata , metadata ) #1
113
+ declare void @bar (i32 )
49
114
50
- attributes #0 = { nounwind }
51
- attributes #1 = { nounwind readnone speculatable }
115
+ declare void @llvm.dbg.value (metadata , metadata , metadata )
52
116
53
117
!llvm.dbg.cu = !{!0 }
54
118
!llvm.module.flags = !{!3 , !4 }
@@ -60,10 +124,14 @@ attributes #1 = { nounwind readnone speculatable }
60
124
!3 = !{i32 2 , !"Dwarf Version" , i32 4 }
61
125
!4 = !{i32 2 , !"Debug Info Version" , i32 3 }
62
126
!5 = !{!"clang version 8.0.0" }
63
- !6 = distinct !DISubprogram (name: "foo" , scope: !1 , file: !1 , line: 10 , type: !7 , isLocal: false , isDefinition: true , scopeLine: 10 , isOptimized: true , unit: !0 , retainedNodes: !8 )
127
+ !6 = distinct !DISubprogram (name: "foo" , scope: !1 , file: !1 , line: 10 , type: !7 , scopeLine: 10 , spFlags: DISPFlagDefinition | DISPFlagOptimized , unit: !0 , retainedNodes: !8 )
64
128
!7 = !DISubroutineType (types: !2 )
65
129
!8 = !{!9 }
66
130
!9 = !DILocalVariable (name: "sum" , scope: !10 , file: !1 , line: 11 , type: !11 )
67
131
!10 = !DILexicalBlockFile (scope: !6 , file: !1 , discriminator: 0 )
68
132
!11 = !DIBasicType (name: "int" , size: 32 , encoding: DW_ATE_signed)
69
133
!12 = !DILocation (line: 0 , scope: !10 )
134
+ !13 = distinct !DISubprogram (name: "multi_exit" , scope: !1 , file: !1 , line: 10 , type: !7 , scopeLine: 10 , spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0 , retainedNodes: !8 )
135
+ !14 = !DILocation (line: 0 , scope: !15 )
136
+ !15 = !DILexicalBlockFile (scope: !13 , file: !1 , discriminator: 0 )
137
+ !16 = !DILocalVariable (name: "sum2" , scope: !15 , file: !1 , line: 11 , type: !11 )
0 commit comments