[llvm-dev] [RFC] Adding a -memeq-lib-function flag to allow the user to specify a memeq function.

James Y Knight via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 9 09:16:26 PST 2019

On Tue, Jan 8, 2019 at 9:24 AM Clement Courbet <courbet at google.com> wrote:

> On Mon, Jan 7, 2019 at 10:26 PM James Y Knight <jyknight at google.com>
> wrote:
I'm afraid about the "almost" and "generally": what about users who don't ?

Even so, it should be fine to enable it for those platforms which do
include it.

I do note, sadly, that currently out of all these implementations, only
>> NetBSD and FreeBSD seem to actually define a separate more optimized bcmp
>> function. That does mean that this optimization would be effectively a
>> no-op, for the vast majority of people.
> This might or might not be considered really an issue.

Right, the issue is adding an effectively useless optimization in llvm.

 - In my original proposal, people have to explicitly opt-in to the feature
> and link to their memcmp implementation, they do not get the improvement
> automatically.
>  - In this proposal, they have to patch their libc, which might be
> slightly more painful depending on the system.

Users may also include a function named bcmp in their binary, which will
overrides the one from libc.

Here's a patch with this proposal to see what this looks like:
> https://reviews.llvm.org/D56436

It feels like this optimization would be better done in
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp, and the presence/name
checking done via TargetLibraryInfo.cpp.

 But if you can show a similar performance win in public code, it'd be
>> great to attempt to push a more optimized version upstream at least to
>> glibc. Some more precise numbers than "very large improvement" are probably
>> necessary to show it's actually worth it. :)
> We were planning to contribute it to compiler-rt. Contributing a
> deprecated function to the libc sounds.... weird.

Yes, contributing an optimization for a deprecated function is indeed
weird. Thus the importance of reliable performance numbers justifying the
importance -- I'd never have thought that the performance cost of returning
an ordering from memcmp would be important, and I suspect nobody else did.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190109/cdaa5f8f/attachment.html>

More information about the llvm-dev mailing list