xref: /llvm-project/llvm/test/CodeGen/X86/machinesink-merge-debuginfo.ll (revision 1339f74b8a3a1fb9965aa36df23362d19051ef03)
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; CHECK: fdiv {{.*}} !dbg [[NO:![0-9]+]]
23; CHECK: fadd {{.*}} !dbg [[YES:![0-9]+]]
24; CHECK: fdiv {{.*}} !dbg [[TAG:![0-9]+]]
25
26; Function Attrs: nounwind readnone uwtable
27define double @_Z3fooddb(double %x, double %y, i1 zeroext %c) local_unnamed_addr !dbg !7 {
28  tail call void @llvm.dbg.value(metadata double %x, metadata !13, metadata !DIExpression()), !dbg !16
29  tail call void @llvm.dbg.value(metadata double %y, metadata !14, metadata !DIExpression()), !dbg !16
30  tail call void @llvm.dbg.value(metadata i1 %c, metadata !15, metadata !DIExpression()), !dbg !16
31  %a = fdiv double %x, 3.000000e+00
32  %b = fdiv double %y, 5.000000e+00, !dbg !17
33  br i1 %c, label %first, label %second
34first:
35  %e = fadd double %a, 1.000000e+00
36  br label %final
37second:
38  %f = fadd double %b, 1.000000e+00, !dbg !18
39
40; CHECK-NOT: debug-location [[NO]]
41; CHECK: debug-location [[YES]]
42; CHECK-NOT: debug-location [[NO]]
43  br label %final
44final:
45  %cond = phi double [%e, %first], [%f, %second]
46  %d = fadd double %cond, 1.000000e+00
47  ret double %d
48}
49
50
51
52; Function Attrs: nounwind readnone uwtable
53define double @_Z4foo1ddb(double %x, double %y, i1 zeroext %c) local_unnamed_addr !dbg !19 {
54  tail call void @llvm.dbg.value(metadata double %x, metadata !21, metadata !DIExpression()), !dbg !24
55  tail call void @llvm.dbg.value(metadata double %y, metadata !22, metadata !DIExpression()), !dbg !24
56  tail call void @llvm.dbg.value(metadata i1 %c, metadata !23, metadata !DIExpression()), !dbg !24
57  %a = fdiv double %x, 3.000000e+00
58  %b = fdiv double %y, 5.000000e+00, !dbg !25
59  br i1 %c, label %first, label %second
60first:
61  %e = fadd double %a, 1.000000e+00
62  br label %final
63second:
64  %f = fadd double %b, 1.000000e+00, !dbg !25
65; CHECK: debug-location [[TAG]]
66; CHECK-NEXT: debug-location [[TAG]]
67  br label %final
68final:
69  %cond = phi double [%e, %first], [%f, %second]
70  %d = fadd double %cond, 1.000000e+00
71  ret double %d
72}
73
74!llvm.dbg.cu = !{!0}
75!llvm.module.flags = !{!3, !4, !5}
76!llvm.ident = !{!6}
77
78attributes #1 = { nounwind readnone speculatable }
79
80; Function Attrs: nounwind readnone speculatable
81declare void @llvm.dbg.value(metadata, metadata, metadata) #1
82
83!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)
84!1 = !DIFile(filename: "test-sink-debug.cpp", directory: "/tmp")
85!2 = !{}
86!3 = !{i32 2, !"Dwarf Version", i32 4}
87!4 = !{i32 2, !"Debug Info Version", i32 3}
88!5 = !{i32 1, !"wchar_size", i32 4}
89!6 = !{!"clang version 6.0.0 (trunk 313291)"}
90!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)
91!8 = !DISubroutineType(types: !9)
92!9 = !{!10, !10, !10, !11}
93!10 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
94!11 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)
95!12 = !{!13, !14, !15}
96!13 = !DILocalVariable(name: "x", arg: 1, scope: !7, file: !1, line: 1, type: !10)
97!14 = !DILocalVariable(name: "y", arg: 2, scope: !7, file: !1, line: 1, type: !10)
98!15 = !DILocalVariable(name: "c", arg: 3, scope: !7, file: !1, line: 1, type: !11)
99!16 = !DILocation(line: 1, column: 19, scope: !7)
100!17 = !DILocation(line: 2, column: 26, scope: !7)
101!18 = !DILocation(line: 3, column: 20, scope: !7)
102!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)
103!20 = !{!21, !22, !23}
104!21 = !DILocalVariable(name: "x", arg: 1, scope: !19, file: !1, line: 1, type: !10)
105!22 = !DILocalVariable(name: "y", arg: 2, scope: !19, file: !1, line: 1, type: !10)
106!23 = !DILocalVariable(name: "c", arg: 3, scope: !19, file: !1, line: 1, type: !11)
107!24 = !DILocation(line: 1, column: 19, scope: !19)
108!25 = !DILocation(line: 2, column: 26, scope: !19)
109