Skip to content

Commit 1321ef9

Browse files
committed
Tweak
1 parent 7da5a5c commit 1321ef9

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

Zend/Optimizer/dfa_pass.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,14 @@ void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx
11311131
ssa_verify_integrity(op_array, ssa, "before dfa");
11321132
#endif
11331133

1134+
/* Optimization should not be done on main because of globals. */
1135+
if (op_array->function_name) {
1136+
zend_dfa_optimize_send_copies(op_array, ssa);
1137+
#if ZEND_DEBUG_DFA
1138+
ssa_verify_integrity(op_array, ssa, "after optimize send copies");
1139+
#endif
1140+
}
1141+
11341142
if (ZEND_OPTIMIZER_PASS_8 & ctx->optimization_level) {
11351143
if (sccp_optimize_op_array(ctx, op_array, ssa, call_map)) {
11361144
remove_nops = 1;
@@ -1171,14 +1179,6 @@ void zend_dfa_optimize_op_array(zend_op_array *op_array, zend_optimizer_ctx *ctx
11711179
#endif
11721180
}
11731181

1174-
/* Optimization should not be done on main because of globals. */
1175-
if (op_array->function_name) {
1176-
zend_dfa_optimize_send_copies(op_array, ssa);
1177-
#if ZEND_DEBUG_DFA
1178-
ssa_verify_integrity(op_array, ssa, "after optimize send copies");
1179-
#endif
1180-
}
1181-
11821182
for (v = op_array->last_var; v < ssa->vars_count; v++) {
11831183

11841184
op_1 = ssa->vars[v].definition;

Zend/Optimizer/sccp.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,12 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op *ssa_o
10531053
SKIP_IF_TOP(op1);
10541054

10551055
if (opline->opcode == ZEND_SEND_VAR) {
1056-
SET_RESULT(op1, op1);
1056+
if (opline->extended_value) {
1057+
ZVAL_UNDEF(&zv);
1058+
SET_RESULT(op1, &zv);
1059+
} else {
1060+
SET_RESULT(op1, op1);
1061+
}
10571062
}
10581063

10591064
/* If the value of a SEND for an ICALL changes, we need to reconsider the
@@ -2346,8 +2351,11 @@ static int replace_constant_operands(sccp_ctx *ctx) {
23462351
FOREACH_USE(var, use) {
23472352
zend_op *opline = &op_array->opcodes[use];
23482353
zend_ssa_op *ssa_op = &ssa->ops[use];
2354+
/* Removing the def in try_remove_definition() may reduce optimisation opportunities.
2355+
* So only remove it when we actually want to replace it (?) */ // TODO
23492356
if (opline->opcode == ZEND_SEND_VAR && ssa_op->op1_use == i && ssa_op->op1_def >= 0) {
23502357
zend_ssa_replace_op1_def_op1_use(ssa, ssa_op);
2358+
opline->extended_value = 0;
23512359
}
23522360
if (try_replace_op1(ctx, opline, ssa_op, i, value)) {
23532361
if (opline->opcode == ZEND_NOP) {

Zend/Optimizer/zend_inference.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,6 +2951,7 @@ static zend_always_inline zend_result _zend_update_type_info(
29512951
tmp |= MAY_BE_RCN;
29522952
}
29532953
if ((t1 & (MAY_BE_ARRAY|MAY_BE_STRING)) && (t1 & MAY_BE_RC1) && !(t1 & (MAY_BE_UNDEF|MAY_BE_REF)) && ssa_vars[ssa_op->op1_def].no_val && !ssa_vars[ssa_op->op1_def].alias) {
2954+
/* implicit move may make value undef */
29542955
tmp |= MAY_BE_UNDEF;
29552956
}
29562957
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);
@@ -2995,6 +2996,7 @@ static zend_always_inline zend_result _zend_update_type_info(
29952996
if (ssa_op->op1_def >= 0) {
29962997
tmp = (t1 & MAY_BE_UNDEF)|MAY_BE_REF|MAY_BE_RC1|MAY_BE_RCN|MAY_BE_ANY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF;
29972998
if (opline->opcode == ZEND_SEND_VAR_EX && (t1 & (MAY_BE_ARRAY|MAY_BE_STRING)) && (t1 & MAY_BE_RC1) && !(t1 & (MAY_BE_UNDEF|MAY_BE_REF)) && ssa_vars[ssa_op->op1_def].no_val && !ssa_vars[ssa_op->op1_def].alias) {
2999+
/* implicit move may make value undef */
29983000
tmp |= MAY_BE_UNDEF;
29993001
}
30003002
UPDATE_SSA_TYPE(tmp, ssa_op->op1_def);

0 commit comments

Comments
 (0)