1; REQUIRES: object-emission 2 3; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s 4 5; Build from source: 6; $ clang++ a.cpp b.cpp -g -c -emit-llvm 7; $ llvm-link a.bc b.bc -o ab.bc 8; $ opt -inline ab.bc -o ab-opt.bc 9; $ cat a.cpp 10; extern int i; 11; int func(int); 12; int main() { 13; return func(i); 14; } 15; $ cat b.cpp 16; int __attribute__((always_inline)) func(int x) { 17; return x * 2; 18; } 19 20; Ensure that func inlined into main is described and references the abstract 21; definition in b.cpp's CU. 22 23; CHECK: DW_TAG_compile_unit 24; CHECK: DW_AT_name {{.*}} "a.cpp" 25; CHECK: DW_TAG_subprogram 26; CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000[[INT:.*]]) 27; CHECK: DW_TAG_inlined_subroutine 28; CHECK-NOT: DW_TAG 29; CHECK: DW_AT_abstract_origin {{.*}}[[ABS_FUNC:........]]) 30; CHECK: DW_TAG_formal_parameter 31; CHECK-NOT: DW_TAG 32; CHECK: DW_AT_abstract_origin {{.*}}[[ABS_VAR:........]]) 33 34; Check the abstract definition is in the 'b.cpp' CU and doesn't contain any 35; concrete information (address range or variable location) 36; CHECK: DW_TAG_compile_unit 37; CHECK: DW_AT_name {{.*}} "b.cpp" 38; CHECK: 0x[[ABS_FUNC]]: DW_TAG_subprogram 39; CHECK-NOT: DW_AT_low_pc 40; CHECK: 0x[[ABS_VAR]]: DW_TAG_formal_parameter 41; CHECK-NOT: DW_TAG 42; CHECK-NOT: DW_AT_location 43; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} {0x[[INT]]} 44; CHECK-NOT: DW_AT_location 45 46; CHECK: 0x[[INT]]: DW_TAG_base_type 47; CHECK-NOT: DW_TAG 48; CHECK: DW_AT_name {{.*}} "int" 49 50; Check the concrete out of line definition references the abstract and 51; provides the address range and variable location 52; CHECK: DW_TAG_subprogram 53; CHECK-NOT: DW_TAG 54; CHECK: DW_AT_low_pc 55; CHECK-NOT: DW_TAG 56; CHECK: DW_AT_abstract_origin {{.*}} {0x[[ABS_FUNC]]} 57; CHECK: DW_TAG_formal_parameter 58; CHECK-NOT: DW_TAG 59; CHECK: DW_AT_location 60; CHECK-NOT: DW_TAG 61; CHECK: DW_AT_abstract_origin {{.*}} {0x[[ABS_VAR]]} 62 63 64@i = external global i32 65 66; Function Attrs: uwtable 67define i32 @main() #0 { 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* @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 !20), !dbg !21 77 %2 = load 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 { 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), !dbg !23 90 %0 = load 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) #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" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.5.0 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/a.cpp] [DW_LANG_C_plus_plus] 114!1 = metadata !{metadata !"a.cpp", metadata !"/tmp/dbginfo"} 115!2 = metadata !{} 116!3 = metadata !{metadata !4} 117!4 = metadata !{i32 786478, metadata !1, metadata !5, metadata !"main", metadata !"main", metadata !"", i32 3, metadata !6, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main, null, null, metadata !2, i32 3} ; [ DW_TAG_subprogram ] [line 3] [def] [main] 118!5 = metadata !{i32 786473, metadata !1} ; [ DW_TAG_file_type ] [/tmp/dbginfo/a.cpp] 119!6 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] 120!7 = metadata !{metadata !8} 121!8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] 122!9 = metadata !{i32 786449, metadata !10, i32 4, metadata !"clang version 3.5.0 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !11, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/b.cpp] [DW_LANG_C_plus_plus] 123!10 = metadata !{metadata !"b.cpp", metadata !"/tmp/dbginfo"} 124!11 = metadata !{metadata !12} 125!12 = metadata !{i32 786478, metadata !10, metadata !13, metadata !"func", metadata !"func", metadata !"_Z4funci", i32 1, metadata !14, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z4funci, null, null, metadata !2, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [func] 126!13 = metadata !{i32 786473, metadata !10} ; [ DW_TAG_file_type ] [/tmp/dbginfo/b.cpp] 127!14 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !15, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] 128!15 = metadata !{metadata !8, metadata !8} 129!16 = metadata !{i32 2, metadata !"Dwarf Version", i32 4} 130!17 = metadata !{i32 2, metadata !"Debug Info Version", i32 1} 131!18 = metadata !{metadata !"clang version 3.5.0 "} 132!19 = metadata !{i32 4, i32 0, metadata !4, null} 133!20 = metadata !{i32 786689, metadata !12, metadata !"x", metadata !13, i32 16777217, metadata !8, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [x] [line 1] 134!21 = metadata !{i32 1, i32 0, metadata !12, metadata !19} 135!22 = metadata !{i32 2, i32 0, metadata !12, metadata !19} 136!23 = metadata !{i32 1, i32 0, metadata !12, null} 137!24 = metadata !{i32 2, i32 0, metadata !12, null} 138 139