1 ; RUN: opt -S -passes=simplifycfg < %s | FileCheck %s
3 ; Check that SimplifyCFGPass's performBlockTailMerging() propagates
4 ; the debug location of the old block terminator to the new branch
7 define i32 @foo(i64 %x, i64 %y) !dbg !5 {
8 ; CHECK-LABEL: define i32 @foo(
10 ; CHECK: br label %[[COMMON_RET:.*]], !dbg [[DBG14:![0-9]+]]
12 ; CHECK: br label %[[COMMON_RET]], !dbg [[DBG17:![0-9]+]]
15 %eq = icmp eq i64 %x, %y, !dbg !8
16 br i1 %eq, label %b, label %switch, !dbg !9
18 switch: ; preds = %entry
19 %lt = icmp slt i64 %x, %y, !dbg !10
20 %qux = select i1 %lt, i32 0, i32 2, !dbg !11
21 switch i32 %qux, label %bees [
28 tail call void @bees.a(), !dbg !13
31 b: ; preds = %switch, %switch, %entry
32 %retval = phi i32 [ 0, %switch ], [ 0, %switch ], [ 2, %entry ], !dbg !15
33 tail call void @bees.b(), !dbg !16
34 ret i32 %retval, !dbg !17
36 bees: ; preds = %switch
37 tail call void @llvm.trap(), !dbg !18
42 declare void @llvm.trap()
43 declare void @bees.a()
44 declare void @bees.b()
47 !llvm.debugify = !{!2, !3}
48 !llvm.module.flags = !{!4}
50 ; CHECK: [[DBG14]] = !DILocation(line: 7,
51 ; CHECK: [[DBG17]] = !DILocation(line: 10,
53 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
54 !1 = !DIFile(filename: "main.ll", directory: "/")
57 !4 = !{i32 2, !"Debug Info Version", i32 3}
58 !5 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
59 !6 = !DISubroutineType(types: !7)
61 !8 = !DILocation(line: 1, column: 1, scope: !5)
62 !9 = !DILocation(line: 2, column: 1, scope: !5)
63 !10 = !DILocation(line: 3, column: 1, scope: !5)
64 !11 = !DILocation(line: 4, column: 1, scope: !5)
65 !12 = !DILocation(line: 5, column: 1, scope: !5)
66 !13 = !DILocation(line: 6, column: 1, scope: !5)
67 !14 = !DILocation(line: 7, column: 1, scope: !5)
68 !15 = !DILocation(line: 8, column: 1, scope: !5)
69 !16 = !DILocation(line: 9, column: 1, scope: !5)
70 !17 = !DILocation(line: 10, column: 1, scope: !5)
71 !18 = !DILocation(line: 11, column: 1, scope: !5)
72 !19 = !DILocation(line: 12, column: 1, scope: !5)