git subrepo clone https://git.savannah.gnu.org/git/lightning.git deps/lightning
[pcsx_rearmed.git] / deps / lightning / check / jmpr.tst
1 /*
2 This is a very simple check to a condition that on lightning 2.0.5
3 could cause an assertion on some backends, due to correcting a problem
4 with temporaries that could not be saved/reloaded due to being used only
5 in the hardware instruction, or being considered live for too long on the
6 lightning instruction, and that could not be reloaded after the jump target
7 (or after false/true target on conditional branches).
8
9 If this code in lib/lightning.c:_jit_update():
10
11                     for (regno = 0; regno < _jitc->reglen; regno++) {
12                         spec = jit_class(_rvs[regno].spec);
13                         if (jit_regset_tstbit(mask, regno) &&
14                             (spec & (jit_class_gpr|jit_class_fpr)) &&
15                             !(spec & jit_class_sav))
16                             jit_regset_clrbit(mask, regno);
17                     }
18
19 were removed, this test case, on x86_64 would fail like this:
20
21 lt-lightning: lightning.c:305: _jit_get_reg: Assertion `regspec & 0x02000000' failed.
22 Aborted (core dumped)
23  */
24
25 .data   32
26 ret:
27 #if __WORDSIZE == 32
28 .i      0
29 #else
30 .l      0
31 #endif
32 ok:
33 .c      "ok"
34
35 .code
36         prolog
37         jmpi start
38
39 add_v1_v2:
40         addr %v1 %v1 %v2
41         ldi %r0 ret
42         jmpr %r0
43
44 start:
45         movi %v1 1
46         movi %v2 2
47         movi %r0 ret_add_v1_v2
48         sti ret %r0
49         movi %v0 add_v1_v2
50         jmpr %v0
51         movi_d %f0 3
52         beqi_d pass_movi_f0 %f0 3
53         calli @abort
54 pass_movi_f0:
55         beqi pass_check_v2 %v2 2
56         calli @abort
57 pass_check_v2:
58 ret_add_v1_v2:
59         beqi pass_add_v1_v2 %v1 3
60         calli @abort
61 pass_add_v1_v2:
62         prepare
63                 pushargi ok
64         finishi @puts
65         ret
66         epilog