]> granicus.if.org Git - php/commitdiff
Fixed wrong edges_count re-calculation.
authorDmitry Stogov <dmitry@zend.com>
Thu, 20 Jul 2017 20:28:05 +0000 (23:28 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 20 Jul 2017 20:28:05 +0000 (23:28 +0300)
ext/opcache/Optimizer/scdf.c
ext/opcache/Optimizer/zend_cfg.c
ext/opcache/Optimizer/zend_cfg.h

index add8741af62dd713563316c9907180822e69a60a..7482b0eff5d8f89fb7b98c850d73252bdf8783f2 100644 (file)
@@ -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;
index 4914c9e45e89ed3195be6a1e57ce74add532e01d..8276bec0518b6a20e7d98d81ca26a3a0f13ab5aa 100644 (file)
@@ -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;
index b5b5683f1270e778ae7ebd3169da36aa7a7da7d0..9a2a4e5a348ae50eb395d57a2a774ba9579b18ef 100644 (file)
@@ -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;