Use the llvm-upgrade program to upgrade llvm assembly.
[oota-llvm.git] / test / Feature / testmemory.ll
1 ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
2 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
3 ; RUN: diff %t1.ll %t2.ll
4
5 %struct = type { int , {float, {ubyte } } , ulong }
6 %complexty = type {int, {[4 x sbyte *], float}, double}
7
8 implementation
9
10 int "main"()
11 begin
12   call int %testfunction(long 0, long 1)
13   ret int 0
14 end
15
16 int "testfunction"(long %i0, long %j0)
17 begin
18     %array0 = malloc [4 x ubyte]            ; yields {[4 x ubyte]*}:array0
19     %size   = add uint 2, 2                 ; yields {uint}:size = uint %4
20     %array1 = malloc ubyte, uint 4          ; yields {ubyte*}:array1
21     %array2 = malloc ubyte, uint %size      ; yields {ubyte*}:array2
22
23     %idx = getelementptr [4 x ubyte]* %array0, long 0, long 2
24     store ubyte 123, ubyte* %idx
25     free [4x ubyte]* %array0
26     free ubyte* %array1
27     free ubyte* %array2
28
29
30     %aa = alloca %complexty, uint 5
31     %idx2 = getelementptr %complexty* %aa, long %i0, uint 1, uint 0, long %j0
32     store sbyte *null, sbyte** %idx2
33     
34     %ptr = alloca int                       ; yields {int*}:ptr
35     store int 3, int* %ptr                  ; yields {void}
36     %val = load int* %ptr                   ; yields {int}:val = int %3
37
38     %sptr = alloca %struct                  ; yields {%struct*}:sptr
39     %ubsptr = getelementptr %struct * %sptr, long 0, uint 1, uint 1  ; yields {{ubyte}*}:ubsptr
40     %idx3 = getelementptr {ubyte} * %ubsptr, long 0, uint 0
41     store ubyte 4, ubyte* %idx3
42
43     ret int 3
44 end
45