5 public static int Main (String[] args) {
6 return TestDriver.RunTests (typeof (Tests));
9 static void call_clobber_inner () {
12 public static int test_15_clobber_1 () {
15 for (int i = 0; i < 10; ++i)
17 for (int i = 0; i < 5; ++i)
20 // clob == '1' and dreg == sreg2
25 public static int test_15_clobber_1_fp () {
28 for (int i = 0; i < 10; ++i)
30 for (int i = 0; i < 5; ++i)
33 // clob == '1' and dreg == sreg2
38 public static int test_5_call_clobber () {
39 // A call clobbers some registers so variables in those registers need to be spilled
40 // and later reloaded to a register
44 call_clobber_inner ();
49 static int call_clobber_inner2 () {
53 public static int test_7_call_clobber_dreg () {
54 // A call doesn't clobber its dreg
58 a = call_clobber_inner2 ();
63 public static int test_9_spill_if_then_else () {
64 // Spilling variables in one branch of an if-then-else
70 call_clobber_inner ();
76 public static int test_3_spill_reload_if_then_else () {
77 // Spilling and reloading variables in one branch of an if-then-else
84 call_clobber_inner ();
91 public static int test_5_spill_loop () {
94 for (i = 0; i < 5; ++i)
95 call_clobber_inner ();
100 public unsafe static int test_0_volatile () {
120 public unsafe static int test_0_volatile_unused () {
130 public unsafe static int test_0_volatile_unused_2 () {
141 static int ref_int (int i, ref int b, int j) {
147 public static int test_0_volatile_unused_3 () {
148 // b's def has no use so its interval is split at a position not covered by the interval
150 if (ref_int (99, ref b, 100) != 42)
153 if (ref_int (99, ref b, 100) != 43)
160 static int ref_bool (int i, ref bool b1, ref bool b2, ref bool b3) {
168 public static int test_0_volatile_regress_1 () {
169 // Spill stores should precede spill loads at a given position
170 for (int i = 0; i < 8; i++) {
171 bool b1 = (i & 4) != 0;
172 bool b2 = (i & 2) != 0;
173 bool b3 = (i & 1) != 0;
174 bool orig_b1 = b1, orig_b2 = b2, orig_b3 = b3;
175 if (ref_bool(i, ref b1, ref b2, ref b3) != 0)
188 public static int test_0_clobber_regress_1 () {
189 object[] a11 = new object [10];
190 object o = new Object ();
191 // A spill load is inserted before the backward branch, clobbering one of the
192 // registers used in the comparison
193 for (int i = 0; i < 10; ++i)
199 static int return_arg (int i) {
203 public static int test_0_spill_regress_1 () {
205 for (int i = 0; i < 3; i++) {
206 // i is spilled by the call, then reloaded for the loop check
207 // make sure the move from its first reg to its second is inserted in the
208 // if body bblock, not the for body bblock
211 if (return_arg (j) != 5)
219 public static int test_0_spill_regress_2 () {
220 double[] temporaries = new double[3];
221 for (int i = 0; i < 3; i++) {
222 // i and temporaries are spilled by the call, then reloaded after the call
223 // make sure the two moves inserted in the if bblock are in the proper order
226 temporaries [i] = return_arg (i);
233 static int many_args_unused (int i, int j, int k, int l, int m, int n, int p, int q) {
237 public static int test_0_unused_args () {
238 return many_args_unused (0, 1, 2, 3, 4, 5, 6, 7);
241 public unsafe void ClearBuffer (byte *buffer, int i) {
243 byte *b = stackalloc byte [4];
246 public unsafe bool instance_method_1 (string s, string target, int start, int length, int opt) {
247 byte* alwaysMatchFlags = stackalloc byte [16];
248 byte* neverMatchFlags = stackalloc byte [16];
249 byte* targetSortKey = stackalloc byte [4];
250 byte* sk1 = stackalloc byte [4];
251 byte* sk2 = stackalloc byte [4];
252 ClearBuffer (alwaysMatchFlags, 16);
253 ClearBuffer (neverMatchFlags, 16);
254 ClearBuffer (targetSortKey, 4);
255 ClearBuffer (sk1, 4);
256 ClearBuffer (sk2, 4);
258 return this == null && s == target && start == length && length == opt && alwaysMatchFlags == neverMatchFlags && neverMatchFlags == targetSortKey && sk1 == sk2;
261 public static int test_0_spill_regress_3 () {
262 new Tests ().instance_method_1 (null, null, 0, 0, 0);
266 unsafe bool MatchesBackward (string s, ref int idx, int end, int orgStart, int ti, byte* sortkey, bool noLv4, ref object ctx) {
268 byte *b = stackalloc byte [4];
271 throw new Exception ();
277 unsafe int LastIndexOfSortKey (string s, int start, int orgStart, int length, byte* sortkey, int ti, bool noLv4, ref object ctx)
279 // ctx is initially allocated to the stack, when it is reloaded before the call,
280 // %rax is spilled to free up the register, then ctx is allocated to %rax for its
281 // whole lifetime, but %rax is not available for this since it is clobbered by the
283 int end = start - length;
287 if (MatchesBackward (s, ref idx, end, orgStart,
288 ti, sortkey, noLv4, ref ctx))
294 public unsafe static int test_0_spill_regress_4 () {
295 object o = new Object ();
296 new Tests ().LastIndexOfSortKey ("", 10, 0, 5, null, 0, false, ref o);