1; RUN: llc -O2 < %s | FileCheck %s
2; RUN: llc -O2 -regalloc=basic < %s | FileCheck %s
3; Test to check that unused argument 'this' is not undefined in debug info.
4
5target triple = "x86_64-apple-darwin10.2"
6
7%struct.foo = type { i32 }
8
9@llvm.used = appending global [1 x i8*] [i8* bitcast (i32 (%struct.foo*, i32)* @_ZN3foo3bazEi to i8*)], section "llvm.metadata"
10
11; Function Attrs: noinline nounwind optsize readnone ssp
12define i32 @_ZN3foo3bazEi(%struct.foo* nocapture %this, i32 %x) #0 align 2 !dbg !4 {
13entry:
14  ; CHECK: DEBUG_VALUE: baz:this <- $rdi{{$}}
15  tail call void @llvm.dbg.value(metadata %struct.foo* %this, i64 0, metadata !13, metadata !16), !dbg !17
16  tail call void @llvm.dbg.value(metadata i32 %x, i64 0, metadata !18, metadata !16), !dbg !17
17  %0 = mul nsw i32 %x, 7, !dbg !19
18  %1 = add nsw i32 %0, 1, !dbg !19
19  ret i32 %1, !dbg !19
20}
21
22; Function Attrs: nounwind readnone
23declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
24
25attributes #0 = { noinline nounwind optsize readnone ssp }
26attributes #1 = { nounwind readnone }
27
28!llvm.dbg.cu = !{!0}
29!llvm.module.flags = !{!3}
30
31!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "4.2.1 LLVM build", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
32!1 = !DIFile(filename: "foo.cp", directory: "/tmp/")
33!2 = !{}
34!3 = !{i32 1, !"Debug Info Version", i32 3}
35!4 = distinct !DISubprogram(name: "baz", linkageName: "_ZN3foo3bazEi", scope: !5, file: !1, line: 15, type: !10, isLocal: false, isDefinition: true, scopeLine: 15, virtualIndex: 6, isOptimized: true, unit: !0)
36!5 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", scope: !1, file: !1, line: 3, size: 32, align: 32, elements: !6)
37!6 = !{!7, !9, !4}
38!7 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !5, file: !1, line: 8, baseType: !8, size: 32, align: 32)
39!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
40!9 = distinct !DISubprogram(name: "bar", linkageName: "_ZN3foo3barEi", scope: !5, file: !1, line: 11, type: !10, isLocal: false, isDefinition: true, scopeLine: 11, virtualIndex: 6, isOptimized: true, unit: !0)
41!10 = !DISubroutineType(types: !11)
42!11 = !{!8, !12, !8}
43!12 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !1, file: !1, baseType: !5, size: 64, align: 64, flags: DIFlagArtificial)
44!13 = !DILocalVariable(name: "this", arg: 1, scope: !4, file: !1, line: 15, type: !14)
45!14 = !DIDerivedType(tag: DW_TAG_const_type, scope: !1, file: !1, baseType: !15, size: 64, align: 64, flags: DIFlagArtificial)
46!15 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !1, file: !1, baseType: !5, size: 64, align: 64)
47!16 = !DIExpression()
48!17 = !DILocation(line: 0, scope: !4)
49!18 = !DILocalVariable(name: "x", arg: 2, scope: !4, file: !1, line: 15, type: !8)
50!19 = !DILocation(line: 16, scope: !20)
51!20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 15)
52