[PATCH] PR string/19907: Incorrect memcpy tests
Florian Weimer
fw@deneb.enyo.de
Sun May 8 19:35:00 GMT 2016
* H. J. Lu:
> On Sun, May 8, 2016 at 10:14 AM, Florian Weimer <fw@deneb.enyo.de> wrote:
>> * H. J. Lu:
>>
>>> + /* Must clear the destination buffer set by the previous run. */
>>> + for (i = 0; i < len; i++)
>>> + dst[i] = 0;
>>
>> Doesn't this need some sort of compiler barrier so that GCC will not
>> eliminate the dead stores if it recognizes a memset-style loop?
>
> The code looks like:
>
> /* Must clear the destination buffer set by the previous run. */
> for (i = 0; i < len; i++)
> dst[i] = 0;
>
> if (CALL (impl, dst, src, len) != MEMCPY_RESULT (dst, len))
> {
>
> Compiler doesn't know what CALL (impl, dst, src, len) does
> and won't optimize it out.
I looked at the underlying mechanism and there's an indirection
through the “impls” section. You are right that it's going to take a
while until the compiler will see through that. In any case, it's a
pre-existing problem, not related to your change.
More information about the Libc-alpha
mailing list