1; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
2
3; Built from source:
4; $ clang++ a.cpp b.cpp -g -c -emit-llvm
5; $ llvm-link a.bc b.bc -o ab.bc
6; $ cat a.cpp
7; # 1 "func.h"
8; inline int func(int i) {
9;   return i * 2;
10; }
11; int (*x)(int) = &func;
12; $ cat b.cpp
13; # 1 "func.h"
14; inline int func(int i) {
15;   return i * 2;
16; }
17; int (*y)(int) = &func;
18
19; CHECK: DW_TAG_compile_unit
20; CHECK:   DW_TAG_subprogram
21; CHECK-NOT: DW_TAG
22; CHECK:     DW_AT_name {{.*}} "func"
23; CHECK: DW_TAG_compile_unit
24; CHECK-NOT: DW_TAG_subprogram
25
26source_filename = "test/DebugInfo/Generic/cross-cu-linkonce.ll"
27
28@x = global i32 (i32)* @_Z4funci, align 8, !dbg !0
29@y = global i32 (i32)* @_Z4funci, align 8, !dbg !7
30
31; Function Attrs: inlinehint nounwind uwtable
32define linkonce_odr i32 @_Z4funci(i32 %i) #0 !dbg !19 {
33  %1 = alloca i32, align 4
34  store i32 %i, i32* %1, align 4
35  call void @llvm.dbg.declare(metadata i32* %1, metadata !20, metadata !21), !dbg !22
36  %2 = load i32, i32* %1, align 4, !dbg !23
37  %3 = mul nsw i32 %2, 2, !dbg !23
38  ret i32 %3, !dbg !23
39}
40
41; Function Attrs: nounwind readnone
42declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
43
44attributes #0 = { inlinehint 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" }
45attributes #1 = { nounwind readnone }
46
47!llvm.dbg.cu = !{!9, !13}
48!llvm.module.flags = !{!16, !17}
49!llvm.ident = !{!18, !18}
50
51!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
52!1 = !DIGlobalVariable(name: "x", scope: null, file: !2, line: 4, type: !3, isLocal: false, isDefinition: true)
53!2 = !DIFile(filename: "func.h", directory: "/tmp/dbginfo")
54!3 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64, align: 64)
55!4 = !DISubroutineType(types: !5)
56!5 = !{!6, !6}
57!6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
58!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())
59!8 = !DIGlobalVariable(name: "y", scope: null, file: !2, line: 4, type: !3, isLocal: false, isDefinition: true)
60!9 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !10, producer: "clang version 3.5.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !11, retainedTypes: !11, globals: !12, imports: !11)
61!10 = !DIFile(filename: "a.cpp", directory: "/tmp/dbginfo")
62!11 = !{}
63!12 = !{!0}
64!13 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !14, producer: "clang version 3.5.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !11, retainedTypes: !11, globals: !15, imports: !11)
65!14 = !DIFile(filename: "b.cpp", directory: "/tmp/dbginfo")
66!15 = !{!7}
67!16 = !{i32 2, !"Dwarf Version", i32 4}
68!17 = !{i32 1, !"Debug Info Version", i32 3}
69!18 = !{!"clang version 3.5.0 "}
70!19 = distinct !DISubprogram(name: "func", linkageName: "_Z4funci", scope: !2, file: !2, line: 1, type: !4, isLocal: false, isDefinition: true, scopeLine: 1, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !9, retainedNodes: !11)
71!20 = !DILocalVariable(name: "i", arg: 1, scope: !19, file: !2, line: 1, type: !6)
72!21 = !DIExpression()
73!22 = !DILocation(line: 1, scope: !19)
74!23 = !DILocation(line: 2, scope: !19)
75
76