xref: /llvm-project/llvm/test/DebugInfo/Generic/import-inlined-declaration.ll (revision 3a05e01d1a76984fe1532bd237edbbb7ed9db6ea)
1; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump - | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s
2
3; RUN: %llc_dwarf --try-experimental-debuginfo-iterators -O0 -filetype=obj < %s | llvm-dwarfdump - | FileCheck --implicit-check-not "{{DW_TAG|NULL}}" %s
4
5; namespace ns {
6; inline __attribute__((always_inline))
7; void foo() { int a = 4; }
8; }
9;
10; void goo() {
11;   using ns::foo;
12;   foo();
13; }
14
15; Ensure that imported declarations reference the correct subprograms even if
16; those subprograms are inlined.
17
18; CHECK: DW_TAG_compile_unit
19; CHECK:   DW_TAG_namespace
20; CHECK:     DW_AT_name     ("ns")
21; CHECK: [[FOO:0x.*]]:     DW_TAG_subprogram
22; CHECK:       DW_AT_name   ("foo")
23; CHECK:       DW_TAG_variable
24; CHECK:       NULL
25; CHECK:     NULL
26; CHECK:   DW_TAG_base_type
27; CHECK:   DW_TAG_subprogram
28; CHECK:     DW_AT_name     ("goo")
29; CHECK:     DW_TAG_inlined_subroutine
30; CHECK:       DW_AT_abstract_origin ([[FOO]]
31; CHECK:       DW_TAG_variable
32; CHECK:       NULL
33; CHECK:     DW_TAG_imported_declaration
34; CHECK:       DW_AT_import ([[FOO]])
35; CHECK:     NULL
36; CHECK:   NULL
37
38; Function Attrs: mustprogress noinline optnone uwtable
39define dso_local void @_Z3goov() !dbg !4 {
40entry:
41  %a.i = alloca i32, align 4
42  call void @llvm.dbg.declare(metadata ptr %a.i, metadata !16, metadata !DIExpression()), !dbg !18
43  store i32 4, ptr %a.i, align 4, !dbg !18
44  ret void, !dbg !20
45}
46
47; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
48declare void @llvm.dbg.declare(metadata, metadata, metadata)
49
50!llvm.dbg.cu = !{!0}
51!llvm.module.flags = !{!10, !11, !12, !13, !14}
52!llvm.ident = !{!15}
53
54!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
55!1 = !DIFile(filename: "imported-inlined-declaration.cpp", directory: "")
56!2 = !{!3}
57!3 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !8, file: !1, line: 7)
58!4 = distinct !DISubprogram(name: "goo", linkageName: "_Z3goov", scope: !1, file: !1, line: 6, type: !5, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
59!5 = !DISubroutineType(types: !6)
60!6 = !{null}
61!7 = !{}
62!8 = distinct !DISubprogram(name: "foo", linkageName: "_ZN2ns3fooEv", scope: !9, file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !7)
63!9 = !DINamespace(name: "ns", scope: null)
64!10 = !{i32 7, !"Dwarf Version", i32 4}
65!11 = !{i32 2, !"Debug Info Version", i32 3}
66!12 = !{i32 1, !"wchar_size", i32 4}
67!13 = !{i32 7, !"uwtable", i32 1}
68!14 = !{i32 7, !"frame-pointer", i32 2}
69!15 = !{!"clang version 14.0.0"}
70!16 = !DILocalVariable(name: "a", scope: !8, file: !1, line: 3, type: !17)
71!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
72!18 = !DILocation(line: 3, column: 18, scope: !8, inlinedAt: !19)
73!19 = distinct !DILocation(line: 8, column: 2, scope: !4)
74!20 = !DILocation(line: 9, column: 1, scope: !4)
75