1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=simplifycfg < %s | FileCheck %s
3 ;; Test that we correct clone debug-info when folding in
4 ;; FoldCondBranchOnValueKnownInPredecessorImpl. There should be two paths
5 ;; through this program, assigning [0 1 2 3 4 5 6 7] to the variable down
6 ;; one path, and [0 1 2 3 6 7] down the other.
10 declare void @use.i1(i1)
11 declare void @use.i32(i32)
12 declare void @llvm.dbg.value(metadata, metadata, metadata)
14 define void @test_phi_extra_use(i1 %c) {
15 ; CHECK-LABEL: @test_phi_extra_use(
16 ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
18 ; CHECK-NEXT: call void @foo()
19 ; CHECK-NEXT: #dbg_value(i32 0, [[META7:![0-9]+]], !DIExpression(), [[META13:![0-9]+]])
20 ; CHECK-NEXT: #dbg_value(i32 1, [[META7]], !DIExpression(), [[META13]])
21 ; CHECK-NEXT: call void @use.i1(i1 true)
22 ; CHECK-NEXT: #dbg_value(i32 2, [[META7]], !DIExpression(), [[META13]])
23 ; CHECK-NEXT: #dbg_value(i32 3, [[META7]], !DIExpression(), [[META13]])
24 ; CHECK-NEXT: call void @foo()
25 ; CHECK-NEXT: br label [[JOIN2:%.*]]
27 ; CHECK-NEXT: call void @bar()
28 ; CHECK-NEXT: #dbg_value(i32 0, [[META7]], !DIExpression(), [[META13]])
29 ; CHECK-NEXT: #dbg_value(i32 1, [[META7]], !DIExpression(), [[META13]])
30 ; CHECK-NEXT: call void @use.i1(i1 false)
31 ; CHECK-NEXT: #dbg_value(i32 2, [[META7]], !DIExpression(), [[META13]])
32 ; CHECK-NEXT: #dbg_value(i32 3, [[META7]], !DIExpression(), [[META13]])
33 ; CHECK-NEXT: #dbg_value(i32 4, [[META7]], !DIExpression(), [[META13]])
34 ; CHECK-NEXT: #dbg_value(i32 5, [[META7]], !DIExpression(), [[META13]])
35 ; CHECK-NEXT: call void @bar()
36 ; CHECK-NEXT: br label [[JOIN2]]
38 ; CHECK-NEXT: #dbg_value(i32 6, [[META7]], !DIExpression(), [[META13]])
39 ; CHECK-NEXT: #dbg_value(i32 7, [[META7]], !DIExpression(), [[META13]])
40 ; CHECK-NEXT: ret void, !dbg [[META13]]
42 br i1 %c, label %if, label %else
53 %c2 = phi i1 [ true, %if ], [ false, %else ]
54 call void @llvm.dbg.value(metadata i32 0, metadata !12, metadata !DIExpression()), !dbg !15
55 call void @llvm.dbg.value(metadata i32 1, metadata !12, metadata !DIExpression()), !dbg !15
56 call void @use.i1(i1 %c2)
57 call void @llvm.dbg.value(metadata i32 2, metadata !12, metadata !DIExpression()), !dbg !15
58 call void @llvm.dbg.value(metadata i32 3, metadata !12, metadata !DIExpression()), !dbg !15
59 br i1 %c2, label %if2, label %else2
66 call void @llvm.dbg.value(metadata i32 4, metadata !12, metadata !DIExpression()), !dbg !15
67 call void @llvm.dbg.value(metadata i32 5, metadata !12, metadata !DIExpression()), !dbg !15
72 call void @llvm.dbg.value(metadata i32 6, metadata !12, metadata !DIExpression()), !dbg !15
73 call void @llvm.dbg.value(metadata i32 7, metadata !12, metadata !DIExpression()), !dbg !15
78 !llvm.module.flags = !{!3, !4, !5}
81 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
82 !1 = !DIFile(filename: ".", directory: "/foo")
84 !3 = !{i32 2, !"Dwarf Version", i32 4}
85 !4 = !{i32 2, !"Debug Info Version", i32 3}
86 !5 = !{i32 1, !"wchar_size", i32 4}
88 !7 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
89 !8 = !DISubroutineType(types: !9)
91 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
93 !12 = !DILocalVariable(name: "getdirt", arg: 1, scope: !7, file: !1, line: 1, type: !10)
94 !15 = !DILocation(line: 1, column: 15, scope: !7)