Fixed other issues with empty block handling
authorDmitry Stogov <dmitry@zend.com>
Wed, 9 Dec 2015 07:58:42 +0000 (10:58 +0300)
committerDmitry Stogov <dmitry@zend.com>
Wed, 9 Dec 2015 07:58:42 +0000 (10:58 +0300)
ext/opcache/Optimizer/block_pass.c

index 0f083ba86e3018d0ce2149929ce438e7ee94669a..2e797d4e7e1c41428ac9bb78ad4494fa57cd7f1b 100644 (file)
@@ -776,7 +776,11 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array)
                                if (next < end && next == blocks + b->successors[0]) {
                                        /* JMP to the next block - strip it */
                                        MAKE_NOP(opline);
-                                       b->end--;
+                                       if (b->end == 0) {
+                                               b->start++;
+                                       } else {
+                                               b->end--;
+                                       }
                                }
                        } else if (b->start == b->end && opline->opcode == ZEND_NOP) {
                                /* skip empty block */
@@ -822,7 +826,7 @@ static void assemble_code_blocks(zend_cfg *cfg, zend_op_array *op_array)
        op_array->last = len;
 
        for (b = blocks; b < end; b++) {
-               if (!(b->flags & ZEND_BB_REACHABLE)) {
+               if (!(b->flags & ZEND_BB_REACHABLE) || b->start > b->end) {
                        continue;
                }
                opline = op_array->opcodes + b->end;