// It would be really nice to reuse switch lowering here but we can't change
// the CFG at this point.
//
- // memchr("\r\n", C, 2) != nullptr -> (C & ((1 << '\r') | (1 << '\n'))) != 0
+ // memchr("\r\n", C, 2) != nullptr -> (1 << C & ((1 << '\r') | (1 << '\n')))
+ // != 0
// after bounds check.
if (!CharC && !Str.empty() && isOnlyUsedInZeroEqualityComparison(CI)) {
unsigned char Max =
// memcmp(x, y, Len) == 0 -> bcmp(x, y, Len) == 0
// `bcmp` can be more efficient than memcmp because it only has to know that
- // there is a difference, not where is is.
+ // there is a difference, not where it is.
if (isOnlyUsedInZeroEqualityComparison(CI) && TLI->has(LibFunc_bcmp)) {
return emitBCmp(LHS, RHS, Size, B, DL, TLI);
}
}
if (FormatStr[1] == 's') {
- // sprintf(dest, "%s", str) -> llvm.memcpy(dest, str, strlen(str)+1, 1)
+ // sprintf(dest, "%s", str) -> llvm.memcpy(align 1 dest, align 1 str,
+ // strlen(str)+1)
if (!CI->getArgOperand(2)->getType()->isPointerTy())
return nullptr;
else if (N < FormatStr.size() + 1)
return nullptr;
- // sprintf(str, size, fmt) -> llvm.memcpy(align 1 str, align 1 fmt,
+ // snprintf(dst, size, fmt) -> llvm.memcpy(align 1 dst, align 1 fmt,
// strlen(fmt)+1)
B.CreateMemCpy(
CI->getArgOperand(0), 1, CI->getArgOperand(2), 1,
return nullptr;
}
- // fputs(s,F) --> fwrite(s,1,strlen(s),F)
+ // fputs(s,F) --> fwrite(s,strlen(s),1,F)
uint64_t Len = GetStringLength(CI->getArgOperand(0));
if (!Len)
return nullptr;