1; RUN: llc -simplify-mir -stop-after=machine-sink < %s -o - | FileCheck %s 2 3; ModuleID = 'test-sink-debug.cpp' 4source_filename = "test-sink-debug.cpp" 5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 6target triple = "x86_64-unknown-linux-gnu" 7 8; double foo(double x, double y, bool c) { 9; double a = x / 3.0; 10; double b = y / 5.0; 11; double ret; 12; 13; if (c) 14; ret = a + 1.0; 15; else 16; ret = b + 1.0; 17; 18; ret = ret + 1.0; 19; 20; return ret; 21; } 22 23; Function Attrs: nounwind readnone uwtable 24define double @_Z3fooddb(double %x, double %y, i1 zeroext %c) local_unnamed_addr !dbg !7 { 25 tail call void @llvm.dbg.value(metadata double %x, metadata !13, metadata !DIExpression()), !dbg !16 26 tail call void @llvm.dbg.value(metadata double %y, metadata !14, metadata !DIExpression()), !dbg !16 27 tail call void @llvm.dbg.value(metadata i1 %c, metadata !15, metadata !DIExpression()), !dbg !16 28 %a = fdiv double %x, 3.000000e+00 29 %b = fdiv double %y, 5.000000e+00, !dbg !17 30 br i1 %c, label %first, label %second 31first: 32 %e = fadd double %a, 1.000000e+00 33 br label %final 34second: 35; CHECK-NOT: debug-location !17 36; CHECK: debug-location !18 37; CHECK-NOT: debug-location !17 38 %f = fadd double %b, 1.000000e+00, !dbg !18 39 br label %final 40final: 41 %cond = phi double [%e, %first], [%f, %second] 42 %d = fadd double %cond, 1.000000e+00 43 ret double %d 44} 45 46 47 48; Function Attrs: nounwind readnone uwtable 49define double @_Z4foo1ddb(double %x, double %y, i1 zeroext %c) local_unnamed_addr !dbg !19 { 50 tail call void @llvm.dbg.value(metadata double %x, metadata !21, metadata !DIExpression()), !dbg !24 51 tail call void @llvm.dbg.value(metadata double %y, metadata !22, metadata !DIExpression()), !dbg !24 52 tail call void @llvm.dbg.value(metadata i1 %c, metadata !23, metadata !DIExpression()), !dbg !24 53 %a = fdiv double %x, 3.000000e+00 54 %b = fdiv double %y, 5.000000e+00, !dbg !25 55 br i1 %c, label %first, label %second 56first: 57 %e = fadd double %a, 1.000000e+00 58 br label %final 59second: 60 %f = fadd double %b, 1.000000e+00, !dbg !25 61; CHECK: debug-location !25 62; CHECK-NEXT: debug-location !25 63 br label %final 64final: 65 %cond = phi double [%e, %first], [%f, %second] 66 %d = fadd double %cond, 1.000000e+00 67 ret double %d 68} 69 70!llvm.dbg.cu = !{!0} 71!llvm.module.flags = !{!3, !4, !5} 72!llvm.ident = !{!6} 73 74attributes #1 = { nounwind readnone speculatable } 75 76; Function Attrs: nounwind readnone speculatable 77declare void @llvm.dbg.value(metadata, metadata, metadata) #1 78 79!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 (trunk 313291)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 80!1 = !DIFile(filename: "test-sink-debug.cpp", directory: "/tmp") 81!2 = !{} 82!3 = !{i32 2, !"Dwarf Version", i32 4} 83!4 = !{i32 2, !"Debug Info Version", i32 3} 84!5 = !{i32 1, !"wchar_size", i32 4} 85!6 = !{!"clang version 6.0.0 (trunk 313291)"} 86!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooddb", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12) 87!8 = !DISubroutineType(types: !9) 88!9 = !{!10, !10, !10, !11} 89!10 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float) 90!11 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean) 91!12 = !{!13, !14, !15} 92!13 = !DILocalVariable(name: "x", arg: 1, scope: !7, file: !1, line: 1, type: !10) 93!14 = !DILocalVariable(name: "y", arg: 2, scope: !7, file: !1, line: 1, type: !10) 94!15 = !DILocalVariable(name: "c", arg: 3, scope: !7, file: !1, line: 1, type: !11) 95!16 = !DILocation(line: 1, column: 19, scope: !7) 96!17 = !DILocation(line: 2, column: 26, scope: !7) 97!18 = !DILocation(line: 3, column: 20, scope: !7) 98!19 = distinct !DISubprogram(name: "foo1", linkageName: "_Z4foo1ddb", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !20) 99!20 = !{!21, !22, !23} 100!21 = !DILocalVariable(name: "x", arg: 1, scope: !19, file: !1, line: 1, type: !10) 101!22 = !DILocalVariable(name: "y", arg: 2, scope: !19, file: !1, line: 1, type: !10) 102!23 = !DILocalVariable(name: "c", arg: 3, scope: !19, file: !1, line: 1, type: !11) 103!24 = !DILocation(line: 1, column: 19, scope: !19) 104!25 = !DILocation(line: 2, column: 26, scope: !19) 105