[PATCH] D50233: [InstCombine] Transform str(n)cmp to memcmp

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 12:45:15 PDT 2018


xbolva00 added a comment.

In https://reviews.llvm.org/D50233#1223686, @adamreichold wrote:

> In https://reviews.llvm.org/D50233#1223683, @efriedma wrote:
>
> > > Does LLVM's implementation somehow guarantee that no later optimization pass comes along, sees the program reading uninitialized memory and declares UB?
> >
> > In LLVM IR, reading uninitialized memory isn't itself UB; it's only UB if you perform certain operations on the result.  Granted, a naive LLVM IR implementation of memcmp might involve operations which lead to UB.
>
>
> But that also implies that you have to emit an inline implementation since you might not control what the implementation of `memcmp` supplied by `libc` does?


LLVM already expands memcmp if possible, as we can see https://godbolt.org/z/o9CEYv (vs. https://godbolt.org/z/D8RhVl)


Repository:
  rL LLVM

https://reviews.llvm.org/D50233





More information about the llvm-commits mailing list