[llvm] [SLSR] Skipping rewriting based on liveness (PR #218470)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 2 04:25:39 PDT 2026
================
@@ -1359,6 +1359,20 @@ class TargetTransformInfo {
/// \return the number of registers in the target-provided register class.
LLVM_ABI unsigned getNumberOfRegisters(unsigned ClassID) const;
+ /// \return A conservative bound on the number of registers \p F can use
+ /// before the register allocator is likely to spill, or std::nullopt if the
+ /// target has no meaningful bound to report.
+ ///
+ /// The budget is a property of the function, not only of the subtarget: it
+ /// may depend on attributes that constrain how many registers the function
+ /// is permitted to use. So two functions in the same module can have
+ /// different budgets.
+ ///
+ /// It is intended for heuristics deciding whether a
+ /// transform is about to make register pressure a problem, and staying below.
+ /// Not a guarantee that no spilling occurs.
+ LLVM_ABI std::optional<unsigned> getRegisterBudget(const Function &F) const;
----------------
arsenm wrote:
The raw number of the registers isn't that useful to the IR. You would need to account for the type legalization cost to get an actual physical register count. I think the existing getNumberOfRegisters hook probably shouldn't be here either. TTI has several other poorly considered register budget hooks which really should be consolidated, rather than add another one to the collection
https://github.com/llvm/llvm-project/pull/218470
More information about the llvm-commits
mailing list