diff options
| author | Sergei Barannikov <barannikov88@gmail.com> | 2025-11-16 20:46:44 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-16 20:46:44 +0300 |
| commit | 97a60aa37a048155fec0c560fc51ed52dbd84e44 (patch) | |
| tree | b43faa17886d900ca3a9426e78d4c385ad492aff /llvm/lib/CodeGen/MachineCopyPropagation.cpp | |
| parent | 6f3f1088df0d48c3f56f6eaec695868f9e239318 (diff) | |
[CodeGen] Turn MCRegUnit into an enum class (NFC) (#167943)
This changes `MCRegUnit` type from `unsigned` to `enum class : unsigned`
and inserts necessary casts.
The added `MCRegUnitToIndex` functor is used with `SparseSet`,
`SparseMultiSet` and `IndexedMap` in a few places.
`MCRegUnit` is opaque to users, so it didn't seem worth making it a
full-fledged class like `Register`.
Static type checking has detected one issue in
`PrologueEpilogueInserter.cpp`, where `BitVector` created for
`MCRegister` is indexed by both `MCRegister` and `MCRegUnit`.
The number of casts could be reduced by using `IndexedMap` in more
places and/or adding a `BitVector` adaptor, but the number of casts *per
file* is still small and `IndexedMap` has limitations, so it didn't seem
worth the effort.
Pull Request: https://github.com/llvm/llvm-project/pull/167943
Diffstat (limited to 'llvm/lib/CodeGen/MachineCopyPropagation.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/MachineCopyPropagation.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp index 5ec7c48d7ee6..2a344b40c30c 100644 --- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp +++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp @@ -138,7 +138,7 @@ public: for (unsigned SafeReg = 0, E = TRI.getNumRegs(); SafeReg < E; ++SafeReg) if (!RegMaskOp.clobbersPhysReg(SafeReg)) for (MCRegUnit SafeUnit : TRI.regunits(SafeReg)) - PreservedRegUnits.set(SafeUnit); + PreservedRegUnits.set(static_cast<unsigned>(SafeUnit)); return PreservedRegUnits; } @@ -996,7 +996,7 @@ void MachineCopyPropagation::ForwardCopyPropagateBlock(MachineBasicBlock &MBB) { // this register mask. bool MIRefedinCopyInfo = false; for (MCRegUnit RegUnit : TRI->regunits(Reg)) { - if (!PreservedRegUnits.test(RegUnit)) + if (!PreservedRegUnits.test(static_cast<unsigned>(RegUnit))) Tracker.clobberRegUnit(RegUnit, *TRI, *TII, UseCopyInstr); else { if (MaybeDead == Tracker.findCopyForUnit(RegUnit, *TRI)) { |
