Re: objtool warning "uses BP as a scratch register" with clang-9
From: Linus Torvalds
Date: Fri Aug 30 2019 - 12:01:27 EST
On Fri, Aug 30, 2019 at 8:55 AM David Laight <David.Laight@xxxxxxxxxx> wrote:
> Even in userspace you might be accessing mmap()ed PCIe device memory.
> The last thing you want is the compiler converting anything into
> 'rep movsb'.
Agreed, although for actual IO accesses you likely should really be
doing "volatile" anyway.
But yeah, in general it's just not obviously safe to turn individual
accesses into memset/memcpy. In contrast, the reverse is obviously
fine (and _required_ for any kind of half-way good performance when
you do small constant-sized memory copies, which is actually a common
pattern partly because the insane C aliasing rules have taught people
that it's the _only_ safe pattern in some situations).
This is why I think "-ffreestanding" and "-fno-builtin-memcpy" are
completely broken as-is: they are an all-or-nothing thing, they don't
understand that it's directional.