com php-src: Fixed wrong edges_count re-calculation.: ext/opcache/Optimizer/scdf.c ext/opcache/Optimizer/zend _cfg.c ext/opcache/Optimizer/zend_cfg.h
| From: | Dmitry Stogov | Date: | Thu, 20 Jul 2017 20:28:05 +0000 |
| Subject: | com php-src: Fixed wrong edges_count re-calculation.: ext/opcache/Optimizer/scdf.c ext/opcache/Optimizer/zend _cfg.c ext/opcache/Optimizer/zend_cfg.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98674@lists.php.net to get a copy of this message | ||
Commit: 1b9d0c8af374442ed9341ef473db59f9f259110f
Author: Dmitry Stogov <dmitry@zend.com> Thu, 20 Jul 2017 23:28:05 +0300
Parents: b8eb110cd5b1e862429d893c1acd6dc9959c8e01
Branches: PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1b9d0c8af374442ed9341ef473db59f9f259110f
Log:
Fixed wrong edges_count re-calculation.
Changed paths:
M ext/opcache/Optimizer/scdf.c
M ext/opcache/Optimizer/zend_cfg.c
M ext/opcache/Optimizer/zend_cfg.h
Diff:
diff --git a/ext/opcache/Optimizer/scdf.c b/ext/opcache/Optimizer/scdf.c
index add8741..7482b0e 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 4914c9e..8276bec 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 b5b5683..9a2a4e5 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;