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