This patch migrates the TTI cost interfaces to return an InstructionCost.
See this patch for the introduction of the type: https://reviews.llvm.org/D91174
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2020-November/146408.html
I can see that TargetTransformInfo::getScalingFactorCost already performs the >=0 test and so I'm wondering if at this point you only need to assert the costs are valid?