From 1b9d0c8af374442ed9341ef473db59f9f259110f Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 20 Jul 2017 23:28:05 +0300 Subject: [PATCH] Fixed wrong edges_count re-calculation. --- ext/opcache/Optimizer/scdf.c | 9 +-------- ext/opcache/Optimizer/zend_cfg.c | 1 + ext/opcache/Optimizer/zend_cfg.h | 1 + 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ext/opcache/Optimizer/scdf.c b/ext/opcache/Optimizer/scdf.c index add8741af6..7482b0eff5 100644 --- a/ext/opcache/Optimizer/scdf.c +++ b/ext/opcache/Optimizer/scdf.c @@ -81,13 +81,6 @@ void scdf_mark_edge_feasible(scdf_ctx *scdf, int from, int to) { } void scdf_init(zend_optimizer_ctx *ctx, scdf_ctx *scdf, zend_op_array *op_array, zend_ssa *ssa) { - uint32_t edges_count = 0; - int b; - - for (b = 0; b < ssa->cfg.blocks_count; b++) { - edges_count += ssa->cfg.blocks[b].predecessors_count; - } - scdf->op_array = op_array; scdf->ssa = ssa; @@ -96,7 +89,7 @@ void scdf_init(zend_optimizer_ctx *ctx, scdf_ctx *scdf, zend_op_array *op_array, scdf->block_worklist_len = zend_bitset_len(ssa->cfg.blocks_count); scdf->instr_worklist = zend_arena_calloc(&ctx->arena, - scdf->instr_worklist_len + scdf->phi_var_worklist_len + 2 * scdf->block_worklist_len + zend_bitset_len(edges_count), + scdf->instr_worklist_len + scdf->phi_var_worklist_len + 2 * scdf->block_worklist_len + zend_bitset_len(ssa->cfg.edges_count), sizeof(zend_ulong)); scdf->phi_var_worklist = scdf->instr_worklist + scdf->instr_worklist_len; diff --git a/ext/opcache/Optimizer/zend_cfg.c b/ext/opcache/Optimizer/zend_cfg.c index 4914c9e45e..8276bec051 100644 --- a/ext/opcache/Optimizer/zend_cfg.c +++ b/ext/opcache/Optimizer/zend_cfg.c @@ -635,6 +635,7 @@ int zend_cfg_build_predecessors(zend_arena **arena, zend_cfg *cfg) /* {{{ */ } } + cfg->edges_count = edges; cfg->predecessors = predecessors = (int*)zend_arena_calloc(arena, sizeof(int), edges); edges = 0; diff --git a/ext/opcache/Optimizer/zend_cfg.h b/ext/opcache/Optimizer/zend_cfg.h index b5b5683f12..9a2a4e5a34 100644 --- a/ext/opcache/Optimizer/zend_cfg.h +++ b/ext/opcache/Optimizer/zend_cfg.h @@ -86,6 +86,7 @@ typedef struct _zend_basic_block { typedef struct _zend_cfg { int blocks_count; /* number of basic blocks */ + int edges_count; /* number of basic blocks */ zend_basic_block *blocks; /* array of basic blocks */ int *predecessors; uint32_t *map; -- 2.40.0