xref: /llvm-project/llvm/test/Transforms/LCSSA/DontInsertDebugValuesForPHIs.ll (revision 8205a68da89123bd29ea253f9c76d440f3afb987)
1; RUN: opt < %s -passes=lcssa -S | FileCheck %s
2
3; This test ensures that LCSSA does not insert dbg.value intrinsics using
4; insertDebugValuesForPHIs() which effectively cause assignments to be
5; re-ordered.
6; See PR48206 for more information.
7
8define dso_local i32 @_Z5lcssab(i1 zeroext %S2) {
9entry:
10  br label %loop.interior
11
12loop.interior:                                    ; preds = %post.if, %entry
13  br i1 %S2, label %if.true, label %if.false
14
15if.true:                                          ; preds = %loop.interior
16  %X1 = add i32 0, 0
17  br label %post.if
18
19if.false:                                         ; preds = %loop.interior
20  %X2 = add i32 0, 1
21  br label %post.if
22
23post.if:                                          ; preds = %if.false, %if.true
24  %X3 = phi i32 [ %X1, %if.true ], [ %X2, %if.false ], !dbg !21
25  call void @llvm.dbg.value(metadata i32 %X3, metadata !9, metadata !DIExpression()), !dbg !21
26  %Y1 = add i32 4, %X3, !dbg !22
27  call void @llvm.dbg.value(metadata i32 %Y1, metadata !9, metadata !DIExpression()), !dbg !22
28  br i1 %S2, label %loop.exit, label %loop.interior, !dbg !23
29
30loop.exit:                                        ; preds = %post.if
31; CHECK: loop.exit:
32; CHECK-NEXT: %X3.lcssa = phi i32
33; CHECK-NOT: call void @llvm.dbg.value
34  %X4 = add i32 3, %X3
35  ret i32 %X4
36}
37
38declare void @llvm.dbg.value(metadata, metadata, metadata)
39
40!llvm.dbg.cu = !{!0}
41!llvm.debugify = !{!3, !4}
42!llvm.module.flags = !{!5}
43
44!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify and Author", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
45!1 = !DIFile(filename: "./testcase.ll", directory: "/")
46!2 = !{}
47!3 = !{i32 11}
48!4 = !{i32 5}
49!5 = !{i32 2, !"Debug Info Version", i32 3}
50!6 = distinct !DISubprogram(name: "_Z5lcssab", linkageName: "_Z5lcssab", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !{!9})
51!7 = !DISubroutineType(types: !2)
52!9 = !DILocalVariable(name: "var", scope: !6, file: !1, line: 3, type: !10)
53!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
54!21 = !DILocation(line: 7, column: 1, scope: !6)
55!22 = !DILocation(line: 8, column: 1, scope: !6)
56!23 = !DILocation(line: 9, column: 1, scope: !6)
57
58