1
0
mirror of https://github.com/php/php-src.git synced 2026-04-20 22:41:20 +02:00

Fixed removing dead live ranges

This commit is contained in:
Dmitry Stogov
2017-08-14 13:54:52 +03:00
parent 112afb9250
commit df5104bfc9
3 changed files with 22 additions and 4 deletions

View 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;

View 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) {

View 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]);