xref: /llvm-project/llvm/test/DebugInfo/Generic/assignment-tracking/inline/id.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt %s -S -passes=inline -o - | FileCheck %s
2; RUN: opt --try-experimental-debuginfo-iterators %s -S -passes=inline -o - | FileCheck %s
3
4;; Check that all DIAssignID metadata that are inlined are replaced with new
5;; versions. Otherwise two inlined instances of an assignment will be considered
6;; to be the same assignment.
7;;
8;; $cat test.cpp
9;; __attribute__((always_inline))
10;; int get() { int val = 5; return val; }
11;; void fun() {
12;;   get();
13;;   get();
14;; }
15
16; CHECK-LABEL: _Z3funv
17;
18; CHECK: store i32 5, ptr %val.i, align 4{{.*}}, !DIAssignID [[ID_0:![0-9]+]]
19; CHECK-NEXT: #dbg_assign(i32 5, [[val:![0-9]+]], !DIExpression(), [[ID_0]], ptr %val.i, !DIExpression(), [[dl_inline_0:![0-9]+]]
20;
21; CHECK: store i32 5, ptr %val.i1, align 4{{.*}}, !DIAssignID [[ID_1:![0-9]+]]
22; CHECK-NEXT: #dbg_assign(i32 5, [[val]], !DIExpression(), [[ID_1]], ptr %val.i1, !DIExpression(), [[dl_inline_1:![0-9]+]]
23;
24; CHECK-DAG: [[val]] = !DILocalVariable(name: "val",
25; CHECK-DAG: [[dl_inline_0]] = !DILocation({{.*}}inlinedAt
26; CHECK-DAG: [[dl_inline_1]] = !DILocation({{.*}}inlinedAt
27; CHECK-DAG: [[ID_0]] = distinct !DIAssignID()
28; CHECK-DAG: [[ID_1]] = distinct !DIAssignID()
29
30define dso_local i32 @_Z3getv() !dbg !7 {
31entry:
32  %val = alloca i32, align 4, !DIAssignID !13
33  call void @llvm.dbg.assign(metadata i1 undef, metadata !12, metadata !DIExpression(), metadata !13, metadata ptr %val, metadata !DIExpression()), !dbg !14
34  %0 = bitcast ptr %val to ptr, !dbg !15
35  call void @llvm.lifetime.start.p0(i64 4, ptr %0), !dbg !15
36  store i32 5, ptr %val, align 4, !dbg !16, !DIAssignID !21
37  call void @llvm.dbg.assign(metadata i32 5, metadata !12, metadata !DIExpression(), metadata !21, metadata ptr %val, metadata !DIExpression()), !dbg !14
38  %1 = load i32, ptr %val, align 4, !dbg !22
39  %2 = bitcast ptr %val to ptr, !dbg !23
40  call void @llvm.lifetime.end.p0(i64 4, ptr %2), !dbg !23
41  ret i32 %1, !dbg !24
42}
43
44declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
45declare void @llvm.dbg.declare(metadata, metadata, metadata)
46declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)
47declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
48
49; Function Attrs: nounwind uwtable mustprogress
50define dso_local void @_Z3funv() !dbg !25 {
51entry:
52  %call = call i32 @_Z3getv(), !dbg !28
53  %call1 = call i32 @_Z3getv(), !dbg !29
54  ret void, !dbg !30
55}
56
57!llvm.dbg.cu = !{!0}
58!llvm.module.flags = !{!3, !4, !5, !1000}
59!llvm.ident = !{!6}
60
61!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
62!1 = !DIFile(filename: "test.cpp", directory: "")
63!2 = !{}
64!3 = !{i32 7, !"Dwarf Version", i32 4}
65!4 = !{i32 2, !"Debug Info Version", i32 3}
66!5 = !{i32 1, !"wchar_size", i32 4}
67!6 = !{!"clang version 12.0.0"}
68!7 = distinct !DISubprogram(name: "get", linkageName: "_Z3getv", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
69!8 = !DISubroutineType(types: !9)
70!9 = !{!10}
71!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
72!11 = !{!12}
73!12 = !DILocalVariable(name: "val", scope: !7, file: !1, line: 2, type: !10)
74!13 = distinct !DIAssignID()
75!14 = !DILocation(line: 0, scope: !7)
76!15 = !DILocation(line: 2, column: 13, scope: !7)
77!16 = !DILocation(line: 2, column: 17, scope: !7)
78!21 = distinct !DIAssignID()
79!22 = !DILocation(line: 2, column: 33, scope: !7)
80!23 = !DILocation(line: 2, column: 38, scope: !7)
81!24 = !DILocation(line: 2, column: 26, scope: !7)
82!25 = distinct !DISubprogram(name: "fun", linkageName: "_Z3funv", scope: !1, file: !1, line: 3, type: !26, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
83!26 = !DISubroutineType(types: !27)
84!27 = !{null}
85!28 = !DILocation(line: 4, column: 3, scope: !25)
86!29 = !DILocation(line: 5, column: 3, scope: !25)
87!30 = !DILocation(line: 6, column: 1, scope: !25)
88!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
89