a1420a0ba2ef3075203d0ed2233c9bea4afb544a
[oota-llvm.git] / test / DebugInfo / X86 / dbg-declare.ll
1 ; RUN: llc < %s -O0 -mtriple x86_64-apple-darwin
2 ; <rdar://problem/11134152>
3
4 define i32 @foo(i32* %x) nounwind uwtable ssp {
5 entry:
6   %x.addr = alloca i32*, align 8
7   %saved_stack = alloca i8*
8   %cleanup.dest.slot = alloca i32
9   store i32* %x, i32** %x.addr, align 8
10   call void @llvm.dbg.declare(metadata i32** %x.addr, metadata !14, metadata !DIExpression()), !dbg !15
11   %0 = load i32*, i32** %x.addr, align 8, !dbg !16
12   %1 = load i32, i32* %0, align 4, !dbg !16
13   %2 = zext i32 %1 to i64, !dbg !16
14   %3 = call i8* @llvm.stacksave(), !dbg !16
15   store i8* %3, i8** %saved_stack, !dbg !16
16   %vla = alloca i8, i64 %2, align 16, !dbg !16
17   call void @llvm.dbg.declare(metadata i8* %vla, metadata !18, metadata !DIExpression()), !dbg !23
18   store i32 1, i32* %cleanup.dest.slot
19   %4 = load i8*, i8** %saved_stack, !dbg !24
20   call void @llvm.stackrestore(i8* %4), !dbg !24
21   ret i32 0, !dbg !25
22 }
23
24 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
25
26 declare i8* @llvm.stacksave() nounwind
27
28 declare void @llvm.stackrestore(i8*) nounwind
29
30 !llvm.dbg.cu = !{!0}
31 !llvm.module.flags = !{!27}
32
33 !0 = !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.1 (trunk 153698)", isOptimized: false, emissionKind: 0, file: !26, enums: !1, retainedTypes: !1, subprograms: !3, globals: !1)
34 !1 = !{}
35 !3 = !{!5}
36 !5 = !DISubprogram(name: "foo", line: 6, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, file: !26, scope: !0, type: !7, function: i32 (i32*)* @foo)
37 !6 = !DIFile(filename: "20020104-2.c", directory: "/Volumes/Sandbox/llvm")
38 !7 = !DISubroutineType(types: !8)
39 !8 = !{!9, !10}
40 !9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
41 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !11)
42 !11 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !9)
43 !14 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "x", line: 5, arg: 1, scope: !5, file: !6, type: !10)
44 !15 = !DILocation(line: 5, column: 21, scope: !5)
45 !16 = !DILocation(line: 7, column: 13, scope: !17)
46 !17 = distinct !DILexicalBlock(line: 6, column: 1, file: !26, scope: !5)
47 !18 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "a", line: 7, scope: !17, file: !6, type: !19)
48 !19 = !DICompositeType(tag: DW_TAG_array_type, align: 8, baseType: !20, elements: !21)
49 !20 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
50 !21 = !{!22}
51 !22 = !DISubrange(count: -1)
52 !23 = !DILocation(line: 7, column: 8, scope: !17)
53 !24 = !DILocation(line: 9, column: 1, scope: !17)
54 !25 = !DILocation(line: 8, column: 3, scope: !17)
55 !26 = !DIFile(filename: "20020104-2.c", directory: "/Volumes/Sandbox/llvm")
56 !27 = !{i32 1, !"Debug Info Version", i32 3}