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

Clement Courbet via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 7 04:52:57 PST 2019

On Mon, Jan 7, 2019 at 1:43 PM David Jones <david.jones at metrics.ca> wrote:

> On Mon, Jan 7, 2019 at 5:50 AM Clement Courbet <courbet at google.com> wrote:
>> Hi David & James,
>> On Sat, Jan 5, 2019 at 1:17 AM David Jones <david.jones at metrics.ca>
>> wrote:
>>> If we are considering an optimization to convert calls to memcmp into
>>> bcmp, then does it make sense to add an intrinsic for bcmp like there is
>>> for memcmp?  That way IR writers can express their requirements precisely:
>>> memcmp if you care about the direction of inequality, and bcmp if you do
>>> not.
>> As mentioned in my answer to Hal above, I think the backend at least
>> should be able to do this.
>> Then adding an intrinsic is only for for convenience, because if the
>> backend can do the optimization automatically it's enough for the frontend
>> to emit the attribute. For example, for a language that has a runtime which
>> as a memeq/bcmp, the frontend could just emit the call site annotation. I
>> have no strong opinion on whether the convenience justifies an intrinsic.
> However, there may be cases where the optimizer cannot determine that a
> call to memcmp can be reduced to bcmp.  e.g. I pass the result of memcmp()
> to some externally-defined function unknown to LLVM. I would like to be
> able to specify bcmp explicitly in this case.

Ah yes, that makes sense.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190107/53d6fae7/attachment.html>

More information about the llvm-dev mailing list