[llvm] [AArch64] Don't tail call memset if it would convert to a bzero. (PR #98969)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 15 15:18:04 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)))) &&
----------------
efriedma-quic wrote:
This is sort of ugly... if this code doesn't precisely match SelectionDAG::getMemset, we miscompile.
Can we rearrange the code so that the caller of isInTailCallPosition() does this computation? That could be directly adjacent to the code in getMemset that actually makes the decision of whether to call memset or bzero. We then just pass that into isInTailCallPosition() as a argument.
https://github.com/llvm/llvm-project/pull/98969
More information about the llvm-commits
mailing list