Skip to content

Commit dc379e1

Browse files
committed
Abort register allocation if no candidates
1 parent 786e0ae commit dc379e1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ext/opcache/jit/zend_jit_trace.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,9 +2104,15 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
21042104
j++;
21052105
}
21062106
}
2107+
count = j;
21072108
free_alloca(start, use_heap);
21082109
start = end = NULL;
21092110

2111+
if (!count) {
2112+
zend_arena_release(&CG(arena), checkpoint);
2113+
return NULL;
2114+
}
2115+
21102116
/* Add hints */
21112117
if (parent_vars_count) {
21122118
zend_jit_trace_stack *parent_stack =
@@ -2225,14 +2231,21 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
22252231

22262232
memset(intervals, 0, ssa->vars_count * sizeof(zend_lifetime_interval*));
22272233
ival = list;
2234+
count = 0;
22282235
while (ival != NULL) {
22292236
ZEND_ASSERT(ival->reg != ZREG_NONE);
2237+
count++;
22302238
next = ival->list_next;
22312239
ival->list_next = intervals[ival->ssa_var];
22322240
intervals[ival->ssa_var] = ival;
22332241
ival = next;
22342242
}
22352243

2244+
if (!count) {
2245+
zend_arena_release(&CG(arena), checkpoint);
2246+
return NULL;
2247+
}
2248+
22362249
/* SSA resolution */
22372250
if (trace_buffer->stop == ZEND_JIT_TRACE_STOP_LOOP) {
22382251
zend_ssa_phi *phi = ssa->blocks[1].phis;
@@ -2306,12 +2319,18 @@ static zend_lifetime_interval** zend_jit_trace_allocate_registers(zend_jit_trace
23062319
}
23072320
if (may_remove) {
23082321
intervals[i] = NULL;
2322+
count--;
23092323
}
23102324
}
23112325
}
23122326

23132327
// Remove intervals used once ????
23142328

2329+
if (!count) {
2330+
zend_arena_release(&CG(arena), checkpoint);
2331+
return NULL;
2332+
}
2333+
23152334
if (ZCG(accel_directives).jit_debug & ZEND_JIT_DEBUG_REG_ALLOC) {
23162335
fprintf(stderr, "---- TRACE %d Allocated Live Ranges\n", ZEND_JIT_TRACE_NUM);
23172336
for (i = 0; i < ssa->vars_count; i++) {

0 commit comments

Comments
 (0)