blob: cf65b190947ff588b2f470d2381552920c5acbf5 [file] [log] [blame]
Adrian Prantl7bc1b282017-09-11 22:59:45 +00001; RUN: llc -mtriple=x86_64-linux-gnu -filetype=obj -o - %s | llvm-dwarfdump -debug-loc - | FileCheck %s
Robert Lougher10f740d2017-08-03 11:54:02 +00002
3; The test inlines the function F four times, with each inlined variable for
4; "i4" sharing the same virtual register. This means the live interval of the
5; register spans all of the inlined callsites, extending beyond the lexical
6; scope of each. Later during register allocation the live interval is split
7; into multiple intervals. Check that this does not generate multiple entries
8; within the debug location (see PR33730).
9;
10; Generated from:
11;
12; extern int foobar(int, int, int, int, int);
Jonas Devlieghere6f24c872018-01-16 11:17:57 +000013;
Robert Lougher10f740d2017-08-03 11:54:02 +000014; int F(int i1, int i2, int i3, int i4, int i5) {
15; return foobar(i1, i2, i3, i4, i5);
16; }
Jonas Devlieghere6f24c872018-01-16 11:17:57 +000017;
Robert Lougher10f740d2017-08-03 11:54:02 +000018; int foo(int a, int b, int c, int d, int e) {
19; return F(a,b,c,d,e) +
20; F(a,b,c,d,e) +
21; F(a,b,c,d,e) +
22; F(a,b,c,d,e);
23; }
24
Reid Klecknera0587362017-08-29 21:41:21 +000025; CHECK: .debug_loc contents:
26; CHECK-NEXT: 0x00000000:
Adrian Prantl93faeec2017-11-08 18:27:13 +000027; We currently emit an entry for the function prologue, too, which could be optimized away.
Jeremy Morse41206b62020-02-04 14:19:42 +000028; CHECK: (0x0000000000000018, 0x0000000000000072): DW_OP_reg3 RBX
Adrian Prantl93faeec2017-11-08 18:27:13 +000029; We should only have one entry inside the function.
Reid Klecknera0587362017-08-29 21:41:21 +000030; CHECK-NOT: :
Robert Lougher10f740d2017-08-03 11:54:02 +000031
32declare i32 @foobar(i32, i32, i32, i32, i32)
33
34define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) !dbg !25 {
35entry:
36 tail call void @llvm.dbg.value(metadata i32 %d, i64 0, metadata !15, metadata !17) #3, !dbg !41
37 %call.i = tail call i32 @foobar(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) #3, !dbg !43
38 %call.i21 = tail call i32 @foobar(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) #3, !dbg !50
39 %add = add nsw i32 %call.i21, %call.i, !dbg !51
40 %call.i22 = tail call i32 @foobar(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) #3, !dbg !58
41 %add3 = add nsw i32 %add, %call.i22, !dbg !59
42 %call.i23 = tail call i32 @foobar(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) #3, !dbg !66
43 %add5 = add nsw i32 %add3, %call.i23, !dbg !67
44 ret i32 %add5, !dbg !68
45}
46
47declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
48
49!llvm.dbg.cu = !{!0}
50!llvm.module.flags = !{!3, !4, !5}
51!llvm.ident = !{!6}
52
53!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk 308976)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
54!1 = !DIFile(filename: "foo.c", directory: "")
55!2 = !{}
56!3 = !{i32 2, !"Dwarf Version", i32 4}
57!4 = !{i32 2, !"Debug Info Version", i32 3}
58!5 = !{i32 1, !"wchar_size", i32 4}
59!6 = !{!"clang version 6.0.0 (trunk 308976)"}
Shiva Chen2c864552018-05-09 02:40:45 +000060!7 = distinct !DISubprogram(name: "F", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
Robert Lougher10f740d2017-08-03 11:54:02 +000061!8 = !DISubroutineType(types: !9)
62!9 = !{!10, !10, !10, !10, !10, !10}
63!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
64!11 = !{!15}
65!15 = !DILocalVariable(name: "i4", arg: 4, scope: !7, file: !1, line: 3, type: !10)
66!17 = !DIExpression()
Shiva Chen2c864552018-05-09 02:40:45 +000067!25 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 7, type: !8, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !26)
Robert Lougher10f740d2017-08-03 11:54:02 +000068!26 = !{}
69!38 = distinct !DILocation(line: 8, column: 10, scope: !25)
70!41 = !DILocation(line: 3, column: 35, scope: !7, inlinedAt: !38)
71!43 = !DILocation(line: 4, column: 10, scope: !7, inlinedAt: !38)
72!45 = distinct !DILocation(line: 9, column: 10, scope: !25)
73!50 = !DILocation(line: 4, column: 10, scope: !7, inlinedAt: !45)
74!51 = !DILocation(line: 8, column: 23, scope: !25)
75!53 = distinct !DILocation(line: 10, column: 10, scope: !25)
76!58 = !DILocation(line: 4, column: 10, scope: !7, inlinedAt: !53)
77!59 = !DILocation(line: 9, column: 23, scope: !25)
78!61 = distinct !DILocation(line: 11, column: 10, scope: !25)
79!66 = !DILocation(line: 4, column: 10, scope: !7, inlinedAt: !61)
80!67 = !DILocation(line: 10, column: 23, scope: !25)
81!68 = !DILocation(line: 8, column: 3, scope: !25)