1 ; Test to make sure that lazily loaded debug location scope metadata is
2 ; handled properly. Note that we need to have the DILexicalScope !34
3 ; referenced from multiple function's debug locs for this to be in the
4 ; lazily loaded module level metadata block.
6 ; RUN: opt -module-hash -module-summary %s -o %t1.bc
7 ; RUN: opt -module-hash -module-summary %p/Inputs/pr35472.ll -o %t2.bc
8 ; RUN: llvm-lto -thinlto-action=run %t1.bc %t2.bc -exported-symbol=_Z5Alphav
9 ; RUN: llvm-nm %t1.bc.thinlto.o | FileCheck %s -check-prefix=ThinLTOa
10 ; RUN: llvm-nm %t2.bc.thinlto.o | FileCheck %s -check-prefix=ThinLTOb
12 ; ThinLTOa-DAG: T _Z5Bravov
13 ; ThinLTOa-DAG: W _ZN4EchoD2Ev
14 ; ThinLTOb-DAG: T _Z5Alphav
16 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
17 target triple = "x86_64-unknown-linux-gnu"
19 %struct.Delta = type { %struct.Charlie }
20 %struct.Charlie = type { i32 }
21 %struct.Echo = type { %struct.Charlie }
23 $_ZN4EchoD2Ev = comdat any
24 $_ZN5DeltaD2Ev = comdat any
26 define void @_Z5Bravov() !dbg !7 {
27 %Hotel = alloca %struct.Delta, align 4
28 %India = alloca %struct.Echo, align 4
29 call void @llvm.dbg.declare(metadata %struct.Delta* %Hotel, metadata !10, metadata !DIExpression()), !dbg !22
30 call void @_ZN4EchoD2Ev(%struct.Echo* %India), !dbg !28
34 declare void @llvm.dbg.declare(metadata, metadata, metadata)
36 define linkonce_odr void @_ZN4EchoD2Ev(%struct.Echo* %this) unnamed_addr comdat align 2 {
37 %this.addr.i = alloca %struct.Charlie*, align 8
38 call void @llvm.dbg.declare(metadata %struct.Charlie** %this.addr.i, metadata !29, metadata !DIExpression()), !dbg !32
39 %this1.i = load %struct.Charlie*, %struct.Charlie** %this.addr.i, align 8
40 %Golf.i = getelementptr inbounds %struct.Charlie, %struct.Charlie* %this1.i, i32 0, i32 0, !dbg !33
44 define linkonce_odr void @_ZN5DeltaD2Ev(%struct.Delta* %this) unnamed_addr comdat align 2 !dbg !36 {
45 %this.addr.i = alloca %struct.Charlie*, align 8
46 call void @llvm.dbg.declare(metadata %struct.Charlie** %this.addr.i, metadata !29, metadata !DIExpression()), !dbg !41
47 %this1.i = load %struct.Charlie*, %struct.Charlie** %this.addr.i, align 8
48 %Golf.i = getelementptr inbounds %struct.Charlie, %struct.Charlie* %this1.i, i32 0, i32 0, !dbg !48
52 !llvm.module.flags = !{!3, !4, !5}
54 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 (trunk 321056)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
55 !1 = !DIFile(filename: "a.cpp", directory: "/home/sunil/185335/302")
57 !3 = !{i32 2, !"Dwarf Version", i32 4}
58 !4 = !{i32 2, !"Debug Info Version", i32 3}
59 !5 = !{i32 1, !"wchar_size", i32 4}
60 !7 = distinct !DISubprogram(name: "Bravo", linkageName: "_Z5Bravov", scope: !1, file: !1, line: 17, type: !8, isLocal: false, isDefinition: true, scopeLine: 17, flags: DIFlagPrototyped, isOptimized: false, unit: !0)
61 !8 = !DISubroutineType(types: !9)
63 !10 = !DILocalVariable(name: "Hotel", scope: !7, file: !1, line: 18, type: !11)
64 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Delta", file: !1, line: 6, size: 32, elements: !12, identifier: "_ZTS5Delta")
66 !13 = !DIDerivedType(tag: DW_TAG_member, name: "Foxtrot", scope: !11, file: !1, line: 7, baseType: !14, size: 32)
67 !14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Charlie", file: !1, line: 1, size: 32, elements: !15, identifier: "_ZTS7Charlie")
69 !16 = !DIDerivedType(tag: DW_TAG_member, name: "Golf", scope: !14, file: !1, line: 3, baseType: !17, size: 32)
70 !17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
71 !18 = !DISubprogram(name: "~Charlie", scope: !14, file: !1, line: 2, type: !19, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false)
72 !19 = !DISubroutineType(types: !20)
74 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
75 !22 = !DILocation(line: 18, column: 11, scope: !7)
76 !24 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Echo", file: !1, line: 10, size: 32, elements: !25, identifier: "_ZTS4Echo")
78 !26 = !DIDerivedType(tag: DW_TAG_member, name: "Foxtrot", scope: !24, file: !1, line: 11, baseType: !14, size: 32)
79 !28 = !DILocation(line: 20, column: 1, scope: !7)
80 !29 = !DILocalVariable(name: "this", arg: 1, scope: !30, type: !31, flags: DIFlagArtificial | DIFlagObjectPointer)
81 !30 = distinct !DISubprogram(name: "~Charlie", linkageName: "_ZN7CharlieD2Ev", scope: !14, file: !1, line: 2, type: !19, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !18)
82 !31 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)
83 !32 = !DILocation(line: 0, scope: !30)
84 !33 = !DILocation(line: 2, column: 53, scope: !34)
85 !34 = distinct !DILexicalBlock(scope: !30, file: !1, line: 2, column: 51)
86 !36 = distinct !DISubprogram(name: "~Delta", linkageName: "_ZN5DeltaD2Ev", scope: !11, file: !1, line: 6, type: !37, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !0, declaration: !40)
87 !37 = !DISubroutineType(types: !38)
89 !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
90 !40 = !DISubprogram(name: "~Delta", scope: !11, type: !37, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
91 !41 = !DILocation(line: 0, scope: !30, inlinedAt: !42)
92 !42 = distinct !DILocation(line: 6, column: 8, scope: !43)
93 !43 = distinct !DILexicalBlock(scope: !36, file: !1, line: 6, column: 8)
94 !48 = !DILocation(line: 2, column: 53, scope: !34, inlinedAt: !42)
96 ;----------------------------------------------------------------------------------------------
97 ; Compiled from following two source files with 'clang++ -S --std=c++11 -O0 -g -flto=thin'
99 ; __attribute__((__always_inline__)) ~Charlie() { Golf = 0; }
109 ; __attribute__((nodebug)) ~Echo() = default;
112 ; extern void Bravo();
118 ; -----------------------------
119 ; extern void Bravo();
120 ; extern void Alpha();
121 ; void Alpha() { Bravo(); }