Skip to content

Commit

Permalink
[SimplifyLibCalls] Drop redundant CreatePointerCast in optimizeSPrint…
Browse files Browse the repository at this point in the history
…FString

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.
  • Loading branch information
bjope committed Sep 18, 2023
1 parent 08fdbbe commit 07ece4e
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 07ece4e

Please sign in to comment.