[llvm] Support non-malloc functions in malloc+memset->calloc fold (PR #138299)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri May 2 13:13:55 PDT 2025
================
@@ -2028,9 +2028,19 @@ struct DSEState {
if (!InnerCallee)
return false;
LibFunc Func;
+ std::optional<StringRef> ZeroedVariantName = std::nullopt;
if (!TLI.getLibFunc(*InnerCallee, Func) || !TLI.has(Func) ||
- Func != LibFunc_malloc)
- return false;
+ Func != LibFunc_malloc) {
+ if (!Malloc->hasFnAttr("alloc-variant-zeroed") ||
----------------
nikic wrote:
Directly use getFnAttr() and check isValid() on it, instead of the separate hasFnAttr call.
https://github.com/llvm/llvm-project/pull/138299
More information about the llvm-commits
mailing list