Fix line endings on Transforms/Inline/inline_dbg_declare.ll
[oota-llvm.git] / test / Transforms / Inline / inline_dbg_declare.ll
1 ; RUN: opt < %s -S -inline | FileCheck %s
2 ;
3 ; The purpose of this test is to check that inline pass preserves debug info
4 ; for variable using the dbg.declare intrinsic.
5 ;
6 ;; This test was generated by running this command:
7 ;; clang.exe -S -O0 -emit-llvm -g foo.c
8 ;;
9 ;; foo.c
10 ;; ==========================
11 ;; float foo(float x)
12 ;; {
13 ;;    return x;
14 ;; }
15 ;;
16 ;; void bar(float *dst)
17 ;; {
18 ;;    dst[0] = foo(dst[0]);
19 ;; }
20 ;; ==========================
21
22 target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
23 target triple = "i686-pc-windows-msvc"
24
25 ; Function Attrs: nounwind
26 define float @foo(float %x) #0 {
27 entry:
28   %x.addr = alloca float, align 4
29   store float %x, float* %x.addr, align 4
30   call void @llvm.dbg.declare(metadata float* %x.addr, metadata !16, metadata !17), !dbg !18
31   %0 = load float, float* %x.addr, align 4, !dbg !19
32   ret float %0, !dbg !19
33 }
34
35 ; Function Attrs: nounwind readnone
36 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
37
38 ; CHECK: define void @bar
39
40 ; Function Attrs: nounwind
41 define void @bar(float* %dst) #0 {
42 entry:
43
44 ; CHECK: [[x_addr_i:%[a-zA-Z0-9.]+]] = alloca float, align 4
45
46   %dst.addr = alloca float*, align 4
47   store float* %dst, float** %dst.addr, align 4
48   call void @llvm.dbg.declare(metadata float** %dst.addr, metadata !20, metadata !17), !dbg !21
49   %0 = load float*, float** %dst.addr, align 4, !dbg !22
50   %arrayidx = getelementptr inbounds float, float* %0, i32 0, !dbg !22
51   %1 = load float, float* %arrayidx, align 4, !dbg !22
52   %call = call float @foo(float %1), !dbg !22
53
54 ; CHECK-NOT: call float @foo
55 ; CHECK: void @llvm.dbg.declare(metadata float* [[x_addr_i]], metadata [[m23:![0-9]+]], metadata !17), !dbg [[m24:![0-9]+]]
56
57   %2 = load float*, float** %dst.addr, align 4, !dbg !22
58   %arrayidx1 = getelementptr inbounds float, float* %2, i32 0, !dbg !22
59   store float %call, float* %arrayidx1, align 4, !dbg !22
60   ret void, !dbg !23
61 }
62
63 attributes #0 = { nounwind }
64 attributes #1 = { nounwind readnone }
65
66 !llvm.dbg.cu = !{!0}
67 !llvm.module.flags = !{!13, !14}
68 !llvm.ident = !{!15}
69
70 !0 = !{!"0x11\0012\00clang version 3.6.0 (trunk)\000\00\000\00\001", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [foo.c] [DW_LANG_C99]
71 !1 = !{!"foo.c", !""}
72 !2 = !{}
73 !3 = !{!4, !9}
74 !4 = !{!"0x2e\00foo\00foo\00\001\000\001\000\000\00256\000\002", !1, !5, !6, null, float (float)* @foo, null, null, !2} ; [ DW_TAG_subprogram ] [line 1] [def] [scope 2] [foo]
75 !5 = !{!"0x29", !1}    ; [ DW_TAG_file_type ] [foo.c]
76 !6 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
77 !7 = !{!8, !8}
78 !8 = !{!"0x24\00float\000\0032\0032\000\000\004", null, null} ; [ DW_TAG_base_type ] [float] [line 0, size 32, align 32, offset 0, enc DW_ATE_float]
79 !9 = !{!"0x2e\00bar\00bar\00\006\000\001\000\000\00256\000\007", !1, !5, !10, null, void (float*)* @bar, null, null, !2} ; [ DW_TAG_subprogram ] [line 6] [def] [scope 7] [bar]
80 !10 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !11, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
81 !11 = !{null, !12}
82 !12 = !{!"0xf\00\000\0032\0032\000\000", null, null, !8} ; [ DW_TAG_pointer_type ] [line 0, size 32, align 32, offset 0] [from float]
83 !13 = !{i32 2, !"Dwarf Version", i32 4}
84 !14 = !{i32 2, !"Debug Info Version", i32 2}
85 !15 = !{!"clang version 3.6.0 (trunk)"}
86 !16 = !{!"0x101\00x\0016777217\000", !4, !5, !8} ; [ DW_TAG_arg_variable ] [x] [line 1]
87 !17 = !{!"0x102"}               ; [ DW_TAG_expression ]
88 !18 = !MDLocation(line: 1, column: 17, scope: !4)
89 !19 = !MDLocation(line: 3, column: 5, scope: !4)
90 !20 = !{!"0x101\00dst\0016777222\000", !9, !5, !12} ; [ DW_TAG_arg_variable ] [dst] [line 6]
91 !21 = !MDLocation(line: 6, column: 17, scope: !9)
92 !22 = !MDLocation(line: 8, column: 14, scope: !9)
93 !23 = !MDLocation(line: 9, column: 1, scope: !9)
94
95 ; CHECK: [[CALL_SITE:![0-9]+]] = distinct !MDLocation(line: 8, column: 14, scope: !9)
96 ; CHECK: [[m23]] = !{!"0x101\00x\0016777217\000", !4, !5, !8, [[CALL_SITE]]} ; [ DW_TAG_arg_variable ] [x] [line 1]
97 ; CHECK: [[m24]] = !MDLocation(line: 1, column: 17, scope: !4, inlinedAt: [[CALL_SITE]])