[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
Wed Jun 15 14:14:04 PDT 2022


goldstein.w.n added a comment.

In D127461#3586945 <https://reviews.llvm.org/D127461#3586945>, @efriedma wrote:

> We already effectively have a platform version number on Mac/iOS/Android; adding a version number for another platform isn't a big deal.  (Yes, it doesn't really scale in the sense that every libc needs to have some entries in TargetLibraryInfo.cpp, but we basically end up doing that anyway, in practice.)
>
> The tricky thing is that there isn't any easy way to tell the glibc version number.  The clang driver would have to dig through either system headers or the glibc library itself.

Parsing "libc.so.6" for ".gnu.version_d" wouldn't be an insane way to do it.

> The alternative is that clang IR generation could check if __memcmpeq is declared somewhere in the file, and add some metadata to the module.  That's also sort of ugly, but maybe easier to implement.

I like the idea of doing this at IR generation time.

What do you think about just using the clang AST and checking if there is a valid definition for __memcmpeq + isGNUEnvironment?
It's in the reserved namespace so as long as its not another libc re-purposing the symbol that should be safe.

That also seems to the direction GCC is going so it would be maximum compatibility.


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