[llvm] [IPSCCP] Infer nonnull return attribute (PR #106553)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 08:21:50 PDT 2024
================
@@ -296,6 +296,14 @@ static bool runIPSCCP(
F->addRangeRetAttr(CR);
continue;
}
+ // Infer nonnull return attribute.
+ if (F->getReturnType()->isPointerTy() && ReturnValue.isNotConstant() &&
+ ReturnValue.getNotConstant()->isNullValue() &&
+ !F->hasRetAttribute(Attribute::NonNull) &&
+ !F->hasRetAttribute(Attribute::Dereferenceable)) {
----------------
nikic wrote:
Good point, I dropped the check. FunctionAttrs doesn't check this either.
https://github.com/llvm/llvm-project/pull/106553
More information about the llvm-commits
mailing list