[llvm] f4eafba - [MemCpyOpt] Remove unnecessary bitcast and reuse some variables for ByValOptimization (NFC)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 4 00:12:09 PDT 2023
Author: khei4
Date: 2023-06-04T15:37:41+09:00
New Revision: f4eafba2064d52f992e6f32c957f3d51d8627975
URL: https://github.com/llvm/llvm-project/commit/f4eafba2064d52f992e6f32c957f3d51d8627975
DIFF: https://github.com/llvm/llvm-project/commit/f4eafba2064d52f992e6f32c957f3d51d8627975.diff
LOG: [MemCpyOpt] Remove unnecessary bitcast and reuse some variables for ByValOptimization (NFC)
Differential Revision: https://reviews.llvm.org/D152056
Added:
Modified:
llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index b9582fc0ed018..2f04cf35933c0 100644
--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -1591,24 +1591,15 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
// foo(*a)
// It would be invalid to transform the second memcpy into foo(*b).
if (writtenBetween(MSSA, BAA, MemoryLocation::getForSource(MDep),
- MSSA->getMemoryAccess(MDep), MSSA->getMemoryAccess(&CB)))
+ MSSA->getMemoryAccess(MDep), CallAccess))
return false;
- Value *TmpCast = MDep->getSource();
- if (MDep->getSource()->getType() != ByValArg->getType()) {
- BitCastInst *TmpBitCast = new BitCastInst(MDep->getSource(), ByValArg->getType(),
- "tmpcast", &CB);
- // Set the tmpcast's DebugLoc to MDep's
- TmpBitCast->setDebugLoc(MDep->getDebugLoc());
- TmpCast = TmpBitCast;
- }
-
LLVM_DEBUG(dbgs() << "MemCpyOptPass: Forwarding memcpy to byval:\n"
<< " " << *MDep << "\n"
<< " " << CB << "\n");
// Otherwise we're good! Update the byval argument.
- CB.setArgOperand(ArgNo, TmpCast);
+ CB.setArgOperand(ArgNo, MDep->getSource());
++NumMemCpyInstr;
return true;
}
More information about the llvm-commits
mailing list