]> granicus.if.org Git - php/commitdiff
Fixed removing dead live ranges
authorDmitry Stogov <dmitry@zend.com>
Mon, 14 Aug 2017 10:54:52 +0000 (13:54 +0300)
committerDmitry Stogov <dmitry@zend.com>
Mon, 14 Aug 2017 10:54:52 +0000 (13:54 +0300)
ext/opcache/Optimizer/sccp.c
ext/opcache/Optimizer/zend_optimizer.c
ext/opcache/Optimizer/zend_ssa.c

index cd74ea41e3fc654133aeba1aed07052a1dceb283..24af78ee5db7c4749f522dd12e0146bc30c51c2b 100644 (file)
@@ -1459,7 +1459,7 @@ static int replace_constant_operands(sccp_ctx *ctx) {
                                        ZEND_ASSERT(call);
                                        ZEND_ASSERT(call->caller_call_opline == opline);
                                        if (opline->result_type & (IS_TMP_VAR|IS_VAR)) {
-                                               zend_optimizer_remove_live_range_ex(op_array, opline->result.var, var->definition + 1);
+                                               zend_optimizer_remove_live_range_ex(op_array, opline->result.var, var->definition);
                                        }
                                        zend_ssa_remove_result_def(ssa, ssa_op);
                                        zend_ssa_remove_instr(ssa, opline, ssa_op);
@@ -1477,7 +1477,7 @@ static int replace_constant_operands(sccp_ctx *ctx) {
                                } else {
                                        /* Ordinary computational instruction -> remove it */
                                        if (opline->result_type & (IS_TMP_VAR|IS_VAR)) {
-                                               zend_optimizer_remove_live_range_ex(op_array, opline->result.var, var->definition + 1);
+                                               zend_optimizer_remove_live_range_ex(op_array, opline->result.var, var->definition);
                                        }
                                        zend_ssa_remove_result_def(ssa, ssa_op);
                                        zend_ssa_remove_instr(ssa, opline, ssa_op);
@@ -1502,7 +1502,7 @@ static int replace_constant_operands(sccp_ctx *ctx) {
                                                && ssa->vars[ssa_op->result_def].use_chain < 0
                                                && ssa->vars[ssa_op->result_def].phi_use_chain == NULL) {
                                        if (opline->result_type & (IS_TMP_VAR|IS_VAR)) {
-                                               zend_optimizer_remove_live_range_ex(op_array, opline->result.var, var->definition + 1);
+                                               zend_optimizer_remove_live_range_ex(op_array, opline->result.var, var->definition);
                                        }
                                        zend_ssa_remove_result_def(ssa, ssa_op);
                                        opline->result_type = IS_UNUSED;
index 4b56809fda0086d17b23181b003cc90941e5a5c5..89917224d9138efe19058bed38faa624e92d29a2 100644 (file)
@@ -557,6 +557,24 @@ void zend_optimizer_remove_live_range_ex(zend_op_array *op_array, uint32_t var,
 {
        uint32_t i = 0;
 
+       switch (op_array->opcodes[start].opcode) {
+               case ZEND_ROPE_ADD:
+               case ZEND_ADD_ARRAY_ELEMENT:
+                       return;
+               case ZEND_ROPE_INIT:
+                       var |= ZEND_LIVE_ROPE;
+                       break;
+               case ZEND_BEGIN_SILENCE:
+                       var |= ZEND_LIVE_SILENCE;
+                       break;
+               case ZEND_FE_RESET_R:
+               case ZEND_FE_RESET_RW:
+                       var |= ZEND_LIVE_LOOP;
+                       /* break missing intentionally */
+               default:
+                       start++;
+       }
+
        while (i < op_array->last_live_range) {
                if (op_array->live_range[i].var == var
                                && op_array->live_range[i].start == start) {
index a82d7ff2251730e39d6c1a1aa435b331f3250eb8..e100be426c32f03ff3f6c8e641dfca928949f219 100644 (file)
@@ -1362,7 +1362,7 @@ void zend_ssa_remove_block(zend_op_array *op_array, zend_ssa *ssa, int i) /* {{{
                }
 
                if (op_array->opcodes[j].result_type & (IS_TMP_VAR|IS_VAR)) {
-                       zend_optimizer_remove_live_range_ex(op_array, op_array->opcodes[j].result.var, j + 1);
+                       zend_optimizer_remove_live_range_ex(op_array, op_array->opcodes[j].result.var, j);
                }
                zend_ssa_remove_defs_of_instr(ssa, &ssa->ops[j]);
                zend_ssa_remove_instr(ssa, &op_array->opcodes[j], &ssa->ops[j]);