[llvm] r355905 - [SimplifyLibCalls] Fix comments about fputs, memchr, and s[n]printf. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 03:31:52 PDT 2019
Author: maskray
Date: Tue Mar 12 03:31:52 2019
New Revision: 355905
URL: http://llvm.org/viewvc/llvm-project?rev=355905&view=rev
Log:
[SimplifyLibCalls] Fix comments about fputs, memchr, and s[n]printf. NFC
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/trunk/test/Transforms/InstCombine/fputs-1.ll
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp?rev=355905&r1=355904&r2=355905&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyLibCalls.cpp Tue Mar 12 03:31:52 2019
@@ -776,7 +776,8 @@ Value *LibCallSimplifier::optimizeMemChr
// 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 =
@@ -921,7 +922,7 @@ Value *LibCallSimplifier::optimizeMemCmp
// 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);
}
@@ -2094,7 +2095,8 @@ Value *LibCallSimplifier::optimizeSPrint
}
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;
@@ -2157,7 +2159,7 @@ Value *LibCallSimplifier::optimizeSnPrin
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,
@@ -2338,7 +2340,7 @@ Value *LibCallSimplifier::optimizeFPuts(
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;
Modified: llvm/trunk/test/Transforms/InstCombine/fputs-1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fputs-1.ll?rev=355905&r1=355904&r2=355905&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/fputs-1.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/fputs-1.ll Tue Mar 12 03:31:52 2019
@@ -12,7 +12,7 @@ target datalayout = "e-p:32:32:32-i1:8:8
declare i32 @fputs(i8*, %FILE*)
-; Check fputs(str, fp) --> fwrite(str, 1, strlen(s), fp).
+; Check fputs(str, fp) --> fwrite(str, strlen(s), 1, fp).
define void @test_simplify1(%FILE* %fp) {
; CHECK-LABEL: @test_simplify1(
More information about the llvm-commits
mailing list