================ @@ -354,6 +354,36 @@ bool SCCPSolver::removeNonFeasibleEdges(BasicBlock *BB, DomTreeUpdater &DTU, return true; } +void SCCPSolver::inferReturnAttributes() const { + for (const auto &I : getTrackedRetVals()) { + Function *F = I.first; + const ValueLatticeElement &ReturnValue = I.second; + + // If there is a known constant range for the return value, add range + // attribute to the return value. + if (ReturnValue.isConstantRange() && + !ReturnValue.getConstantRange().isSingleElement()) { + // Do not add range metadata if the return value may include undef. ---------------- nikic wrote:
> I don't see any tests for this. This is pre-existing code moved to a different place. > Is the reason for this to avoid creating UB where we where just propagating > poison beforehand? If so, do you also need noundef for propagating nonnull? `ConstantRangeIncludingUndef` means `ConstantRange|undef`. In the `undef` case any value may be picked, so the result is a full range. https://github.com/llvm/llvm-project/pull/106732 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits