b14bc2db2a4ed52341131716b3ed618d9fb67846
[oota-llvm.git] / test / Transforms / LevelRaise / 2002-03-20-BadCodegen.ll
1 ; This testcase tests whether the raise pass generates bad code for a 
2 ; getelementptr instruction... with a bad level raise pass, this code
3 ; will segfault on execution.
4 ;
5 ; RUN: as < %s | opt -raise  |lli -abort-on-exception  
6  
7  %Village = type { [4 x \3 *], \2 *, { \2 *, { int, int, int, \5 * } *, \2 * }, { int, int, int, { \2 *, { int, int, int, \6 * } *, \2 * }, { \2 *, { int, int,
8   int, \6 * } *, \2 * }, { \2 *, { int, int, int, \6 * } *, \2 * }, { \2 *, { int, int, int, \6 * } *, \2 * } }, int, int }
9
10
11
12 implementation
13
14 void "foo"(%Village *%V)
15 begin
16         ret void
17 end
18
19 int %main(int %argc, sbyte **%argv) {
20 ; <label>:0         ;[#uses=0]
21   %fval = alloca %Village *, uint 4   ; <%Village * *> [#uses=1]
22   %reg115 = malloc sbyte, uint 184    ; <sbyte *> [#uses=2]
23   br label %bb4
24
25 bb4:          ;[#uses=2]
26   %reg130 = shl int %argc, ubyte 2   ; <int> [#uses=1]
27   %reg131 = add int %reg130, 3    ; <int> [#uses=1]
28   %reg132 = add int %reg131, 1    ; <int> [#uses=1]
29   %cast323 = cast sbyte * %reg115 to %Village *   ; <%Village *> [#uses=1]
30   call void %foo(%Village * %cast323)    ; <%Village *> [#uses=0]
31   br label %bb6
32
33 bb6:          ;[#uses=3]
34   %reg176 = phi int [ %reg177, %bb6 ], [ 0, %bb4 ]    ; <int> [#uses=2]
35   %cast370 = cast int %reg176 to int    ; <int> [#uses=1]
36   %cast366 = cast int %reg176 to uint   ; <uint> [#uses=1]
37   %reg159 = shl uint %cast366, ubyte 3    ; <uint> [#uses=1]
38   %cast161 = cast uint %reg159 to ulong   ; <ulong> [#uses=1]
39   %cast367 = cast %Village * * %fval to ulong   ; <sbyte *> [#uses=1]
40   %reg169 = add ulong %cast367, %cast161
41   %cast368 = cast ulong %reg169 to sbyte * *    ; <sbyte * *> [#uses=1]
42   %reg170 = load sbyte * * %cast368   ; <sbyte *> [#uses=1]
43   %V = cast sbyte *%reg170 to %Village*
44   call void %foo(%Village *%V)
45   %reg177 = add int %cast370, 1   ; <int> [#uses=2]
46   %cond303 = setle int %reg177, 3   ; <bool> [#uses=1]
47   br bool %cond303, label %bb6, label %bb7
48
49 bb7:          ;[#uses=1]
50   ret int 0
51 }