[llvm] [AArch64] Don't tail call memset if it would convert to a bzero. (PR #98969)
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 16 10:31:10 PDT 2024
================
@@ -685,7 +687,10 @@ bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
(IID == Intrinsic::memmove &&
TLI.getLibcallName(RTLIB::MEMMOVE) == StringRef("memmove")) ||
(IID == Intrinsic::memset &&
- TLI.getLibcallName(RTLIB::MEMSET) == StringRef("memset"))) &&
+ TLI.getLibcallName(RTLIB::MEMSET) == StringRef("memset") &&
+ (!isa<ConstantInt>(Call->getOperand(1)) ||
+ !cast<ConstantInt>(Call->getOperand(1))->isZero() ||
+ !TLI.getLibcallName(RTLIB::BZERO)))) &&
----------------
aemerson wrote:
I tried to implement this. It didn't turn out as well as I'd hoped, memset is ok to do and we the logic for memset. However for memmove we have a user in XCore which is computing a tail-call-position using a DAG node without any reference to a `CallInst` so we can't do the same thing there. From what I could tell memcpy usages seemed ok to convert too but I didn't check all of them since there were so many.
https://github.com/llvm/llvm-project/pull/98969
More information about the llvm-commits
mailing list