[llvm] Support non-malloc functions in malloc+memset->calloc fold (PR #138299)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat May 3 00:52:57 PDT 2025
================
@@ -2377,6 +2377,32 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
CheckFailed("'allockind()' can't be both zeroed and uninitialized");
}
+ if (Attrs.hasFnAttr("alloc-variant-zeroed")) {
+ if (auto A = Attrs.getFnAttr("alloc-variant-zeroed"); A.isValid()) {
+ StringRef s = A.getValueAsString();
+ Check(!s.empty(), "\"alloc-variant-zeroed\" must not be empty");
+ if (auto *F = dyn_cast<Function>(V)) {
+ if (auto Variant = F->getParent()->getFunction(s)) {
+ auto Family = Attrs.getFnAttr("alloc-family");
+ if (Family.isValid())
+ Check(Variant->getFnAttribute("alloc-family").isValid() &&
----------------
nikic wrote:
Move the duplicate getFnAttribute() call out of the check.
https://github.com/llvm/llvm-project/pull/138299
More information about the llvm-commits
mailing list