blob: c42b8e5145072c6a167b68a132e7e2e97333b0d2 [file] [log] [blame]
Adrian Prantl7bc1b282017-09-11 22:59:45 +00001; RUN: llc -filetype=obj -o - < %s | llvm-dwarfdump - --debug-loc | FileCheck %s
Keno Fischer6c1e47a2016-02-03 21:13:33 +00002;
3; Created using clang -g -O3 from:
4; struct S0 {
5; short f0;
6; int f3;
7; } a;
8; void fn1(short p1) {
9; struct S0 b, c = {3};
10; b.f3 = p1;
11; a = b = c;
12; }
Jonas Devlieghere6f24c872018-01-16 11:17:57 +000013;
Keno Fischer6c1e47a2016-02-03 21:13:33 +000014; int main() { return 0; }
15;
16; This is similar to the bug in test/DebugInfo/ARM/PR26163.ll, except that there is an
17; extra non-overlapping range first. Thus, we make sure that the backend actually looks
18; at all expressions when determining whether to merge ranges, not just the first one.
David Stenberg33b192d2019-01-09 09:58:59 +000019; AS in 26163, we only expect one range as the first one is zero sized.
Keno Fischer6c1e47a2016-02-03 21:13:33 +000020;
21;
David Stenberg33b192d2019-01-09 09:58:59 +000022; CHECK: [0x0000000000000000, 0x000000000000000f): DW_OP_lit3, DW_OP_piece 0x4, DW_OP_lit0, DW_OP_piece 0x4
Keno Fischer6c1e47a2016-02-03 21:13:33 +000023
Adrian Prantl1eadba12016-12-22 00:45:21 +000024source_filename = "test/DebugInfo/X86/PR26148.ll"
Keno Fischer6c1e47a2016-02-03 21:13:33 +000025target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
26target triple = "x86_64-apple-macosx10.11.0"
27
28%struct.S0 = type { i16, i32 }
29
Adrian Prantl1eadba12016-12-22 00:45:21 +000030@a = common global %struct.S0 zeroinitializer, align 4, !dbg !0
Keno Fischer6c1e47a2016-02-03 21:13:33 +000031
Adrian Prantl1eadba12016-12-22 00:45:21 +000032; Function Attrs: nounwind readnone
33declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
Keno Fischer6c1e47a2016-02-03 21:13:33 +000034
Adrian Prantl1eadba12016-12-22 00:45:21 +000035; Function Attrs: nounwind readnone
Adrian Prantlabe04752017-07-28 20:21:02 +000036declare void @llvm.dbg.value(metadata, metadata, metadata) #0
Adrian Prantl1eadba12016-12-22 00:45:21 +000037
David Stenberg33b192d2019-01-09 09:58:59 +000038define void @fn1(i16 signext %p1) !dbg !16 {
Keno Fischer6c1e47a2016-02-03 21:13:33 +000039entry:
Adrian Prantlabe04752017-07-28 20:21:02 +000040 tail call void @llvm.dbg.value(metadata i16 %p1, metadata !20, metadata !23), !dbg !24
Adrian Prantl1eadba12016-12-22 00:45:21 +000041 tail call void @llvm.dbg.declare(metadata %struct.S0* undef, metadata !21, metadata !23), !dbg !25
42 tail call void @llvm.dbg.declare(metadata %struct.S0* undef, metadata !22, metadata !23), !dbg !26
Adrian Prantlabe04752017-07-28 20:21:02 +000043 tail call void @llvm.dbg.value(metadata i32 3, metadata !22, metadata !27), !dbg !26
44 tail call void @llvm.dbg.value(metadata i32 0, metadata !22, metadata !28), !dbg !26
45 tail call void @llvm.dbg.value(metadata i16 %p1, metadata !21, metadata !29), !dbg !25
46 tail call void @llvm.dbg.value(metadata i32 3, metadata !21, metadata !27), !dbg !25
47 tail call void @llvm.dbg.value(metadata i32 0, metadata !21, metadata !28), !dbg !25
Adrian Prantl1eadba12016-12-22 00:45:21 +000048 store i32 3, i32* bitcast (%struct.S0* @a to i32*), align 4, !dbg !30
49 store i32 0, i32* getelementptr inbounds (%struct.S0, %struct.S0* @a, i64 0, i32 1), align 4, !dbg !30
50 ret void, !dbg !31
Keno Fischer6c1e47a2016-02-03 21:13:33 +000051}
52
Adrian Prantl1eadba12016-12-22 00:45:21 +000053define i32 @main() !dbg !32 {
Keno Fischer6c1e47a2016-02-03 21:13:33 +000054entry:
55 ret i32 0, !dbg !35
56}
57
Adrian Prantl1eadba12016-12-22 00:45:21 +000058attributes #0 = { nounwind readnone }
Keno Fischer6c1e47a2016-02-03 21:13:33 +000059
Adrian Prantl1eadba12016-12-22 00:45:21 +000060!llvm.dbg.cu = !{!2}
61!llvm.module.flags = !{!12, !13, !14}
62!llvm.ident = !{!15}
63
Adrian Prantl05782212017-08-30 18:06:51 +000064!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
Adrian Prantl1eadba12016-12-22 00:45:21 +000065!1 = !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 4, type: !6, isLocal: false, isDefinition: true)
James Y Knight693d39d2019-01-15 16:18:52 +000066!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.9.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
Adrian Prantl1eadba12016-12-22 00:45:21 +000067!3 = !DIFile(filename: "small.c", directory: "/Users/kfischer/Projects/clangbug")
68!4 = !{}
69!5 = !{!0}
70!6 = !DICompositeType(tag: DW_TAG_structure_type, name: "S0", file: !3, line: 1, size: 64, align: 32, elements: !7)
71!7 = !{!8, !10}
72!8 = !DIDerivedType(tag: DW_TAG_member, name: "f0", scope: !6, file: !3, line: 2, baseType: !9, size: 16, align: 16)
73!9 = !DIBasicType(name: "short", size: 16, align: 16, encoding: DW_ATE_signed)
74!10 = !DIDerivedType(tag: DW_TAG_member, name: "f3", scope: !6, file: !3, line: 3, baseType: !11, size: 32, align: 32, offset: 32)
75!11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
76!12 = !{i32 2, !"Dwarf Version", i32 2}
77!13 = !{i32 2, !"Debug Info Version", i32 3}
78!14 = !{i32 1, !"PIC Level", i32 2}
James Y Knight693d39d2019-01-15 16:18:52 +000079!15 = !{!"clang version 3.9.0"}
Shiva Chen2c864552018-05-09 02:40:45 +000080!16 = distinct !DISubprogram(name: "fn1", scope: !3, file: !3, line: 5, type: !17, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !19)
Adrian Prantl1eadba12016-12-22 00:45:21 +000081!17 = !DISubroutineType(types: !18)
82!18 = !{null, !9}
83!19 = !{!20, !21, !22}
84!20 = !DILocalVariable(name: "p1", arg: 1, scope: !16, file: !3, line: 5, type: !9)
85!21 = !DILocalVariable(name: "b", scope: !16, file: !3, line: 6, type: !6)
86!22 = !DILocalVariable(name: "c", scope: !16, file: !3, line: 6, type: !6)
87!23 = !DIExpression()
88!24 = !DILocation(line: 5, column: 16, scope: !16)
89!25 = !DILocation(line: 6, column: 13, scope: !16)
90!26 = !DILocation(line: 6, column: 16, scope: !16)
91!27 = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
92!28 = !DIExpression(DW_OP_LLVM_fragment, 32, 32)
93!29 = !DIExpression(DW_OP_LLVM_fragment, 32, 16)
94!30 = !DILocation(line: 8, column: 9, scope: !16)
95!31 = !DILocation(line: 9, column: 1, scope: !16)
Shiva Chen2c864552018-05-09 02:40:45 +000096!32 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 11, type: !33, isLocal: false, isDefinition: true, scopeLine: 11, isOptimized: true, unit: !2, retainedNodes: !4)
Adrian Prantl1eadba12016-12-22 00:45:21 +000097!33 = !DISubroutineType(types: !34)
98!34 = !{!11}
99!35 = !DILocation(line: 11, column: 14, scope: !32)
100