xref: /llvm-project/llvm/test/DebugInfo/Generic/dead-argument-order.ll (revision 10b03e66629aedad79a804e22d23b575077303b3)
1; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s
2; RUN: %llc_dwarf --try-experimental-debuginfo-iterators -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s
3
4; Built from the following source with clang -O1
5; struct S { int i; };
6; int function(struct S s, int i) { return s.i + i; }
7
8; Due to the X86_64 ABI, 's' is passed in registers and once optimized, the
9; entirety of 's' is never reconstituted, since only the int is required, and
10; thus the variable's location is unknown/dead to debug info.
11
12; Future/current work should enable us to describe partial variables, which, in
13; this case, happens to be the entire variable.
14
15; CHECK: DW_TAG_subprogram
16; CHECK-NOT: DW_TAG
17; CHECK:   DW_AT_name ("function")
18; CHECK-NOT: {{DW_TAG|NULL}}
19; CHECK:   DW_TAG_formal_parameter
20; CHECK-NOT: DW_TAG
21; CHECK:     DW_AT_name ("s")
22; CHECK-NOT: DW_TAG
23; FIXME: Even though 's' is never reconstituted into a struct, the one member
24; variable is still live and used, and so we should be able to describe 's's
25; location as the location of that int.
26; CHECK-NOT: DW_AT_location
27; CHECK-NOT: {{DW_TAG|NULL}}
28; CHECK:   DW_TAG_formal_parameter
29; CHECK-NOT: DW_TAG
30; CHECK:     DW_AT_location
31; CHECK-NOT: DW_TAG
32; CHECK:     DW_AT_name ("i")
33
34
35%struct.S = type { i32 }
36
37; Function Attrs: nounwind readnone uwtable
38define i32 @_Z8function1Si(i32 %s.coerce, i32 %i) #0 !dbg !9 {
39entry:
40  tail call void @llvm.dbg.declare(metadata ptr undef, metadata !14, metadata !DIExpression()), !dbg !20
41  tail call void @llvm.dbg.value(metadata i32 %i, metadata !15, metadata !DIExpression()), !dbg !20
42  %add = add nsw i32 %i, %s.coerce, !dbg !20
43  ret i32 %add, !dbg !20
44}
45
46; Function Attrs: nounwind readnone
47declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
48
49; Function Attrs: nounwind readnone
50declare void @llvm.dbg.value(metadata, metadata, metadata) #1
51
52attributes #0 = { nounwind readnone uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
53attributes #1 = { nounwind readnone }
54
55!llvm.dbg.cu = !{!0}
56!llvm.module.flags = !{!16, !17}
57!llvm.ident = !{!18}
58
59!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
60!1 = !DIFile(filename: "dead-argument-order.cpp", directory: "/tmp/dbginfo")
61!2 = !{}
62!3 = !{!4}
63!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "S", line: 1, size: 32, align: 32, file: !1, elements: !5, identifier: "_ZTS1S")
64!5 = !{!6}
65!6 = !DIDerivedType(tag: DW_TAG_member, name: "i", line: 1, size: 32, align: 32, file: !1, scope: !4, baseType: !7)
66!7 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
67!9 = distinct !DISubprogram(name: "function", linkageName: "_Z8function1Si", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 2, file: !1, scope: !10, type: !11, retainedNodes: !13)
68!10 = !DIFile(filename: "dead-argument-order.cpp", directory: "/tmp/dbginfo")
69!11 = !DISubroutineType(types: !12)
70!12 = !{!7, !4, !7}
71!13 = !{!14, !15}
72!14 = !DILocalVariable(name: "s", line: 2, arg: 1, scope: !9, file: !10, type: !4)
73!15 = !DILocalVariable(name: "i", line: 2, arg: 2, scope: !9, file: !10, type: !7)
74!16 = !{i32 2, !"Dwarf Version", i32 4}
75!17 = !{i32 2, !"Debug Info Version", i32 3}
76!18 = !{!"clang version 3.5.0 "}
77!19 = !{ptr undef}
78!20 = !DILocation(line: 2, scope: !9)
79
80