[llvm-dev] Which assumptions do llvm.memcpy/memmove/memset.* make when the count is 0?
Ralf Jung via llvm-dev
llvm-dev at lists.llvm.org
Fri Jul 21 12:30:07 PDT 2017
On 21.07.2017 11:39, Joerg Sonnenberger wrote:
> On Fri, Jul 21, 2017 at 09:31:41AM -0600, John Regehr via llvm-dev wrote:
>> I propose documenting in the LangRef that memcpy and related intrinsics are
>> defined even when src and dst don't refer to valid storage as long as the
>> length argument is zero. Then we commit to implementing that behavior. Is
>> that OK with everyone? If so I can update the doc.
> I don't think that was the conclusion of the discussion? I mean the
> result was that a NULL pointer should be explicitly valid if the length
> argument is zero. That's a bit more restrictive.
What exactly does valid storage even mean here? When memset is called
to change 4 bytes, all those 4 bytes have to be in valid storage; but
when the count is 0 -- essentially all this needs is an allocation of
length 0, which could be pretty much any pointer? NULL is always
special and hence need separate consideration, but for non-NULL, aren't
they all valid storage of size 0 (but potentially not aligned)?
More information about the llvm-dev