Skip to content

test #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

test #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Zend/Optimizer/zend_inference.c
Original file line number Diff line number Diff line change
Expand Up @@ -1722,12 +1722,12 @@ static uint32_t get_ssa_alias_types(zend_ssa_alias_kind alias) {
}
}

#define UPDATE_SSA_TYPE(_type, _var) \
#define UPDATE_SSA_TYPE_EX(_type, _var, _propagate_any_on_ref) \
do { \
uint32_t __type = (_type) & ~MAY_BE_GUARD; \
int __var = (_var); \
if (__type & MAY_BE_REF) { \
__type |= MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF; \
__type |= MAY_BE_RC1 | MAY_BE_RCN | (_propagate_any_on_ref ? (MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF) : 0); \
} \
if (__var >= 0) { \
zend_ssa_var *__ssa_var = &ssa_vars[__var]; \
Expand Down Expand Up @@ -1761,6 +1761,8 @@ static uint32_t get_ssa_alias_types(zend_ssa_alias_kind alias) {
} \
} while (0)

#define UPDATE_SSA_TYPE(_type, _var) UPDATE_SSA_TYPE_EX(_type, _var, true)

#define UPDATE_SSA_OBJ_TYPE(_ce, _is_instanceof, var) \
do { \
if (var >= 0) { \
Expand Down Expand Up @@ -3550,7 +3552,7 @@ static zend_always_inline zend_result _zend_update_type_info(
zend_class_entry *ce;
bool ce_is_instanceof;
tmp = zend_get_func_info(call_info, ssa, &ce, &ce_is_instanceof);
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
UPDATE_SSA_TYPE_EX(tmp, ssa_op->result_def, false);
if (ce) {
UPDATE_SSA_OBJ_TYPE(ce, ce_is_instanceof, ssa_op->result_def);
}
Expand Down
6 changes: 3 additions & 3 deletions ext/opcache/tests/opt/verify_return_type.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ opcache.opt_debug_level=0x20000
opcache.preload=
--EXTENSIONS--
opcache
--XFAIL--
Return types cannot be inferred through prototypes
--FILE--
<?php

Expand Down Expand Up @@ -131,6 +129,8 @@ Test2::getInt3:
0003 V1 = DO_FCALL
0004 VERIFY_RETURN_TYPE V1
0005 RETURN V1
LIVE RANGES:
1: 0004 - 0005 (tmp/var)

Test3::getBool:
; (lines=1, args=0, vars=0, tmps=0)
Expand All @@ -143,4 +143,4 @@ Test3::getBool2:
; (after optimizer)
; %s
0000 V0 = QM_ASSIGN bool(true)
0001 RETURN bool(true)
0001 RETURN V0