]> granicus.if.org Git - llvm/commitdiff
[SimplifyLibCalls] Fix comments about fputs, memchr, and s[n]printf. NFC
authorFangrui Song <maskray@google.com>
Tue, 12 Mar 2019 10:31:52 +0000 (10:31 +0000)
committerFangrui Song <maskray@google.com>
Tue, 12 Mar 2019 10:31:52 +0000 (10:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355905 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyLibCalls.cpp
test/Transforms/InstCombine/fputs-1.ll

index 86df9339874425e25d40abaee4c6061e296a0731..b8a18a10f29b307f32388e40b027310e3679465b 100644 (file)
@@ -776,7 +776,8 @@ Value *LibCallSimplifier::optimizeMemChr(CallInst *CI, IRBuilder<> &B) {
   // 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(CallInst *CI, IRBuilder<> &B) {
 
   // 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::optimizeSPrintFString(CallInst *CI, IRBuilder<> &B) {
   }
 
   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::optimizeSnPrintFString(CallInst *CI, IRBuilder<> &B) {
     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(CallInst *CI, IRBuilder<> &B) {
       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;
index 1c245753e61f147e2e6b46f765c7d9fe2c038a01..4bf54b155a42c9f6d54e03cc4da124c34643a843 100644 (file)
@@ -12,7 +12,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
 
 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(