]> granicus.if.org Git - php/commitdiff
Allow SSA construction with source information about CV used as result
authorDmitry Stogov <dmitry@zend.com>
Thu, 30 Mar 2017 17:14:01 +0000 (20:14 +0300)
committerDmitry Stogov <dmitry@zend.com>
Thu, 30 Mar 2017 17:14:01 +0000 (20:14 +0300)
ext/opcache/Optimizer/zend_cfg.h
ext/opcache/Optimizer/zend_inference.c
ext/opcache/Optimizer/zend_ssa.c

index 7b80d83f110a3d945f99d429b1add2dd37e60097..d24bbd910d7367f3e0717fcfeb819041754201b9 100644 (file)
@@ -102,6 +102,7 @@ typedef struct _zend_cfg {
 #define ZEND_CFG_NO_ENTRY_PREDECESSORS (1<<25)
 #define ZEND_CFG_RECV_ENTRY            (1<<24)
 #define ZEND_CALL_TREE                 (1<<23)
+#define ZEND_SSA_USE_CV_RESULTS        (1<<22)
 
 #define CRT_CONSTANT_EX(op_array, node, rt_constants) \
        ((rt_constants) ? \
index 285d443d18a94232413ad8d01a394b2f1efeb338..9472f00f93e50f86f3eb5d797d872dedfc3e5fbf 100644 (file)
@@ -250,6 +250,9 @@ static inline zend_bool is_no_val_use(const zend_op *opline, const zend_ssa_op *
        if (opline->opcode == ZEND_FE_FETCH_R) {
                return ssa_op->op2_use == var && ssa_op->op1_use != var;
        }
+       if (ssa_op->result_use == var && opline->opcode != ZEND_ADD_ARRAY_ELEMENT) {
+               return 1;
+       }
        return 0;
 }
 
index b393cd2d1303e20329ebe1ee614454d518fe8e75..2f5f3597675f388867a496aa710f13db481f2c8e 100644 (file)
@@ -762,6 +762,10 @@ static int zend_ssa_rename(const zend_op_array *op_array, uint32_t build_flags,
                                        break;
                        }
                        if (opline->result_type == IS_CV) {
+                               if ((build_flags & ZEND_SSA_USE_CV_RESULTS)
+                                && opline->opcode != ZEND_RECV) {
+                                       ssa_ops[k].result_use = var[EX_VAR_TO_NUM(opline->result.var)];
+                               }
                                ssa_ops[k].result_def = ssa_vars_count;
                                var[EX_VAR_TO_NUM(opline->result.var)] = ssa_vars_count;
                                ssa_vars_count++;
@@ -1034,7 +1038,7 @@ int zend_ssa_compute_use_def_chains(zend_arena **arena, const zend_op_array *op_
                        op->op2_use_chain = ssa_vars[op->op2_use].use_chain;
                        ssa_vars[op->op2_use].use_chain = i;
                }
-               if (op->result_use >= 0) {
+               if (op->result_use >= 0 && op->result_use != op->op1_use && op->result_use != op->op2_use) {
                        op->res_use_chain = ssa_vars[op->result_use].use_chain;
                        ssa_vars[op->result_use].use_chain = i;
                }