aboutsummaryrefslogtreecommitdiff
path: root/deps/lightning/check/jmpr.tst
blob: 669f54e2a863b1aff4ad353d6b34cab116ad14d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
This is a very simple check to a condition that on lightning 2.0.5
could cause an assertion on some backends, due to correcting a problem
with temporaries that could not be saved/reloaded due to being used only
in the hardware instruction, or being considered live for too long on the
lightning instruction, and that could not be reloaded after the jump target
(or after false/true target on conditional branches).

If this code in lib/lightning.c:_jit_update():

		    for (regno = 0; regno < _jitc->reglen; regno++) {
			spec = jit_class(_rvs[regno].spec);
			if (jit_regset_tstbit(mask, regno) &&
			    (spec & (jit_class_gpr|jit_class_fpr)) &&
			    !(spec & jit_class_sav))
			    jit_regset_clrbit(mask, regno);
		    }

were removed, this test case, on x86_64 would fail like this:

lt-lightning: lightning.c:305: _jit_get_reg: Assertion `regspec & 0x02000000' failed.
Aborted (core dumped)
 */

.data	32
ret:
#if __WORDSIZE == 32
.i	0
#else
.l	0
#endif
ok:
.c	"ok"

.code
	prolog
	jmpi start

add_v1_v2:
	addr %v1 %v1 %v2
	ldi %r0 ret
	jmpr %r0

start:
	movi %v1 1
	movi %v2 2
	movi %r0 ret_add_v1_v2
	sti ret %r0
	movi %v0 add_v1_v2
	jmpr %v0
	movi_d %f0 3
	beqi_d pass_movi_f0 %f0 3
	calli @abort
pass_movi_f0:
	beqi pass_check_v2 %v2 2
	calli @abort
pass_check_v2:
ret_add_v1_v2:
	beqi pass_add_v1_v2 %v1 3
	calli @abort
pass_add_v1_v2:
	prepare
		pushargi ok
	finishi @puts
	ret
	epilog