Skip to content

remove flag ZEND_DEBUG check for ZEND_ASSERT #13159

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

Conversation

jorgsowa
Copy link
Contributor

Flag ZEND_DEBUG is checked anyway in macro ZEND_ASSERT, so this code is redundant.

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without ZEND_DEBUG, ZEND_ASSERT is expanded to ZEND_ASSUME that is not always free. Especially in this place it leaded to a worse final code.

@jorgsowa
Copy link
Contributor Author

Sorry. I thought it should be the same as for functions below zval_set_refcount_p or zval_addref_p.

@jorgsowa jorgsowa closed this Jan 16, 2024
@iluuu1994
Copy link
Member

iluuu1994 commented Jan 16, 2024

@dstogov On GCC, with if (__builtin_expect(!(c), 0)) __builtin_unreachable();? That is surprising to me...

If that's the case, we may try to move to __attribute__((assume(...)));, which is apparently supported on GCC in C (https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes-1).

@dstogov
Copy link
Member

dstogov commented Jan 16, 2024

@dstogov On GCC, with if (__builtin_expect(!(c), 0)) __builtin_unreachable();? That is surprising to me...

In most cases this should be eliminated by the compiler and also help to optimise the program, but in some cases (when condition may make a side effect) this may lead to extra code.

@iluuu1994
Copy link
Member

@dstogov According to the documentation, __attribute__((assume(...))) is guaranteed not to have side-effects, so maybe we should try that.

@jorgsowa
Copy link
Contributor Author

If #13171 is merged, does it mean that this PR can be merged also?

@iluuu1994
Copy link
Member

@jorgsowa No, #13171 is only applicable to GCC 13.

@jorgsowa jorgsowa deleted the remove-zend-debug-flag-check branch February 8, 2024 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants