[llvm] [MachineCP] Correctly handle register masks and sub-registers (PR #122734)

Kai Luo via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 05:24:25 PST 2025


================
@@ -117,7 +117,32 @@ class CopyTracker {
 
   DenseMap<MCRegUnit, CopyInfo> Copies;
 
+  // Memoised sets of register units which are preserved by each register mask,
+  // needed to efficiently remove copies which are invalidated by call
+  // instructions.
+  DenseMap<const uint32_t *, BitVector> RegMaskToPreservedRegUnits;
+
 public:
+  /// Get the set of register units which are preserved by RegMaskOp.
+  BitVector &getPreservedRegUnits(const MachineOperand &RegMaskOp,
----------------
bzEq wrote:

>  The alternative would be to switch this whole pass over to LiveRegUnits

Yeah, that's the direction we wanna take, so that Matt's concern in https://github.com/llvm/llvm-project/pull/122472#discussion_r1913461141 can be addressed too.

>  but that would be a lot of work, and I don't think it would be enough anyway because this pass tracks more than just liveness.

That's ok for now.

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


More information about the llvm-commits mailing list