[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
Mon Jul 15 15:28:22 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:
Maybe I'm not understanding what you're suggesting. `isInTailCallPosition` is called in multiple places so adding in an extra parameter doesn't make it any cleaner IMO. getMemset() is called later, by that point we've already decided to tail-call. We could downgrade the tail call in getMemset() but then we also lose the tail-call when the parent function's return type was void or it returned undef.
https://github.com/llvm/llvm-project/pull/98969
More information about the llvm-commits
mailing list