1 ; RUN: opt < %s -S -inline | FileCheck %s
\r
3 ; The purpose of this test is to check that inline pass preserves debug info
\r
4 ; for variable using the dbg.declare intrinsic.
\r
6 ;; This test was generated by running this command:
\r
7 ;; clang.exe -S -O0 -emit-llvm -g foo.c
\r
10 ;; ==========================
\r
11 ;; float foo(float x)
\r
16 ;; void bar(float *dst)
\r
18 ;; dst[0] = foo(dst[0]);
\r
20 ;; ==========================
\r
22 target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
\r
23 target triple = "i686-pc-windows-msvc"
\r
25 ; Function Attrs: nounwind
\r
26 define float @foo(float %x) #0 {
\r
28 %x.addr = alloca float, align 4
\r
29 store float %x, float* %x.addr, align 4
\r
30 call void @llvm.dbg.declare(metadata float* %x.addr, metadata !16, metadata !17), !dbg !18
\r
31 %0 = load float* %x.addr, align 4, !dbg !19
\r
32 ret float %0, !dbg !19
\r
35 ; Function Attrs: nounwind readnone
\r
36 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
\r
38 ; CHECK: define void @bar
\r
40 ; Function Attrs: nounwind
\r
41 define void @bar(float* %dst) #0 {
\r
44 ; CHECK: [[x_addr_i:%[a-zA-Z0-9.]+]] = alloca float, align 4
\r
46 %dst.addr = alloca float*, align 4
\r
47 store float* %dst, float** %dst.addr, align 4
\r
48 call void @llvm.dbg.declare(metadata float** %dst.addr, metadata !20, metadata !17), !dbg !21
\r
49 %0 = load float** %dst.addr, align 4, !dbg !22
\r
50 %arrayidx = getelementptr inbounds float* %0, i32 0, !dbg !22
\r
51 %1 = load float* %arrayidx, align 4, !dbg !22
\r
52 %call = call float @foo(float %1), !dbg !22
\r
54 ; CHECK-NOT: call float @foo
\r
55 ; CHECK: void @llvm.dbg.declare(metadata float* [[x_addr_i]], metadata [[m23:![0-9]+]], metadata !17), !dbg [[m24:![0-9]+]]
\r
57 %2 = load float** %dst.addr, align 4, !dbg !22
\r
58 %arrayidx1 = getelementptr inbounds float* %2, i32 0, !dbg !22
\r
59 store float %call, float* %arrayidx1, align 4, !dbg !22
\r
63 attributes #0 = { nounwind }
\r
64 attributes #1 = { nounwind readnone }
\r
66 !llvm.dbg.cu = !{!0}
\r
67 !llvm.module.flags = !{!13, !14}
\r
68 !llvm.ident = !{!15}
\r
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]
\r
71 !1 = !{!"foo.c", !""}
\r
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]
\r
75 !5 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [foo.c]
\r
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 ]
\r
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]
\r
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]
\r
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 ]
\r
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]
\r
83 !13 = !{i32 2, !"Dwarf Version", i32 4}
\r
84 !14 = !{i32 2, !"Debug Info Version", i32 2}
\r
85 !15 = !{!"clang version 3.6.0 (trunk)"}
\r
86 !16 = !{!"0x101\00x\0016777217\000", !4, !5, !8} ; [ DW_TAG_arg_variable ] [x] [line 1]
\r
87 !17 = !{!"0x102"} ; [ DW_TAG_expression ]
\r
88 !18 = !{i32 1, i32 17, !4, null}
\r
89 !19 = !{i32 3, i32 5, !4, null}
\r
90 !20 = !{!"0x101\00dst\0016777222\000", !9, !5, !12} ; [ DW_TAG_arg_variable ] [dst] [line 6]
\r
91 !21 = !{i32 6, i32 17, !9, null}
\r
92 !22 = !{i32 8, i32 14, !9, null}
\r
93 !23 = !{i32 9, i32 1, !9, null}
\r
95 ; CHECK: [[m23]] = !{!"0x101\00x\0016777217\000", !4, !5, !8, !22} ; [ DW_TAG_arg_variable ] [x] [line 1]
\r
96 ; CHECK: [[m24]] = !{i32 1, i32 17, !4, !22}
\r