Skip to content

Commit f455894

Browse files
committed
Don't start new block after loop free
This reverts the change from 493c91c. 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.
1 parent 831a171 commit f455894

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Zend/Optimizer/block_pass.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,15 @@ void zend_optimize_cfg(zend_op_array *op_array, zend_optimizer_ctx *ctx)
18921892

18931893
/* Eliminate NOPs */
18941894
for (b = blocks; b < end; b++) {
1895+
if (b->flags & ZEND_BB_UNREACHABLE_FREE) {
1896+
/* In unreachable_free blocks only preserve loop var frees. */
1897+
for (uint32_t i = b->start; i < b->start + b->len; i++) {
1898+
zend_op *opline = &op_array->opcodes[i];
1899+
if (!zend_optimizer_is_loop_var_free(opline)) {
1900+
MAKE_NOP(opline);
1901+
}
1902+
}
1903+
}
18951904
if (b->flags & (ZEND_BB_REACHABLE|ZEND_BB_UNREACHABLE_FREE)) {
18961905
strip_nops(op_array, b);
18971906
}

Zend/Optimizer/zend_cfg.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,6 @@ ZEND_API int zend_build_cfg(zend_arena **arena, const zend_op_array *op_array, u
437437
case ZEND_FE_FREE:
438438
if (zend_optimizer_is_loop_var_free(opline)) {
439439
BB_START(i);
440-
if (i + 1 < op_array->last) {
441-
BB_START(i + 1);
442-
}
443440
flags |= ZEND_FUNC_FREE_LOOP_VAR;
444441
}
445442
break;

0 commit comments

Comments
 (0)