From: Nikita Popov Date: Sun, 5 Jun 2016 21:00:32 +0000 (+0200) Subject: Fix SSA NOP removal X-Git-Tag: php-7.1.0alpha1~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b4618e396917e3bd89e6a4d05402d3715dc701c;p=php Fix SSA NOP removal NOPs need to be tracked in the shiftlist as well, as there may be jumps to NOPs. --- diff --git a/ext/opcache/Optimizer/dfa_pass.c b/ext/opcache/Optimizer/dfa_pass.c index 3be638eb92..2ebbfbd141 100644 --- a/ext/opcache/Optimizer/dfa_pass.c +++ b/ext/opcache/Optimizer/dfa_pass.c @@ -142,6 +142,7 @@ static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa) i = b->start; b->start = target; while (i < end) { + shiftlist[i] = i - target; if (EXPECTED(op_array->opcodes[i].opcode != ZEND_NOP) || /*keep NOP to support ZEND_VM_SMART_BRANCH */ (i > 0 && @@ -165,7 +166,6 @@ static void zend_ssa_remove_nops(zend_op_array *op_array, zend_ssa *ssa) if (i != target) { op_array->opcodes[target] = op_array->opcodes[i]; ssa->ops[target] = ssa->ops[i]; - shiftlist[i] = i - target; } target++; } diff --git a/ext/opcache/tests/ssa_bug_002.phpt b/ext/opcache/tests/ssa_bug_002.phpt new file mode 100644 index 0000000000..9ff6f799f4 --- /dev/null +++ b/ext/opcache/tests/ssa_bug_002.phpt @@ -0,0 +1,16 @@ +--TEST-- +Incorrect NOP removal on jump to NOP +--FILE-- + +--EXPECT-- +int(42)