[libcxx-commits] [PATCH] D122397: [libc++] Use __builtin_expect in _LIBCPP_ASSERT
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 24 11:52:36 PDT 2022
philnik added a comment.
In D122397#3406074 <https://reviews.llvm.org/D122397#3406074>, @ldionne wrote:
> In D122397#3405618 <https://reviews.llvm.org/D122397#3405618>, @philnik wrote:
>
>> Maybe it would make sense to use `__builtin_assume` if assertions are disabled?
>
> My understanding is that `__builtin_assume(x)` does not evaluate `x` ever at runtime, but the documentation is a little bit light on the details. I think this is a fantastic idea, I'll try it out. If `__builtin_assume` does evaluate `x`, I added a test that should fail in my assertions handler patch.
I'm pretty sure it doesn't evaluate at compile-time. https://godbolt.org/z/8d7fh8nc7 clang specifically warns that side-effects will be discarded.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122397/new/
https://reviews.llvm.org/D122397
More information about the libcxx-commits
mailing list