[PATCH] D127461: [SelectionDAG] Use __memcmpeq to replace bcmp and bool usage memcmp

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 15:44:55 PDT 2022


goldstein.w.n added a comment.

In D127461#3587063 <https://reviews.llvm.org/D127461#3587063>, @xbolva00 wrote:

>>> What do you think about just using the clang AST and checking if there is a valid definition for __memcmpeq + isGNUEnvironment?
>
> And if there is no declaration and somebody wrote “__builtin_memcmp(…) == 0” ? We sadly cannot use memcmpeq then, no?

No because the function may not exist.

But it will catch all the cases the function does exist w.o a commandline option. The reason I'm a bit partial to this is
if the optimization is guarded by a commandline option it see very little usage.

The only case the AST would miss is a build where `memcmp` was called w.o `<string.h>` being included. This seems
edge case enough to me its worth accepting.

In a few years time once GLIBC2.35 becomes the norm the replacement can become default like bcmp.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127461/new/

https://reviews.llvm.org/D127461



More information about the llvm-commits mailing list