Skip to content

Commit

Permalink
Fixed wrong edges_count re-calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Jul 20, 2017
1 parent b8eb110 commit 1b9d0c8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
9 changes: 1 addition & 8 deletions ext/opcache/Optimizer/scdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ext/opcache/Optimizer/zend_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ext/opcache/Optimizer/zend_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1b9d0c8

Please sign in to comment.