xref: /llvm-project/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll (revision 04c27852e47093f7efa18609dbf57b3ce58a3ffa)
1; RUN: llc -mtriple i686-pc-cygwin -O2 %s -o - | FileCheck %s
2; RUN: llc --try-experimental-debuginfo-iterators -mtriple i686-pc-cygwin -O2 %s -o - | FileCheck %s
3; Check struct X for dead variable xyz from inlined function foo.
4
5; CHECK: .section .debug_info,"dr"
6; CHECK:	DW_TAG_structure_type
7; CHECK-NEXT:	info_string
8
9source_filename = "test/DebugInfo/X86/InlinedFnLocalVar.ll"
10
11@i = common global i32 0, !dbg !0
12
13; Function Attrs: nounwind readnone
14declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
15
16; Function Attrs: nounwind readnone
17declare void @llvm.dbg.value(metadata, metadata, metadata) #0
18
19; Function Attrs: nounwind ssp
20define i32 @bar() #1 !dbg !8 {
21entry:
22  %0 = load i32, ptr @i, align 4, !dbg !11
23  tail call void @llvm.dbg.value(metadata i32 %0, metadata !13, metadata !24), !dbg !25
24  tail call void @llvm.dbg.declare(metadata !5, metadata !18, metadata !24), !dbg !26
25  %1 = mul nsw i32 %0, %0, !dbg !27
26  store i32 %1, ptr @i, align 4, !dbg !11
27  ret i32 %1, !dbg !28
28}
29
30attributes #0 = { nounwind readnone }
31attributes #1 = { nounwind ssp }
32
33!llvm.dbg.cu = !{!4}
34!llvm.module.flags = !{!7}
35
36!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
37!1 = !DIGlobalVariable(name: "i", scope: !2, file: !2, line: 5, type: !3, isLocal: false, isDefinition: true)
38!2 = !DIFile(filename: "bar.c", directory: "/tmp/")
39!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
40!4 = distinct !DICompileUnit(language: DW_LANG_C89, file: !2, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
41!5 = !{}
42!6 = !{!0}
43!7 = !{i32 1, !"Debug Info Version", i32 3}
44!8 = distinct !DISubprogram(name: "bar", linkageName: "bar", scope: !2, file: !2, line: 14, type: !9, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !4)
45!9 = !DISubroutineType(types: !10)
46!10 = !{!3}
47!11 = !DILocation(line: 15, scope: !12)
48!12 = distinct !DILexicalBlock(scope: !8, file: !2, line: 14)
49!13 = !DILocalVariable(name: "j", arg: 1, scope: !14, file: !2, line: 9, type: !3)
50!14 = distinct !DISubprogram(name: "foo", scope: !2, file: !2, line: 9, type: !15, isLocal: true, isDefinition: true, scopeLine: 9, virtualIndex: 6, isOptimized: true, unit: !4, retainedNodes: !17)
51!15 = !DISubroutineType(types: !16)
52!16 = !{!3, !3}
53!17 = !{!13, !18}
54!18 = !DILocalVariable(name: "xyz", scope: !19, file: !2, line: 10, type: !20)
55!19 = distinct !DILexicalBlock(scope: !14, file: !2, line: 9)
56!20 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !14, file: !2, line: 10, size: 64, align: 32, elements: !21)
57!21 = !{!22, !23}
58!22 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !20, file: !2, line: 10, baseType: !3, size: 32, align: 32)
59!23 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !20, file: !2, line: 10, baseType: !3, size: 32, align: 32, offset: 32)
60!24 = !DIExpression()
61!25 = !DILocation(line: 9, scope: !14, inlinedAt: !11)
62!26 = !DILocation(line: 9, scope: !19, inlinedAt: !11)
63!27 = !DILocation(line: 11, scope: !19, inlinedAt: !11)
64!28 = !DILocation(line: 16, scope: !12)
65
66