[cfe-dev] Clang builtins for C++20 STL features

James Y Knight via cfe-dev cfe-dev at lists.llvm.org
Fri Nov 30 12:35:04 PST 2018


On Thu, Nov 29, 2018, 9:53 PM Richard Smith via cfe-dev <
cfe-dev at lists.llvm.org wrote:

> * P0528R3 Atomic Compare-And-Exchange With Padding Bits
>> We need compiler magic here, in some form. Billy O'Neal wrote to the C1XX
>> team: "To implement the new atomic_ref as well as the change to compare the
>> value representation of atomics only, the library needs a way to zero out
>> the padding in arbitrary T, which we can't discover with library tech
>> alone. We would like an intrinsic that accepts a trivially-copyable T and
>> produces a copy with the padding zeroed, or takes a T* and zeros the
>> padding inside that T, or similar."
>>
>
> I think this should be done in-place in memory; producing a copy has the
> problem that you're passing around a value of type T, and that might permit
> the padding bits to become undefined again.
>
> void __builtin_clear_padding(T *ptr)
> Effects: Set to zero all bits that are padding bits in the representation
> of every value of type T.
>

Is the intent here that every value stored into a std::atomic (e.g. via
store, exchange, or compare_exchange) would be passed through
__builtin_clear_padding first, before being stored into the atomic object?
And presumably the same would need to occur implicitly for C-style `_Atomic
T`?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181130/560d6677/attachment.html>


More information about the cfe-dev mailing list