1; RUN: opt -S -passes=simplifycfg < %s | FileCheck %s 2 3; Check that SimplifyCFGPass's performBlockTailMerging() propagates 4; the debug location of the old block terminator to the new branch 5; instruction. 6 7define i32 @foo(i64 %x, i64 %y) !dbg !5 { 8; CHECK-LABEL: define i32 @foo( 9; CHECK: a: 10; CHECK: br label %[[COMMON_RET:.*]], !dbg [[DBG14:![0-9]+]] 11; CHECK: b: 12; CHECK: br label %[[COMMON_RET]], !dbg [[DBG17:![0-9]+]] 13; 14entry: 15 %eq = icmp eq i64 %x, %y, !dbg !8 16 br i1 %eq, label %b, label %switch, !dbg !9 17 18switch: ; 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 [ 22 i32 0, label %a 23 i32 1, label %b 24 i32 2, label %b 25 ], !dbg !12 26 27a: ; preds = %switch 28 tail call void @bees.a(), !dbg !13 29 ret i32 1, !dbg !14 30 31b: ; 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 35 36bees: ; preds = %switch 37 tail call void @llvm.trap(), !dbg !18 38 unreachable, !dbg !19 39} 40 41 42declare void @llvm.trap() 43declare void @bees.a() 44declare void @bees.b() 45 46!llvm.dbg.cu = !{!0} 47!llvm.debugify = !{!2, !3} 48!llvm.module.flags = !{!4} 49 50; CHECK: [[DBG14]] = !DILocation(line: 7, 51; CHECK: [[DBG17]] = !DILocation(line: 10, 52 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: "/") 55!2 = !{i32 12} 56!3 = !{i32 0} 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) 60!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) 73