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