Add CodeGen tests for the recent SelectionDAG transforms
[oota-llvm.git] / test / Debugger / funccall.ll
1 ;; RUN: echo create > %t.commands
2 ;; RUN: echo s >> %t.commands
3 ;; RUN: echo s >> %t.commands
4 ;; RUN: echo finish >> %t.commands
5 ;; RUN: echo bt >> %t.commands
6 ;; RUN: echo q >> %t.commands
7 ;; RUN: echo y >> %t.commands
8 ;; RUN: llvm-as -f %s -o %t.bc
9 ;; RUN: llvm-db %t.bc < %t.commands | grep 'in main at funccall.c:11:2'
10
11
12 ;; Debugger type declarations
13 %lldb.compile_unit = type { uint, ushort, ushort, sbyte*, sbyte*, sbyte*, {}* }
14 %lldb.global = type { uint, %lldb.compile_unit*, sbyte*, {}*, sbyte*, bool, bool }
15 %lldb.local = type { uint, %lldb.global*, sbyte*, sbyte*, bool, bool }
16
17
18 ;; Debugger intrinsic declarations...
19 declare {}* %llvm.dbg.stoppoint({}*, uint, uint, %lldb.compile_unit*)
20 declare {}* %llvm.dbg.func.start(%lldb.global*)
21 declare {}* %llvm.dbg.region.start({}*)
22 declare {}* %llvm.dbg.region.end({}*)
23 declare {}* %llvm.dbg.declare({}*, ...)
24
25 ;; Global object anchors
26 %llvm.dbg.translation_units = linkonce global {} {}
27 %llvm.dbg.globals = linkonce global {} {}
28
29
30 %.str_1 = internal constant [11 x sbyte] c"funccall.c\00"
31 %.str_2 = internal constant [12 x sbyte] c"/home/sabre\00"
32 %.str_3 = internal constant [14 x sbyte] c"llvmgcc 3.4.x\00"
33
34 %d.compile_unit = internal constant %lldb.compile_unit {
35    uint 17,                                                        ;; DW_TAG_compile_unit
36    ushort 0,                                                       ;; LLVM Debug version #
37    ushort 1,                                                       ;; Language: DW_LANG_C89
38    sbyte* getelementptr ([11 x sbyte]* %.str_1, long 0, long 0),   ;; Source filename
39    sbyte* getelementptr ([12 x sbyte]* %.str_2, long 0, long 0),   ;; Working directory
40    sbyte* getelementptr ([14 x sbyte]* %.str_3, long 0, long 0),   ;; producer
41    {}* %llvm.dbg.translation_units                                 ;; Anchor
42 }
43
44
45 %.str_5 = internal global [5 x sbyte] c"main\00"
46 %.str_6 = internal global [4 x sbyte] c"foo\00"
47 %.str_7 = internal global [2 x sbyte] c"q\00"
48 %.str_8 = internal global [2 x sbyte] c"t\00"
49
50 %d.main = global %lldb.global {
51    uint 46,                                                        ;; DW_TAG_subprogram
52    %lldb.compile_unit* %d.compile_unit,                            ;; context pointer
53    sbyte* getelementptr ([5 x sbyte]* %.str_5, long 0, long 0),    ;; name
54    {}* %llvm.dbg.globals,                                          ;; anchor
55    sbyte* null,                                                    ;; EVENTUALLY the type
56    bool true,                                                      ;; non-static linkage?
57   bool false                                                       ;; definition, not declaration
58 }
59
60 %d.foo = global %lldb.global {
61    uint 46,                                                        ;; DW_TAG_subprogram
62    %lldb.compile_unit* %d.compile_unit,                            ;; context pointer
63    sbyte* getelementptr ([4 x sbyte]* %.str_6, long 0, long 0),    ;; name
64    {}* %llvm.dbg.globals,                                          ;; anchor
65    sbyte* null,                                                    ;; EVENTUALLY the type
66    bool true,                                                      ;; non-static linkage
67   bool false                                                       ;; definition, not declaration
68 }
69
70 %d.q = internal global %lldb.global {
71   uint 52,                                                         ;; DW_TAG_variable
72   %lldb.compile_unit* %d.compile_unit,                             ;; context pointer
73   sbyte* getelementptr ([2 x sbyte]* %.str_7, long 0, long 0),     ;; name
74   {}* %llvm.dbg.globals,                                           ;; anchor
75   sbyte* null,                                                     ;; EVENTUALLY the type
76   bool false,                                                      ;; static linkage
77   bool false                                                       ;; definition, not declaration
78 }
79
80
81 %d.t = internal global %lldb.local {
82   uint 52,                                                         ;; DW_TAG_variable
83   %lldb.global* %d.foo,                                            ;; context pointer
84   sbyte* getelementptr ([2 x sbyte]* %.str_8, long 0, long 0),     ;; name
85   sbyte* null,                                                     ;; EVENTUALLY the type
86   bool false,                                                      ;; local variable
87   bool false                                                       ;; definition, not declaratation
88 }
89
90
91
92 %q = internal global int 0
93
94 implementation   ; Functions:
95
96 void %foo() {
97 entry:
98         %t = alloca int
99         %.1 = call {}* %llvm.dbg.func.start(%lldb.global* %d.foo)
100         %.2 = call {}* %llvm.dbg.stoppoint({}* %.1, uint 5, uint 2, %lldb.compile_unit* %d.compile_unit)
101
102         %.3 = call {}*({}*, ...)* %llvm.dbg.declare({}* %.2, %lldb.local* %d.t, int* %t)
103         %tmp.0 = load int* %q
104         store int %tmp.0, int* %t
105         %.4 = call {}* %llvm.dbg.stoppoint({}* %.3, uint 6, uint 2, %lldb.compile_unit* %d.compile_unit)
106         %tmp.01 = load int* %t
107         %tmp.1 = add int %tmp.01, 1
108         store int %tmp.1, int* %q
109         %.5 = call {}* %llvm.dbg.stoppoint({}* %.4, uint 7, uint 1, %lldb.compile_unit* %d.compile_unit)
110         call {}* %llvm.dbg.region.end({}* %.5)
111         ret void
112 }
113
114 int %main() {
115 entry:
116         %.1 = call {}* %llvm.dbg.func.start(%lldb.global* %d.main)
117         %result = alloca int
118         %.2 = call {}* %llvm.dbg.stoppoint({}* %.1, uint 9, uint 2, %lldb.compile_unit* %d.compile_unit)
119         store int 0, int* %q
120         %.3 = call {}* %llvm.dbg.stoppoint({}* %.2, uint 10, uint 2, %lldb.compile_unit* %d.compile_unit)
121         call void %foo()
122         %.4 = call {}* %llvm.dbg.stoppoint({}* %.3, uint 11, uint 2, %lldb.compile_unit* %d.compile_unit)
123         %tmp.2 = load int* %q
124         %tmp.3 = sub int %tmp.2, 1
125         store int %tmp.3, int* %q
126         %.5 = call {}* %llvm.dbg.stoppoint({}* %.4, uint 13, uint 2, %lldb.compile_unit* %d.compile_unit)
127         %tmp.4 = load int* %q
128         store int %tmp.4, int* %result
129         %tmp.5 = load int* %result
130         %.6 = call {}* %llvm.dbg.stoppoint({}* %.5, uint 14, uint 1, %lldb.compile_unit* %d.compile_unit)
131         call {}* %llvm.dbg.region.end({}* %.6)
132         ret int %tmp.5
133 }