xref: /llvm-project/llvm/test/CodeGen/ARM/2010-08-04-StackVariable.ll (revision dbd53a1f0c939a55e7719c39d08179468f9ad3dc)
1; RUN: llc -mtriple=arm-apple-darwin -O0 -o - %s | FileCheck %s
2; Use DW_OP_breg in variable's location expression if the variable is in a stack slot.
3
4; CHECK: @ DW_OP_breg
5
6%struct.SVal = type { i8*, i32 }
7
8define i32 @_Z3fooi4SVal(i32 %i, %struct.SVal* noalias %location) #0 !dbg !4 {
9entry:
10  %"alloca point" = bitcast i32 0 to i32
11  call void @llvm.dbg.value(metadata i32 %i, metadata !21, metadata !DIExpression()), !dbg !22
12  call void @llvm.dbg.value(metadata %struct.SVal* %location, metadata !23, metadata !DIExpression()), !dbg !22
13  %tmp = icmp ne i32 %i, 0, !dbg !25
14  br i1 %tmp, label %bb, label %bb1, !dbg !25
15
16bb:                                               ; preds = %entry
17  %tmp1 = getelementptr inbounds %struct.SVal, %struct.SVal* %location, i32 0, i32 1, !dbg !27
18  %tmp2 = load i32, i32* %tmp1, align 8, !dbg !27
19  %tmp3 = add i32 %tmp2, %i, !dbg !27
20  br label %bb2, !dbg !27
21
22bb1:                                              ; preds = %entry
23  %tmp4 = getelementptr inbounds %struct.SVal, %struct.SVal* %location, i32 0, i32 1, !dbg !28
24  %tmp5 = load i32, i32* %tmp4, align 8, !dbg !28
25  %tmp6 = sub i32 %tmp5, 1, !dbg !28
26  br label %bb2, !dbg !28
27
28bb2:                                              ; preds = %bb1, %bb
29  %.0 = phi i32 [ %tmp3, %bb ], [ %tmp6, %bb1 ]
30  br label %return, !dbg !27
31
32return:                                           ; preds = %bb2
33  ret i32 %.0, !dbg !27
34}
35
36declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
37declare void @llvm.dbg.value(metadata, metadata, metadata) #1
38
39attributes #0 = { nounwind ssp }
40attributes #1 = { nounwind readnone speculatable willreturn }
41
42!llvm.dbg.cu = !{!0}
43!llvm.module.flags = !{!3}
44
45!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
46!1 = !DIFile(filename: "small.cc", directory: "/Users/manav/R8248330")
47!2 = !{}
48!3 = !{i32 1, !"Debug Info Version", i32 3}
49!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi4SVal", scope: !1, file: !1, line: 16, type: !5, virtualIndex: 6, spFlags: DISPFlagDefinition, unit: !0)
50!5 = !DISubroutineType(types: !6)
51!6 = !{!7, !7, !8}
52!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
53!8 = !DICompositeType(tag: DW_TAG_structure_type, name: "SVal", file: !1, line: 1, size: 64, align: 64, elements: !9)
54!9 = !{!10, !12, !14, !18}
55!10 = !DIDerivedType(tag: DW_TAG_member, name: "Data", scope: !8, file: !1, line: 7, baseType: !11, size: 64, align: 64)
56!11 = !DIDerivedType(tag: DW_TAG_pointer_type, file: !1, baseType: null, size: 64, align: 64)
57!12 = !DIDerivedType(tag: DW_TAG_member, name: "Kind", scope: !8, file: !1, line: 8, baseType: !13, size: 32, align: 32, offset: 64)
58!13 = !DIBasicType(name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
59!14 = !DISubprogram(name: "SVal", scope: !8, file: !1, line: 11, type: !15, virtualIndex: 6, spFlags: 0)
60!15 = !DISubroutineType(types: !16)
61!16 = !{null, !17}
62!17 = !DIDerivedType(tag: DW_TAG_pointer_type, file: !1, baseType: !8, size: 64, align: 64, flags: DIFlagArtificial)
63!18 = !DISubprogram(name: "~SVal", scope: !8, file: !1, line: 12, type: !19, virtualIndex: 6, spFlags: 0)
64!19 = !DISubroutineType(types: !20)
65!20 = !{null, !17, !7}
66!21 = !DILocalVariable(name: "i", arg: 1, scope: !4, file: !1, line: 16, type: !7)
67!22 = !DILocation(line: 16, scope: !4)
68!23 = !DILocalVariable(name: "location", arg: 2, scope: !4, file: !1, line: 16, type: !24)
69!24 = !DIDerivedType(tag: DW_TAG_reference_type, name: "SVal", scope: !1, file: !1, baseType: !8, size: 32, align: 32)
70!25 = !DILocation(line: 17, scope: !26)
71!26 = distinct !DILexicalBlock(scope: !4, file: !1, line: 16)
72!27 = !DILocation(line: 18, scope: !26)
73!28 = !DILocation(line: 20, scope: !26)
74