Index: lib/CodeGen/Analysis.cpp =================================================================== --- lib/CodeGen/Analysis.cpp +++ lib/CodeGen/Analysis.cpp @@ -590,6 +590,7 @@ // argument. On other platforms like arm-none-eabi, memcpy may be // expanded as library call without return value, like __aeabi_memcpy. const CallInst *Call = cast(I); + auto *BitCastIn = dyn_cast(Call->getArgOperand(0)); if (Function *F = Call->getCalledFunction()) { Intrinsic::ID IID = F->getIntrinsicID(); if (((IID == Intrinsic::memcpy && @@ -598,7 +599,10 @@ TLI.getLibcallName(RTLIB::MEMMOVE) == StringRef("memmove")) || (IID == Intrinsic::memset && TLI.getLibcallName(RTLIB::MEMSET) == StringRef("memset"))) && - RetVal == Call->getArgOperand(0)) + (RetVal == Call->getArgOperand(0) || + (BitCastIn && RetVal == BitCastIn->getOperand(0) && + Call->getArgOperand(0)->getType()->isPointerTy() && + BitCastIn->getOperand(0)->getType()->isPointerTy()))) return true; }