[llvm] 07ece4e - [SimplifyLibCalls] Drop redundant CreatePointerCast in optimizeSPrintFString

Bjorn Pettersson via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 13:17:39 PDT 2023


Author: Bjorn Pettersson
Date: 2023-09-18T22:17:10+02:00
New Revision: 07ece4ed94eef1af44e2dfeaf99176418142daee

URL: https://github.com/llvm/llvm-project/commit/07ece4ed94eef1af44e2dfeaf99176418142daee
DIFF: https://github.com/llvm/llvm-project/commit/07ece4ed94eef1af44e2dfeaf99176418142daee.diff

LOG: [SimplifyLibCalls] Drop redundant CreatePointerCast in optimizeSPrintFString

Given the transition into using opaque pointers we no longer need to
add casts to handle "mismatched pointer types" as all pointers types
involved now are the same.

Added: 
    

Modified: 
    llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
index 3f6e6be2601ad61..40f5cdf3538fc38 100644
--- a/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
@@ -3103,9 +3103,6 @@ Value *LibCallSimplifier::optimizeSPrintFString(CallInst *CI,
       return ConstantInt::get(CI->getType(), SrcLen - 1);
     } else if (Value *V = emitStpCpy(Dest, CI->getArgOperand(2), B, TLI)) {
       // sprintf(dest, "%s", str) -> stpcpy(dest, str) - dest
-      // Handle mismatched pointer types (goes away with typeless pointers?).
-      V = B.CreatePointerCast(V, B.getInt8PtrTy());
-      Dest = B.CreatePointerCast(Dest, B.getInt8PtrTy());
       Value *PtrDiff = B.CreatePtrDiff(B.getInt8Ty(), V, Dest);
       return B.CreateIntCast(PtrDiff, CI->getType(), false);
     }


        


More information about the llvm-commits mailing list