[PATCH] D50233: [InstCombine] Transform str(n)cmp to memcmp
Evgenii Stepanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 4 11:40:14 PDT 2018
eugenis added subscribers: rsmith, eugenis.
eugenis added a comment.
There are concerns about this optimization expressed in
https://github.com/google/sanitizers/issues/993
Specifically, it can transform
strcmp("abc\0...undef...undef...", "foobar")
into a similar memcmp() which would observe uninitialized data at the end of the first string.
I'm not a 100% sure that it is undefined behavior because there are no indeterminate values in the code at all, and memcmp() as a standard library function does not have to follow the same rules (technically). @rsmith But it upsets MemorySanitizer, and for a good reason IMHO.
This optimization should be either limited to functions w/o sanitize_memory attribute, or disabled completely.
Repository:
rL LLVM
https://reviews.llvm.org/D50233
More information about the llvm-commits
mailing list