[PATCH] D154725: [SimplifyLibCalls] Fold strcmp for short string literals
Maksim Kita via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 8 10:33:44 PDT 2023
kitaisreal added inline comments.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:576
+ if (Str2.size() == 1) {
+ return FirstCharacterSub;
+ }
----------------
nikic wrote:
> This will return an incorrect result if the first character of Str1 and Str2 is the same, but Str1 has length greater than one.
Updated implementation.
================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:581
+ B.CreateLoad(B.getInt8Ty(),
+ B.CreateConstInBoundsGEP1_32(B.getInt8Ty(), Str1P, 1)),
+ B.getInt32Ty(), true);
----------------
nikic wrote:
> This may perform an out of bounds access for zero-length strings.
Updated implementation.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154725/new/
https://reviews.llvm.org/D154725
More information about the llvm-commits
mailing list