[llvm] [LiveRegUnits] Enhanced the register liveness check (PR #66061)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 06:21:40 PDT 2023


================
@@ -112,13 +112,13 @@ class LiveRegUnits {
   /// The regmask has the same format as the one in the RegMask machine operand.
   void addRegsInMask(const uint32_t *RegMask);
 
-  /// Returns true if no part of physical register \p Reg is live.
-  bool available(MCPhysReg Reg) const {
-    for (MCRegUnit Unit : TRI->regunits(Reg)) {
-      if (Units.test(Unit))
-        return false;
-    }
-    return true;
+  /// Returns true if no part of physical register \p Reg is live or reserved.
+  bool available(const MachineRegisterInfo &MRI, MCPhysReg Reg) const;
+
+  /// Returns true if any part of physical register \p Reg is live
+  bool contains(MCPhysReg Reg) const {
+    return llvm::any_of(TRI->regunits(Reg),
+                        [&](MCRegUnit Unit) { return Units.test(Unit); });
----------------
arsenm wrote:

I think this just needs to capture this

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


More information about the llvm-commits mailing list