xref: /llvm-project/llvm/test/Bitcode/upgrade-cu-locals.ll (revision b6f922fbf5e983122271aa12acb33f6172046d4d)
1; Test moving of local imports from DICompileUnit's 'imports' to DISubprogram's 'retainedNodes'
2;
3; RUN: llvm-dis -o - %s.bc | FileCheck %s
4
5%"struct.ns::t1" = type { i8 }
6
7declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
8
9declare dso_local void @_Z3pinv() local_unnamed_addr
10
11define dso_local i32 @main() local_unnamed_addr !dbg !23 {
12entry:
13  call void @llvm.dbg.declare(metadata ptr undef, metadata !39, metadata !DIExpression()), !dbg !40
14  call void @_Z3pinv(), !dbg !42
15  ret i32 0, !dbg !43
16}
17
18define dso_local i32 @main2() local_unnamed_addr !dbg !29 {
19  ret i32 0
20}
21
22attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
23
24!llvm.dbg.cu = !{!0, !16}
25!llvm.ident = !{!33, !33}
26!llvm.module.flags = !{!34, !35, !36, !37, !38}
27
28; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, imports: !2,
29; CHECK: !2 = !{!3}
30; CHECK: !3 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !4,
31; CHECK: !4 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t4"
32
33; CHECK: !5 = !{}
34; CHECK: !6 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !7, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, imports: !5, nameTableKind: GNU)
35
36; CHECK: !14 = distinct !DISubprogram(name: "main", scope: !7, file: !7, line: 2, type: !15, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !18)
37; CHECK: !18 = !{!19}
38; CHECK: !19 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !20, entity: !23,
39; CHECK: !20 = !DILexicalBlock(scope: !21, file: !7, line: 7, column: 35)
40; CHECK: !21 = !DILexicalBlock(scope: !22, file: !7, line: 7, column: 35)
41; CHECK: !22 = !DILexicalBlock(scope: !14, file: !7, line: 7, column: 35)
42; CHECK: !23 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t5", scope: !20,
43
44; CHECK: !25 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 3, type: !26, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !28)
45; CHECK: !28 = !{!29, !32, !34}
46; CHECK: !29 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !25, entity: !30,
47; CHECK: !30 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1",
48; CHECK: !32 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !25, entity: !33,
49; CHECK: !33 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t2",
50; CHECK: !34 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !25, entity: !35,
51; CHECK: !35 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t3",
52
53; CHECK: !40 = distinct !DISubprogram(name: "main2", scope: !7, file: !7, line: 10, type: !15, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !41)
54; CHECK: !41 = !{!42, !44}
55; CHECK: !42 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !40, entity: !43,
56; CHECK: !43 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t6"
57; CHECK: !44 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !40, entity: !45,
58; CHECK: !45 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t7",
59
60
61!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, imports: !2, nameTableKind: GNU)
62!1 = !DIFile(filename: "a.cpp", directory: "/")
63!2 = !{!3, !10, !12, !14}
64
65; Move t1 to DISubprogram f1
66!3 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !8, file: !1, line: 3)
67!4 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !7)
68!5 = !DISubroutineType(types: !6)
69!6 = !{null}
70!7 = !{}
71!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", scope: !9, file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTSN2ns2t1E")
72!9 = !DINamespace(name: "ns", scope: null)
73
74; Move t2 to DISubprogram f1
75!10 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !11, file: !1, line: 3)
76!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t2", scope: !9, file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTSN2ns2t2E")
77
78; Move t3 to DISubprogram f1
79!12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !13, file: !1, line: 3)
80!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t3", scope: !9, file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTSN2ns2t3E")
81
82; Leave t4 in CU
83!14 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !0, entity: !15, file: !1, line: 3)
84!15 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t4", scope: !0, file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTSN2ns2t4E")
85!16 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !17, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, imports: !18, nameTableKind: GNU)
86!17 = !DIFile(filename: "b.cpp", directory: "/")
87!18 = !{!19, !28, !31}
88
89; Move t5 to DISubprogram main
90!19 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !20, entity: !27, file: !1, line: 3)
91!20 = !DILexicalBlock(scope: !21, file: !17, line: 7, column: 35)
92!21 = !DILexicalBlock(scope: !22, file: !17, line: 7, column: 35)
93!22 = !DILexicalBlock(scope: !23, file: !17, line: 7, column: 35)
94!23 = distinct !DISubprogram(name: "main", scope: !17, file: !17, line: 2, type: !24, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !16, retainedNodes: !7)
95!24 = !DISubroutineType(types: !25)
96!25 = !{!26}
97!26 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
98!27 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t5", scope: !20, file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTSN2ns2t5E")
99
100; Move t6 to DISubprogram main2
101!28 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !29, entity: !30, file: !17, line: 3)
102!29 = distinct !DISubprogram(name: "main2", scope: !17, file: !17, line: 10, type: !24, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !16, retainedNodes: !7)
103!30 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t6", scope: !29, file: !17, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTSN2ns2t6E")
104
105; Move t7 to DISubprogram main2
106!31 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !29, entity: !32, file: !17, line: 3)
107!32 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t7", scope: !29, file: !17, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !7, identifier: "_ZTSN2ns2t7E")
108!33 = !{!"clang version 14.0.0"}
109!34 = !{i32 7, !"Dwarf Version", i32 4}
110!35 = !{i32 2, !"Debug Info Version", i32 3}
111!36 = !{i32 1, !"wchar_size", i32 4}
112!37 = !{i32 7, !"uwtable", i32 1}
113!38 = !{i32 7, !"frame-pointer", i32 2}
114!39 = !DILocalVariable(name: "v1", scope: !4, file: !1, line: 3, type: !8)
115!40 = !DILocation(line: 3, column: 37, scope: !4, inlinedAt: !41)
116!41 = distinct !DILocation(line: 3, column: 3, scope: !23)
117!42 = !DILocation(line: 3, column: 41, scope: !4, inlinedAt: !41)
118!43 = !DILocation(line: 4, column: 1, scope: !23)
119