[bazel] Replace strip_include_prefix in lldb with includes (#125293)
[llvm-project.git] / llvm / test / DebugInfo / X86 / vla.ll
blobf90cf2aadc71c9f326118cf3275facc09bdb847b
1 ; RUN: llc -O0 -mtriple=x86_64-apple-darwin -filetype=asm %s -o - | FileCheck %s
2 ; RUN: llc --try-experimental-debuginfo-iterators -O0 -mtriple=x86_64-apple-darwin -filetype=asm %s -o - | FileCheck %s
3 ; Ensure that we generate an indirect location for the variable length array a.
4 ; CHECK: ##DEBUG_VALUE: vla:a <- [DW_OP_deref] [{{\$r[a-z]+}}+0]
5 ; CHECK: DW_OP_breg{{[0-9]}}
6 ; rdar://problem/13658587
8 ; generated from:
10 ; int vla(int n) {
11 ;   int a[n];
12 ;   a[0] = 42;
13 ;   return a[n-1];
14 ; }
16 ; int main(int argc, char** argv) {
17 ;    return vla(argc);
18 ; }
20 ; ModuleID = 'vla.c'
21 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
22 target triple = "x86_64-apple-macosx10.8.0"
24 ; Function Attrs: nounwind ssp uwtable
25 define i32 @vla(i32 %n) nounwind ssp uwtable !dbg !4 {
26 entry:
27   %n.addr = alloca i32, align 4
28   %saved_stack = alloca ptr
29   %cleanup.dest.slot = alloca i32
30   store i32 %n, ptr %n.addr, align 4
31   call void @llvm.dbg.declare(metadata ptr %n.addr, metadata !15, metadata !DIExpression()), !dbg !16
32   %0 = load i32, ptr %n.addr, align 4, !dbg !17
33   %1 = zext i32 %0 to i64, !dbg !17
34   %2 = call ptr @llvm.stacksave(), !dbg !17
35   store ptr %2, ptr %saved_stack, !dbg !17
36   %vla = alloca i32, i64 %1, align 16, !dbg !17
37   call void @llvm.dbg.declare(metadata ptr %vla, metadata !18, metadata !DIExpression(DW_OP_deref)), !dbg !17
38   store i32 42, ptr %vla, align 4, !dbg !22
39   %3 = load i32, ptr %n.addr, align 4, !dbg !23
40   %sub = sub nsw i32 %3, 1, !dbg !23
41   %idxprom = sext i32 %sub to i64, !dbg !23
42   %arrayidx1 = getelementptr inbounds i32, ptr %vla, i64 %idxprom, !dbg !23
43   %4 = load i32, ptr %arrayidx1, align 4, !dbg !23
44   store i32 1, ptr %cleanup.dest.slot
45   %5 = load ptr, ptr %saved_stack, !dbg !24
46   call void @llvm.stackrestore(ptr %5), !dbg !24
47   ret i32 %4, !dbg !23
50 ; Function Attrs: nounwind readnone
51 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
53 ; Function Attrs: nounwind
54 declare ptr @llvm.stacksave() nounwind
56 ; Function Attrs: nounwind
57 declare void @llvm.stackrestore(ptr) nounwind
59 ; Function Attrs: nounwind ssp uwtable
60 define i32 @main(i32 %argc, ptr %argv) nounwind ssp uwtable !dbg !9 {
61 entry:
62   %retval = alloca i32, align 4
63   %argc.addr = alloca i32, align 4
64   %argv.addr = alloca ptr, align 8
65   store i32 0, ptr %retval
66   store i32 %argc, ptr %argc.addr, align 4
67   call void @llvm.dbg.declare(metadata ptr %argc.addr, metadata !25, metadata !DIExpression()), !dbg !26
68   store ptr %argv, ptr %argv.addr, align 8
69   call void @llvm.dbg.declare(metadata ptr %argv.addr, metadata !27, metadata !DIExpression()), !dbg !26
70   %0 = load i32, ptr %argc.addr, align 4, !dbg !28
71   %call = call i32 @vla(i32 %0), !dbg !28
72   ret i32 %call, !dbg !28
75 !llvm.dbg.cu = !{!0}
76 !llvm.module.flags = !{!29}
78 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.3 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
79 !1 = !DIFile(filename: "vla.c", directory: "")
80 !2 = !{}
81 !4 = distinct !DISubprogram(name: "vla", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, retainedNodes: !2)
82 !5 = !DIFile(filename: "vla.c", directory: "")
83 !6 = !DISubroutineType(types: !7)
84 !7 = !{!8, !8}
85 !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
86 !9 = distinct !DISubprogram(name: "main", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !5, type: !10, retainedNodes: !2)
87 !10 = !DISubroutineType(types: !11)
88 !11 = !{!8, !8, !12}
89 !12 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !13)
90 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !14)
91 !14 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
92 !15 = !DILocalVariable(name: "n", line: 1, arg: 1, scope: !4, file: !5, type: !8)
93 !16 = !DILocation(line: 1, scope: !4)
94 !17 = !DILocation(line: 2, scope: !4)
95 !18 = !DILocalVariable(name: "a", line: 2, scope: !4, file: !5, type: !19)
96 !19 = !DICompositeType(tag: DW_TAG_array_type, align: 32, baseType: !8, elements: !20)
97 !20 = !{!21}
98 !21 = !DISubrange(count: -1)
99 !22 = !DILocation(line: 3, scope: !4)
100 !23 = !DILocation(line: 4, scope: !4)
101 !24 = !DILocation(line: 5, scope: !4)
102 !25 = !DILocalVariable(name: "argc", line: 7, arg: 1, scope: !9, file: !5, type: !8)
103 !26 = !DILocation(line: 7, scope: !9)
104 !27 = !DILocalVariable(name: "argv", line: 7, arg: 2, scope: !9, file: !5, type: !12)
105 !28 = !DILocation(line: 8, scope: !9)
106 !29 = !{i32 1, !"Debug Info Version", i32 3}