1; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump -v -debug-info - | FileCheck -implicit-check-not=DW_TAG %s 2; RUN: %llc_dwarf -accel-tables=Apple -dwarf-linkage-names=All -O0 -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s 3 4; Build from source: 5; $ clang++ a.cpp b.cpp -g -c -emit-llvm 6; $ llvm-link a.bc b.bc -o ab.bc 7; $ opt -inline ab.bc -o ab-opt.bc 8; $ cat a.cpp 9; extern int i; 10; int func(int); 11; int main() { 12; return func(i); 13; } 14; $ cat b.cpp 15; int __attribute__((always_inline)) func(int x) { 16; return x * 2; 17; } 18 19; Ensure that func inlined into main is described and references the abstract 20; definition in b.cpp's CU. 21 22; CHECK: DW_TAG_compile_unit 23; CHECK: DW_AT_name {{.*}} "a.cpp" 24; CHECK: DW_TAG_subprogram 25; CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000[[INT:[a-f0-9]+]] 26; CHECK: 0x[[INLINED:[0-9a-f]*]]:{{.*}}DW_TAG_inlined_subroutine 27; CHECK: DW_AT_abstract_origin {{.*}}[[ABS_FUNC:........]] "_Z4funci" 28; CHECK: DW_TAG_formal_parameter 29; CHECK: DW_AT_abstract_origin {{.*}}[[ABS_VAR:........]] "x" 30 31; Check the abstract definition is in the 'b.cpp' CU and doesn't contain any 32; concrete information (address range or variable location) 33; CHECK: DW_TAG_compile_unit 34; CHECK: DW_AT_name {{.*}} "b.cpp" 35; CHECK: 0x[[ABS_FUNC]]: DW_TAG_subprogram 36; CHECK-NOT: DW_AT_low_pc 37; CHECK: 0x[[ABS_VAR]]: DW_TAG_formal_parameter 38; CHECK-NOT: DW_AT_location 39; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} {0x[[INT]]} 40; CHECK-NOT: DW_AT_location 41 42; CHECK: 0x[[INT]]: DW_TAG_base_type 43; CHECK: DW_AT_name {{.*}} "int" 44 45; Check the concrete out of line definition references the abstract and 46; provides the address range and variable location 47; CHECK: 0x[[FUNC:[0-9a-f]*]]{{.*}}DW_TAG_subprogram 48; CHECK: DW_AT_low_pc 49; CHECK: DW_AT_abstract_origin {{.*}} {0x[[ABS_FUNC]]} "_Z4funci" 50; CHECK: DW_TAG_formal_parameter 51; CHECK: DW_AT_location 52; CHECK: DW_AT_abstract_origin {{.*}} {0x[[ABS_VAR]]} "x" 53 54; Check that both the inline and the non out of line version of func are 55; correctly referenced in the accelerator table. Before r221837, the one 56; in the second compilation unit had a wrong offset 57; CHECK-ACCEL: .apple_names contents: 58; CHECK-ACCEL: String{{.*}}"func" 59; CHECK-ACCEL-NOT: String 60; CHECK-ACCEL: Atom[0]{{.*}}[[INLINED]] 61; CHECK-ACCEL-NOT: String 62; CHECK-ACCEL: Atom[0]{{.*}}[[FUNC]] 63 64@i = external global i32 65 66; Function Attrs: uwtable 67define i32 @main() #0 !dbg !4 { 68entry: 69 %x.addr.i = alloca i32, align 4 70 %retval = alloca i32, align 4 71 store i32 0, i32* %retval 72 %0 = load i32, i32* @i, align 4, !dbg !19 73 %1 = bitcast i32* %x.addr.i to i8* 74 call void @llvm.lifetime.start(i64 4, i8* %1) 75 store i32 %0, i32* %x.addr.i, align 4 76 call void @llvm.dbg.declare(metadata i32* %x.addr.i, metadata !120, metadata !DIExpression()), !dbg !21 77 %2 = load i32, i32* %x.addr.i, align 4, !dbg !22 78 %mul.i = mul nsw i32 %2, 2, !dbg !22 79 %3 = bitcast i32* %x.addr.i to i8*, !dbg !22 80 call void @llvm.lifetime.end(i64 4, i8* %3), !dbg !22 81 ret i32 %mul.i, !dbg !19 82} 83 84; Function Attrs: alwaysinline nounwind uwtable 85define i32 @_Z4funci(i32 %x) #1 !dbg !12 { 86entry: 87 %x.addr = alloca i32, align 4 88 store i32 %x, i32* %x.addr, align 4 89 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !20, metadata !DIExpression()), !dbg !23 90 %0 = load i32, i32* %x.addr, align 4, !dbg !24 91 %mul = mul nsw i32 %0, 2, !dbg !24 92 ret i32 %mul, !dbg !24 93} 94 95; Function Attrs: nounwind readnone 96declare void @llvm.dbg.declare(metadata, metadata, metadata) #2 97 98; Function Attrs: nounwind 99declare void @llvm.lifetime.start(i64, i8* nocapture) #3 100 101; Function Attrs: nounwind 102declare void @llvm.lifetime.end(i64, i8* nocapture) #3 103 104attributes #0 = { uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 105attributes #1 = { alwaysinline nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 106attributes #2 = { nounwind readnone } 107attributes #3 = { nounwind } 108 109!llvm.dbg.cu = !{!0, !9} 110!llvm.module.flags = !{!16, !17} 111!llvm.ident = !{!18, !18} 112 113!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 114!1 = !DIFile(filename: "a.cpp", directory: "/tmp/dbginfo") 115!2 = !{} 116!4 = distinct !DISubprogram(name: "main", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2) 117!5 = !DIFile(filename: "a.cpp", directory: "/tmp/dbginfo") 118!6 = !DISubroutineType(types: !7) 119!7 = !{!8} 120!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 121!9 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !10, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 122!10 = !DIFile(filename: "b.cpp", directory: "/tmp/dbginfo") 123!12 = distinct !DISubprogram(name: "func", linkageName: "_Z4funci", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !9, scopeLine: 1, file: !10, scope: !13, type: !14, retainedNodes: !2) 124!13 = !DIFile(filename: "b.cpp", directory: "/tmp/dbginfo") 125!14 = !DISubroutineType(types: !15) 126!15 = !{!8, !8} 127!16 = !{i32 2, !"Dwarf Version", i32 4} 128!17 = !{i32 2, !"Debug Info Version", i32 3} 129!18 = !{!"clang version 3.5.0 "} 130!19 = !DILocation(line: 4, scope: !4) 131!20 = !DILocalVariable(name: "x", line: 1, arg: 1, scope: !12, file: !13, type: !8) 132 133!120 = !DILocalVariable(name: "x", line: 1, arg: 1, scope: !12, file: !13, type: !8) 134 135!21 = !DILocation(line: 1, scope: !12, inlinedAt: !19) 136!22 = !DILocation(line: 2, scope: !12, inlinedAt: !19) 137!23 = !DILocation(line: 1, scope: !12) 138!24 = !DILocation(line: 2, scope: !12) 139 140