]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/blob - test/Transforms/Inline/inline_dbg_declare.ll
IR: Move MDLocation into place
[opencl/llvm.git] / test / Transforms / Inline / inline_dbg_declare.ll
1 ; RUN: opt < %s -S -inline | FileCheck %s\r
2 ;\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
5 ;\r
6 ;; This test was generated by running this command:\r
7 ;; clang.exe -S -O0 -emit-llvm -g foo.c\r
8 ;;\r
9 ;; foo.c\r
10 ;; ==========================\r
11 ;; float foo(float x)\r
12 ;; {\r
13 ;;    return x;\r
14 ;; }\r
15 ;;\r
16 ;; void bar(float *dst)\r
17 ;; {\r
18 ;;    dst[0] = foo(dst[0]);\r
19 ;; }\r
20 ;; ==========================\r
21 \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
24 \r
25 ; Function Attrs: nounwind\r
26 define float @foo(float %x) #0 {\r
27 entry:\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
33 }\r
34 \r
35 ; Function Attrs: nounwind readnone\r
36 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1\r
37 \r
38 ; CHECK: define void @bar\r
39 \r
40 ; Function Attrs: nounwind\r
41 define void @bar(float* %dst) #0 {\r
42 entry:\r
43 \r
44 ; CHECK: [[x_addr_i:%[a-zA-Z0-9.]+]] = alloca float, align 4\r
45 \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
53 \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
56 \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
60   ret void, !dbg !23\r
61 }\r
62 \r
63 attributes #0 = { nounwind }\r
64 attributes #1 = { nounwind readnone }\r
65 \r
66 !llvm.dbg.cu = !{!0}\r
67 !llvm.module.flags = !{!13, !14}\r
68 !llvm.ident = !{!15}\r
69 \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
72 !2 = !{}\r
73 !3 = !{!4, !9}\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
77 !7 = !{!8, !8}\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
81 !11 = !{null, !12}\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 = !MDLocation(line: 1, column: 17, scope: !4)\r
89 !19 = !MDLocation(line: 3, column: 5, scope: !4)\r
90 !20 = !{!"0x101\00dst\0016777222\000", !9, !5, !12} ; [ DW_TAG_arg_variable ] [dst] [line 6]\r
91 !21 = !MDLocation(line: 6, column: 17, scope: !9)\r
92 !22 = !MDLocation(line: 8, column: 14, scope: !9)\r
93 !23 = !MDLocation(line: 9, column: 1, scope: !9)\r
94 \r
95 ; CHECK: [[m23]] = !{!"0x101\00x\0016777217\000", !4, !5, !8, !22} ; [ DW_TAG_arg_variable ] [x] [line 1]\r
96 ; CHECK: [[m24]] = !MDLocation(line: 1, column: 17, scope: !4, inlinedAt: !22)\r