-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle constant "pointers" for
__atomic_always_lock_free
/`__atomic_…
…is_lock_free`. (#99340) The second argument passed to these builtins is used to validate whether the object's alignment is sufficient for atomic operations of the given size. Currently, the builtins can be folded at compile time only when the argument is 0/nullptr, or if the _type_ of the pointer guarantees appropriate alignment. This change allows the compiler to also evaluate non-null constant pointers, which enables callers to check a specified alignment, instead of only the type or an exact object. E.g.: `__atomic_is_lock_free(sizeof(T), (void*)4)` can be potentially evaluated to true at compile time, instead of generating a libcall. This is also supported by GCC, and used by libstdc++, and is also useful for libc++'s atomic_ref. Also helps with (but doesn't fix) issue #75081. This also fixes a crash bug, when the second argument was a non-pointer implicitly convertible to a pointer (such as an array, or a function).
- Loading branch information
Showing
3 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters