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. 5 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 11 12;; Re-run with "new" debug-info mode, checking that we load / convert / emit 13;; the dbg.declares below correctly. 14; RUN: llvm-lto -thinlto-action=run %t1.bc %t2.bc -exported-symbol=_Z5Alphav --try-experimental-debuginfo-iterators 15; RUN: llvm-nm %t1.bc.thinlto.o | FileCheck %s -check-prefix=ThinLTOa 16; RUN: llvm-nm %t2.bc.thinlto.o | FileCheck %s -check-prefix=ThinLTOb 17 18; ThinLTOa-DAG: T _Z5Bravov 19; ThinLTOa-DAG: W _ZN4EchoD2Ev 20; ThinLTOb-DAG: T _Z5Alphav 21 22target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 23target triple = "x86_64-unknown-linux-gnu" 24 25%struct.Delta = type { %struct.Charlie } 26%struct.Charlie = type { i32 } 27%struct.Echo = type { %struct.Charlie } 28 29$_ZN4EchoD2Ev = comdat any 30$_ZN5DeltaD2Ev = comdat any 31 32define void @_Z5Bravov() !dbg !7 { 33 %Hotel = alloca %struct.Delta, align 4 34 %India = alloca %struct.Echo, align 4 35 call void @llvm.dbg.declare(metadata ptr %Hotel, metadata !10, metadata !DIExpression()), !dbg !22 36 call void @_ZN4EchoD2Ev(ptr %India), !dbg !28 37 ret void, !dbg !28 38} 39 40declare void @llvm.dbg.declare(metadata, metadata, metadata) 41 42define linkonce_odr void @_ZN4EchoD2Ev(ptr %this) unnamed_addr comdat align 2 { 43 %this.addr.i = alloca ptr, align 8 44 call void @llvm.dbg.declare(metadata ptr %this.addr.i, metadata !29, metadata !DIExpression()), !dbg !32 45 %this1.i = load ptr, ptr %this.addr.i, align 8 46 ret void 47} 48 49define linkonce_odr void @_ZN5DeltaD2Ev(ptr %this) unnamed_addr comdat align 2 !dbg !36 { 50 %this.addr.i = alloca ptr, align 8 51 call void @llvm.dbg.declare(metadata ptr %this.addr.i, metadata !29, metadata !DIExpression()), !dbg !41 52 %this1.i = load ptr, ptr %this.addr.i, align 8 53 ret void 54} 55 56!llvm.module.flags = !{!3, !4, !5} 57 58!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) 59!1 = !DIFile(filename: "a.cpp", directory: "/home/sunil/185335/302") 60!2 = !{} 61!3 = !{i32 2, !"Dwarf Version", i32 4} 62!4 = !{i32 2, !"Debug Info Version", i32 3} 63!5 = !{i32 1, !"wchar_size", i32 4} 64!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) 65!8 = !DISubroutineType(types: !9) 66!9 = !{null} 67!10 = !DILocalVariable(name: "Hotel", scope: !7, file: !1, line: 18, type: !11) 68!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Delta", file: !1, line: 6, size: 32, elements: !12, identifier: "_ZTS5Delta") 69!12 = !{!13} 70!13 = !DIDerivedType(tag: DW_TAG_member, name: "Foxtrot", scope: !11, file: !1, line: 7, baseType: !14, size: 32) 71!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Charlie", file: !1, line: 1, size: 32, elements: !15, identifier: "_ZTS7Charlie") 72!15 = !{!16, !18} 73!16 = !DIDerivedType(tag: DW_TAG_member, name: "Golf", scope: !14, file: !1, line: 3, baseType: !17, size: 32) 74!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 75!18 = !DISubprogram(name: "~Charlie", scope: !14, file: !1, line: 2, type: !19, isLocal: false, isDefinition: false, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false) 76!19 = !DISubroutineType(types: !20) 77!20 = !{null, !21} 78!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 79!22 = !DILocation(line: 18, column: 11, scope: !7) 80!24 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Echo", file: !1, line: 10, size: 32, elements: !25, identifier: "_ZTS4Echo") 81!25 = !{!26} 82!26 = !DIDerivedType(tag: DW_TAG_member, name: "Foxtrot", scope: !24, file: !1, line: 11, baseType: !14, size: 32) 83!28 = !DILocation(line: 20, column: 1, scope: !7) 84!29 = !DILocalVariable(name: "this", arg: 1, scope: !30, type: !31, flags: DIFlagArtificial | DIFlagObjectPointer) 85!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) 86!31 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64) 87!32 = !DILocation(line: 0, scope: !30) 88!33 = !DILocation(line: 2, column: 53, scope: !34) 89!34 = distinct !DILexicalBlock(scope: !30, file: !1, line: 2, column: 51) 90!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) 91!37 = !DISubroutineType(types: !38) 92!38 = !{null, !39} 93!39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 94!40 = !DISubprogram(name: "~Delta", scope: !11, type: !37, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false) 95!41 = !DILocation(line: 0, scope: !30, inlinedAt: !42) 96!42 = distinct !DILocation(line: 6, column: 8, scope: !43) 97!43 = distinct !DILexicalBlock(scope: !36, file: !1, line: 6, column: 8) 98!48 = !DILocation(line: 2, column: 53, scope: !34, inlinedAt: !42) 99 100;---------------------------------------------------------------------------------------------- 101; Compiled from following two source files with 'clang++ -S --std=c++11 -O0 -g -flto=thin' 102; struct Charlie { 103; __attribute__((__always_inline__)) ~Charlie() { Golf = 0; } 104; int Golf; 105; }; 106; 107; struct Delta { 108; Charlie Foxtrot; 109; }; 110; 111; struct Echo { 112; Charlie Foxtrot; 113; __attribute__((nodebug)) ~Echo() = default; 114; }; 115; 116; extern void Bravo(); 117; 118; void Bravo() { 119; Delta Hotel; 120; Echo India; 121; } 122; ----------------------------- 123; extern void Bravo(); 124; extern void Alpha(); 125; void Alpha() { Bravo(); } 126 127