com php-src: Fix SSA NOP removal: ext/opcache/Optimizer/dfa_p ass.c ext/opcache/tests/ssa_bug_002.phpt
| From: | Nikita Popov | Date: | Sun, 05 Jun 2016 21:00:32 +0000 |
| Subject: | com php-src: Fix SSA NOP removal: ext/opcache/Optimizer/dfa_p ass.c ext/opcache/tests/ssa_bug_002.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-92315@lists.php.net to get a copy of this message | ||
Commit: 7b4618e396917e3bd89e6a4d05402d3715dc701c
Author: Nikita Popov <nikic@php.net> Sun, 5 Jun 2016 23:00:32 +0200
Parents: 3be92120ba676afdcbd40bafa9d474b7f10e286c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7b4618e396917e3bd89e6a4d05402d3715dc701c
Log:
Fix SSA NOP removal
NOPs need to be tracked in the shiftlist as well, as there may be
jumps to NOPs.
Changed paths:
M ext/opcache/Optimizer/dfa_pass.c
A ext/opcache/tests/ssa_bug_002.phpt
Diff:
diff --git a/ext/opcache/Optimizer/dfa_pass.c b/ext/opcache/Optimizer/dfa_pass.c
index 3be638e..2ebbfbd 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 0000000..9ff6f79
--- /dev/null
+++ b/ext/opcache/tests/ssa_bug_002.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Incorrect NOP removal on jump to NOP
+--FILE--
+<?php
+
+function test(int $i) : int {
+ if ($i == 1) {
+ $x = $i + 1;
+ }
+ return $i;
+}
+var_dump(test(42));
+
+?>
+--EXPECT--
+int(42)