blob: 1bb63dd77816751201925baaad2f993f2a3e67c9 [file] [log] [blame]
Chris Lattner35e0a2c2002-02-11 23:44:06 +00001; The "bug" is in the level raising code, not correctly
2; raising an array reference. As generated, the code will work, but does
3; not correctly match the array type. In short, the code generated
4; corresponds to this:
5;
6; int Array[100][200];
7; ...
8; Sum += Array[0][i*200+j];
9;
10; which is out of range, because, although it is correctly accessing the
11; array, it does not match types correctly. LLI would pass it through fine,
12; if only the code looked like this:
13;
14; Sum += Array[i][j];
15;
16; which is functionally identical, but matches the array bound correctly.
17; The fix is to have the -raise pass correctly convert it to the second
18; equivelent form.
19;
Tanya Lattner1d28bda2004-11-06 20:38:27 +000020; XFAIL: *
Misha Brukmanedf4bab2003-09-16 15:29:54 +000021; RUN: llvm-as < %s | opt -q -raise > Output/%s.raised.bc
Chris Lattner60c45832003-09-16 15:34:36 +000022; RUN: lli -force-interpreter -array-checks < Output/%s.raised.bc
Chris Lattner35e0a2c2002-02-11 23:44:06 +000023;
24
25implementation
26
27int "main"()
28begin
29bb0: ;[#uses=0]
30 %Array = alloca [100 x [200 x int]] ; <[100 x [200 x int]] *> [#uses=1]
31 %cast1032 = cast [100 x [200 x int]] * %Array to [200 x int] * ; <[200 x int] *> [#uses=1]
32 br label %bb1
33
34bb1: ;[#uses=4]
35 %cond1033 = setgt long 0, 99 ; <bool> [#uses=1]
36 br bool %cond1033, label %bb5, label %bb2
37
38bb2: ;[#uses=5]
39 %reg124 = phi double [ %reg130, %bb4 ], [ 0.000000e+00, %bb1 ] ; <double> [#uses=2]
40 %reg125 = phi int [ %reg131, %bb4 ], [ 0, %bb1 ] ; <int> [#uses=2]
41 %cast1043 = cast int %reg125 to int ; <int> [#uses=1]
42 %cast1038 = cast int %reg125 to uint ; <uint> [#uses=1]
43 %cond1034 = setgt long 0, 199 ; <bool> [#uses=1]
44 br bool %cond1034, label %bb4, label %bb3
45
46bb3: ;[#uses=5]
47 %reg126 = phi double [ %reg128, %bb3 ], [ %reg124, %bb2 ] ; <double> [#uses=1]
48 %reg127 = phi int [ %reg129, %bb3 ], [ 0, %bb2 ] ; <int> [#uses=2]
49 %cast1042 = cast int %reg127 to int ; <int> [#uses=1]
50 %cast1039 = cast int %reg127 to uint ; <uint> [#uses=1]
51 %reg110 = mul uint %cast1038, 200 ; <uint> [#uses=1]
52 %reg111 = add uint %reg110, %cast1039 ; <uint> [#uses=1]
53 %reg113 = shl uint %reg111, ubyte 2 ; <uint> [#uses=1]
54 %cast115 = cast uint %reg113 to ulong ; <ulong> [#uses=1]
Chris Lattner36b86452003-05-14 18:37:03 +000055 %cast1040 = cast [200 x int] * %cast1032 to ulong ; <sbyte *> [#uses=1]
56 %reg118 = add ulong %cast1040, %cast115 ; <sbyte *> [#uses=1]
57 %cast1041 = cast ulong %reg118 to int * ; <int *> [#uses=1]
Chris Lattner35e0a2c2002-02-11 23:44:06 +000058 %reg120 = load int * %cast1041 ; <int> [#uses=1]
59 %cast119 = cast int %reg120 to double ; <double> [#uses=1]
60 %reg128 = add double %reg126, %cast119 ; <double> [#uses=2]
61 %reg129 = add int %cast1042, 1 ; <int> [#uses=2]
62 %cond1035 = setle int %reg129, 199 ; <bool> [#uses=1]
63 br bool %cond1035, label %bb3, label %bb4
64
65bb4: ;[#uses=5]
66 %reg130 = phi double [ %reg128, %bb3 ], [ %reg124, %bb2 ] ; <double> [#uses=2]
67 %reg131 = add int %cast1043, 1 ; <int> [#uses=2]
68 %cond1036 = setle int %reg131, 99 ; <bool> [#uses=1]
69 br bool %cond1036, label %bb2, label %bb5
70
71bb5: ;[#uses=2]
72 %reg132 = phi double [ %reg130, %bb4 ], [ 0.000000e+00, %bb1 ] ; <double> [#uses=1]
73 %RET = cast double %reg132 to int
74 ret int %RET
75end
76