Skip to content

Commit acdf6d2

Browse files
committed
[block_pass] Relink successors after block becomes empty
Improvement of phpGH-20850 for master only.
1 parent 1ee38a3 commit acdf6d2

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Zend/Optimizer/block_pass.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array *op_array
546546
}
547547
}
548548
break;
549-
549+
550550
case ZEND_BOOL:
551551
case ZEND_BOOL_NOT:
552552
optimize_bool:
@@ -1800,6 +1800,7 @@ void zend_optimize_cfg(zend_op_array *op_array, zend_optimizer_ctx *ctx)
18001800
}
18011801

18021802
/* Eliminate NOPs */
1803+
bool recompute_successors = false;
18031804
for (b = blocks; b < end; b++) {
18041805
if (b->flags & ZEND_BB_UNREACHABLE_FREE) {
18051806
/* In unreachable_free blocks only preserve loop var frees. */
@@ -1813,6 +1814,19 @@ void zend_optimize_cfg(zend_op_array *op_array, zend_optimizer_ctx *ctx)
18131814
if (b->flags & (ZEND_BB_REACHABLE|ZEND_BB_UNREACHABLE_FREE)) {
18141815
strip_nops(op_array, b);
18151816
}
1817+
if (b->len == 0 && (b->flags & ZEND_BB_TARGET)) {
1818+
recompute_successors = true;
1819+
}
1820+
}
1821+
if (recompute_successors) {
1822+
for (b = blocks; b < end; b++) {
1823+
for (int s = 0; s < b->successors_count; s++) {
1824+
get_target_block(&cfg, b, s, &opt_count);
1825+
}
1826+
if (b->len == 0 && (b->flags & ZEND_BB_TARGET)) {
1827+
b->flags &= ~ZEND_BB_TARGET;
1828+
}
1829+
}
18161830
}
18171831

18181832
opt_count = 0;

0 commit comments

Comments
 (0)