2020#include "zend_compile.h"
2121#include "zend_dfg.h"
2222
23- int zend_build_dfg (const zend_op_array * op_array , const zend_cfg * cfg , zend_dfg * dfg ) /* {{{ */
23+ int zend_build_dfg (const zend_op_array * op_array , const zend_cfg * cfg , zend_dfg * dfg , uint32_t build_flags ) /* {{{ */
2424{
2525int set_size ;
2626zend_basic_block * blocks = cfg -> blocks ;
@@ -89,18 +89,33 @@ int zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg
8989}
9090if (opline -> op1_type == IS_CV ) {
9191switch (opline -> opcode ) {
92+ case ZEND_ADD_ARRAY_ELEMENT :
93+ case ZEND_INIT_ARRAY :
94+ if ((build_flags & ZEND_SSA_RC_INFERENCE )
95+ || (opline -> extended_value & ZEND_ARRAY_ELEMENT_REF )) {
96+ goto op1_def ;
97+ }
98+ goto op1_use ;
99+ case ZEND_FE_RESET_R :
100+ if (build_flags & ZEND_SSA_RC_INFERENCE ) {
101+ goto op1_def ;
102+ }
103+ goto op1_use ;
104+ case ZEND_YIELD :
105+ if ((build_flags & ZEND_SSA_RC_INFERENCE )
106+ || (op_array -> fn_flags & ZEND_ACC_RETURN_REFERENCE )) {
107+ goto op1_def ;
108+ }
109+ goto op1_use ;
92110case ZEND_ASSIGN :
93111case ZEND_ASSIGN_REF :
94112case ZEND_BIND_GLOBAL :
95113case ZEND_BIND_STATIC :
96114case ZEND_SEND_VAR_EX :
97115case ZEND_SEND_REF :
98116case ZEND_SEND_VAR_NO_REF :
99- case ZEND_FE_RESET_R :
100117case ZEND_FE_RESET_RW :
101- case ZEND_ADD_ARRAY_ELEMENT :
102- case ZEND_INIT_ARRAY :
103- case ZEND_YIELD :
118+ op1_def :
104119if (!DFG_ISSET (use , set_size , j , EX_VAR_TO_NUM (opline -> op1 .var ))) {
105120// FIXME: include into "use" to ...?
106121DFG_SET (use , set_size , j , EX_VAR_TO_NUM (opline -> op1 .var ));
@@ -141,6 +156,7 @@ int zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg
141156case ZEND_FETCH_OBJ_UNSET :
142157DFG_SET (gen , set_size , j , EX_VAR_TO_NUM (opline -> op1 .var ));
143158default :
159+ op1_use :
144160if (!DFG_ISSET (def , set_size , j , EX_VAR_TO_NUM (opline -> op1 .var ))) {
145161DFG_SET (use , set_size , j , EX_VAR_TO_NUM (opline -> op1 .var ));
146162}
@@ -154,10 +170,19 @@ int zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg
154170if (opline -> op2_type == IS_CV ) {
155171switch (opline -> opcode ) {
156172case ZEND_ASSIGN :
173+ if (build_flags & ZEND_SSA_RC_INFERENCE ) {
174+ goto op2_def ;
175+ }
176+ goto op2_use ;
177+ case ZEND_BIND_LEXICAL :
178+ if ((build_flags & ZEND_SSA_RC_INFERENCE ) || opline -> extended_value ) {
179+ goto op2_def ;
180+ }
181+ goto op2_use ;
157182case ZEND_ASSIGN_REF :
158183case ZEND_FE_FETCH_R :
159184case ZEND_FE_FETCH_RW :
160- case ZEND_BIND_LEXICAL :
185+ op2_def :
161186if (!DFG_ISSET (use , set_size , j , EX_VAR_TO_NUM (opline -> op2 .var ))) {
162187// FIXME: include into "use" to ...?
163188DFG_SET (use , set_size , j , EX_VAR_TO_NUM (opline -> op2 .var ));
@@ -166,6 +191,7 @@ int zend_build_dfg(const zend_op_array *op_array, const zend_cfg *cfg, zend_dfg
166191DFG_SET (gen , set_size , j , EX_VAR_TO_NUM (opline -> op2 .var ));
167192break ;
168193default :
194+ op2_use :
169195if (!DFG_ISSET (def , set_size , j , EX_VAR_TO_NUM (opline -> op2 .var ))) {
170196DFG_SET (use , set_size , j , EX_VAR_TO_NUM (opline -> op2 .var ));
171197}
0 commit comments