xref: /llvm-project/llvm/test/DebugInfo/X86/inlined-formal-parameter.ll (revision 274bcbc139463b72d949cd32b972b3721c99f4be)
1; RUN: llc -filetype=obj -o %t.o %s
2; RUN: llvm-dwarfdump %t.o | FileCheck %s
3
4; Testcase generated using 'clang -g -O2 -S -emit-llvm' from the following:
5;; void sink(void);
6;; static __attribute__((always_inline)) void bar(int a) { sink(); }
7;; void foo(void) {
8;;   bar(0);
9;;   bar(0);
10;; }
11
12; Check that we have formal parameters for 'a' in both inlined subroutines.
13; CHECK: .debug_info
14; CHECK:       DW_TAG_inlined_subroutine
15; CHECK-NEXT:    DW_AT_abstract_origin {{.*}} "bar"
16; CHECK:         DW_TAG_formal_parameter
17; CHECK-NEXT:      DW_AT_const_value
18; CHECK-NEXT:      DW_AT_abstract_origin {{.*}} "a"
19; CHECK:       DW_TAG_inlined_subroutine
20; CHECK-NEXT:    DW_AT_abstract_origin {{.*}} "bar"
21; CHECK:         DW_TAG_formal_parameter
22; CHECK-NEXT:      DW_AT_location [DW_FORM_data4]	(0x00000000)
23; CHECK-NEXT:      DW_AT_abstract_origin {{.*}} "a"
24;
25; CHECK: .debug_loc
26; CHECK: Location description: 11 00
27target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
28target triple = "x86_64-apple-darwin"
29
30; Function Attrs: nounwind ssp uwtable
31define void @foo() #0 !dbg !4 {
32entry:
33  tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !12, metadata !17) #3, !dbg !18
34  tail call void @sink() #3, !dbg !20
35  tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !12, metadata !17) #3, !dbg !21
36  tail call void @sink() #3, !dbg !23
37  ret void, !dbg !24
38}
39
40declare void @sink()
41
42; Function Attrs: nounwind readnone
43declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
44
45attributes #0 = { nounwind ssp uwtable  }
46attributes #2 = { nounwind readnone }
47attributes #3 = { nounwind }
48
49!llvm.dbg.cu = !{!0}
50!llvm.module.flags = !{!13, !14, !15}
51!llvm.ident = !{!16}
52
53!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
54!1 = !DIFile(filename: "t.c", directory: "/path/to/dir")
55!2 = !{}
56!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
57!5 = !DISubroutineType(types: !6)
58!6 = !{null}
59!7 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !8, isLocal: true, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !11)
60!8 = !DISubroutineType(types: !9)
61!9 = !{null, !10}
62!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
63!11 = !{!12}
64!12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 2, type: !10)
65!13 = !{i32 2, !"Dwarf Version", i32 2}
66!14 = !{i32 2, !"Debug Info Version", i32 3}
67!15 = !{i32 1, !"PIC Level", i32 2}
68!16 = !{!"clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)"}
69!17 = !DIExpression()
70!18 = !DILocation(line: 2, column: 52, scope: !7, inlinedAt: !19)
71!19 = distinct !DILocation(line: 4, column: 3, scope: !4)
72!20 = !DILocation(line: 2, column: 57, scope: !7, inlinedAt: !19)
73!21 = !DILocation(line: 2, column: 52, scope: !7, inlinedAt: !22)
74!22 = distinct !DILocation(line: 5, column: 3, scope: !4)
75!23 = !DILocation(line: 2, column: 57, scope: !7, inlinedAt: !22)
76!24 = !DILocation(line: 6, column: 1, scope: !4)
77