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