blob: e31fa89b340c3b0d733b62a717c078c1215bfd3e [file] [log] [blame]
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +00001; RUN: llc -filetype=obj -o %t.o %s
2; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
3
4; Testcase generated using 'clang -O2 -S -emit-llvm' from the following:
5;; int *g;
6;;
7;; static __attribute__((always_inline)) int f(int a) {
8;; int l;
9;; g = &l;
10;; return a;
11;; }
12;;
13;; int main(void) {
14;; f(0);
15;; f(0);
16;; return 0;
17;; }
18
19; Check that we the first call to f(0) has no inlined subroutine (since the
20; function is optimized out), and the second call correctly describes the
21; formal parameter 'a'.
22
23; CHECK: DW_TAG_inlined_subroutine
24; CHECK-NOT: DW_TAG_inlined_subroutine
25; CHECK: DW_AT_low_pc
26; CHECK-NEXT: DW_AT_high_pc
27; CHECK-NOT: DW_TAG_inlined_subroutine
28; CHECK: DW_TAG_formal_parameter
29; CHECK-NEXT: DW_AT_const_value
30; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "a"
31; CHECK-NOT: DW_TAG_inlined_subroutine
32; CHECK: DW_TAG_variable
33; CHECK-NEXT: DW_AT_location
34; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "l"
35
36target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
37target triple = "x86_64-apple-darwin"
38
39@g = common global i32* null, align 8
40
41; Function Attrs: nounwind ssp uwtable
42define i32 @main() #0 {
43entry:
44 %l.i2 = alloca i32, align 4
45 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !12, metadata !21), !dbg !22
46 %0 = bitcast i32* %l.i2 to i8*, !dbg !24
47 call void @llvm.lifetime.start(i64 4, i8* %0), !dbg !24
48 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !12, metadata !21), !dbg !24
49 tail call void @llvm.dbg.value(metadata i32* %l.i2, i64 0, metadata !13, metadata !21), !dbg !26
50 store i32* %l.i2, i32** @g, align 8, !dbg !27, !tbaa !28
51 call void @llvm.lifetime.end(i64 4, i8* %0), !dbg !32
52 ret i32 0, !dbg !33
53}
54
55; Function Attrs: nounwind readnone
56declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
57
58; Function Attrs: nounwind
59declare void @llvm.lifetime.start(i64, i8* nocapture) #2
60
61; Function Attrs: nounwind
62declare void @llvm.lifetime.end(i64, i8* nocapture) #2
63
64attributes #0 = { nounwind ssp 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" "target-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }
65attributes #1 = { nounwind readnone }
66attributes #2 = { nounwind }
67
68!llvm.dbg.cu = !{!0}
69!llvm.module.flags = !{!17, !18, !19}
70!llvm.ident = !{!20}
71
72!0 = !MDCompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !14, imports: !2)
73!1 = !MDFile(filename: "t.c", directory: "/path/to/dir")
74!2 = !{}
75!3 = !{!4, !8}
76!4 = !MDSubprogram(name: "main", scope: !1, file: !1, line: 9, type: !5, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: true, function: i32 ()* @main, variables: !2)
77!5 = !MDSubroutineType(types: !6)
78!6 = !{!7}
79!7 = !MDBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
80!8 = !MDSubprogram(name: "f", scope: !1, file: !1, line: 3, type: !9, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, variables: !11)
81!9 = !MDSubroutineType(types: !10)
82!10 = !{!7, !7}
83!11 = !{!12, !13}
84!12 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", arg: 1, scope: !8, file: !1, line: 3, type: !7)
85!13 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "l", scope: !8, file: !1, line: 4, type: !7)
86!14 = !{!15}
87!15 = !MDGlobalVariable(name: "g", scope: !0, file: !1, line: 1, type: !16, isLocal: false, isDefinition: true, variable: i32** @g)
88!16 = !MDDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64)
89!17 = !{i32 2, !"Dwarf Version", i32 2}
90!18 = !{i32 2, !"Debug Info Version", i32 3}
91!19 = !{i32 1, !"PIC Level", i32 2}
92!20 = !{!"clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)"}
93!21 = !MDExpression()
94!22 = !MDLocation(line: 3, column: 49, scope: !8, inlinedAt: !23)
95!23 = distinct !MDLocation(line: 10, column: 3, scope: !4)
96!24 = !MDLocation(line: 3, column: 49, scope: !8, inlinedAt: !25)
97!25 = distinct !MDLocation(line: 11, column: 3, scope: !4)
98!26 = !MDLocation(line: 4, column: 7, scope: !8, inlinedAt: !25)
99!27 = !MDLocation(line: 5, column: 5, scope: !8, inlinedAt: !25)
100!28 = !{!29, !29, i64 0}
101!29 = !{!"any pointer", !30, i64 0}
102!30 = !{!"omnipotent char", !31, i64 0}
103!31 = !{!"Simple C/C++ TBAA"}
104!32 = !MDLocation(line: 11, column: 3, scope: !4)
105!33 = !MDLocation(line: 12, column: 3, scope: !4)