[llvm] [RegisterScavenging] Respect early-clobber when scavenging registers (PR #184814)

Dominik Steenken via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 06:41:59 PDT 2026


================
@@ -140,10 +140,14 @@ class RegScavenger {
   ///
   /// If \p AllowSpill is false, fail if a spill is required to make the
   /// register available, and return NoRegister.
+  /// If \p InspectNext is true, inspect the instruction at MBBI
+  /// for early-clobber def regs that need to be excluded from the set
+  /// of valid registers.
   Register scavengeRegisterBackwards(const TargetRegisterClass &RC,
                                      MachineBasicBlock::iterator To,
                                      bool RestoreAfter, int SPAdj,
-                                     bool AllowSpill = true);
+                                     bool AllowSpill = true,
+                                     bool InspectNext = false);
----------------
dominik-steenken wrote:

Maybe i am misunderstanding - If i pass `std::next(DefMI.getIterator())` in `RegisterScavenging.cpp:413`, I'd be excluding the defining MI from consideration, while fully including the using MI, even though i only want its early-clobber def reg to be considered?

https://github.com/llvm/llvm-project/pull/184814


More information about the llvm-commits mailing list