Don't start new block after loop free

This reverts the change from 493c91c742.
Starting a new block means that in the common case where the loop var
free is not unreachable, we'll always merge back the block.

Instead fix the original problem by explicitly removing instructions
apart from the loop var free in block pass.
This commit is contained in:
Nikita Popov 2021-10-06 09:56:32 +02:00
parent 831a1717f6
commit f455894bb6
2 changed files with 9 additions and 3 deletions

View File

@ -1892,6 +1892,15 @@ void zend_optimize_cfg(zend_op_array *op_array, zend_optimizer_ctx *ctx)
/* Eliminate NOPs */
for (b = blocks; b < end; b++) {
if (b->flags & ZEND_BB_UNREACHABLE_FREE) {
/* In unreachable_free blocks only preserve loop var frees. */
for (uint32_t i = b->start; i < b->start + b->len; i++) {
zend_op *opline = &op_array->opcodes[i];
if (!zend_optimizer_is_loop_var_free(opline)) {
MAKE_NOP(opline);
}
}
}
if (b->flags & (ZEND_BB_REACHABLE|ZEND_BB_UNREACHABLE_FREE)) {
strip_nops(op_array, b);
}

View File

@ -437,9 +437,6 @@ ZEND_API int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, u
case ZEND_FE_FREE:
if (zend_optimizer_is_loop_var_free(opline)) {
BB_START(i);
if (i + 1 < op_array->last) {
BB_START(i + 1);
}
flags |= ZEND_FUNC_FREE_LOOP_VAR;
}
break;