From 6af1ffb57d097ae48ae11256c3323ecf2f042fe6 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 30 Mar 2017 20:14:01 +0300 Subject: [PATCH] Allow SSA construction with source information about CV used as result --- ext/opcache/Optimizer/zend_cfg.h | 1 + ext/opcache/Optimizer/zend_inference.c | 3 +++ ext/opcache/Optimizer/zend_ssa.c | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ext/opcache/Optimizer/zend_cfg.h b/ext/opcache/Optimizer/zend_cfg.h index 7b80d83f11..d24bbd910d 100644 --- a/ext/opcache/Optimizer/zend_cfg.h +++ b/ext/opcache/Optimizer/zend_cfg.h @@ -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) ? \ diff --git a/ext/opcache/Optimizer/zend_inference.c b/ext/opcache/Optimizer/zend_inference.c index 285d443d18..9472f00f93 100644 --- a/ext/opcache/Optimizer/zend_inference.c +++ b/ext/opcache/Optimizer/zend_inference.c @@ -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; } diff --git a/ext/opcache/Optimizer/zend_ssa.c b/ext/opcache/Optimizer/zend_ssa.c index b393cd2d13..2f5f359767 100644 --- a/ext/opcache/Optimizer/zend_ssa.c +++ b/ext/opcache/Optimizer/zend_ssa.c @@ -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; } -- 2.50.1