================ @@ -1279,6 +1280,43 @@ static void addNonNullAttrs(const SCCNodeSet &SCCNodes, } } +/// Deduce noundef attributes for the SCC. +static void addNoUndefAttrs(const SCCNodeSet &SCCNodes, + SmallSet<Function *, 8> &Changed) { + // Check each function in turn, determining which functions return noundef + // values. + for (Function *F : SCCNodes) { + // Already noundef. + if (F->getAttributes().hasRetAttr(Attribute::NoUndef)) + continue; + + // We can infer and propagate function attributes only when we know that the + // definition we'll get at link time is *exactly* the definition we see now. + // For more details, see GlobalValue::mayBeDerefined. + if (!F->hasExactDefinition()) + return; + + if (F->getReturnType()->isVoidTy()) + continue; + + bool HasAnyUndefs = false; + for (BasicBlock &BB : *F) + if (auto *Ret = dyn_cast<ReturnInst>(BB.getTerminator())) { + // TODO: performs context-sensitive analysis? + if (!isGuaranteedNotToBeUndefOrPoison(Ret->getReturnValue())) { + HasAnyUndefs = true; + break; ---------------- nikic wrote:
Use `any_of` (or `none_of` or whatever is most convenient). https://github.com/llvm/llvm-project/pull/76553 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits