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

Adam Reichold via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 12:11:33 PDT 2018


adamreichold added a comment.

>> limited to functions w/o sanitize_memory attribute
> 
> Sounds OK for me, let's hear other folks.
> 
> Edit: Seems GCC does not do this opt if memory sanitizer is on.

Just for my understand of this: If I do that replacement by hand, I am reading uninitialized memory and all bets are of. The compiler however can do this behind the scenes since my program will not be able to observe the indeterminate state (since I am looking only at `== 0` of the return value of `strcmp`.)

Does LLVM's implementation somehow guarantee that no later optimization pass comes along, sees the program reading uninitialized memory and declares UB?


Repository:
  rL LLVM

https://reviews.llvm.org/D50233





More information about the llvm-commits mailing list