diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-22 14:50:28 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-22 14:54:29 +0100 |
commit | 6a5d60085d381255da94789f69892a9c979948a2 (patch) | |
tree | 1e76818d61a81517e0b132723aa14ed8b692d793 /ext/opcache | |
parent | 8ed8cf86a98d1317c633189857ce4d64f105e6f7 (diff) | |
download | php-git-6a5d60085d381255da94789f69892a9c979948a2.tar.gz |
Support VERIFY_RETURN_TYPE elision with unused operand
This handles the degenerate case where SCCP replaced the value in
the RETURN opcode with a constant, but the VERIFY_RETURN is still
there. We can still apply the same optimization, just don't need
to adjust the use list in this case.
The result is still sub-optimal in that a dead QM_ASSIGN is left
behind.
Diffstat (limited to 'ext/opcache')
-rw-r--r-- | ext/opcache/tests/opt/verify_return_type.phpt | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/ext/opcache/tests/opt/verify_return_type.phpt b/ext/opcache/tests/opt/verify_return_type.phpt index 3838cd8b0c..7f52c829a4 100644 --- a/ext/opcache/tests/opt/verify_return_type.phpt +++ b/ext/opcache/tests/opt/verify_return_type.phpt @@ -37,6 +37,16 @@ class Test2 { } } +class Test3 { + private function getBool() { + return true; + } + + private function getBool2(): bool { + return $this->getBool(); + } +} + ?> --EXPECTF-- $_main: @@ -91,3 +101,16 @@ Test2::getInt3: 0003 V1 = DO_FCALL 0004 VERIFY_RETURN_TYPE V1 0005 RETURN V1 + +Test3::getBool: + ; (lines=1, args=0, vars=0, tmps=0) + ; (after optimizer) + ; %s +0000 RETURN bool(true) + +Test3::getBool2: + ; (lines=2, args=0, vars=0, tmps=1) + ; (after optimizer) + ; %s +0000 V0 = QM_ASSIGN bool(true) +0001 RETURN bool(true) |