Skip to content

Commit a84983c

Browse files
committed
NFC: Move check for artificial regunit to MachineRegisterInfo
1 parent 64bf6e4 commit a84983c

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

llvm/include/llvm/CodeGen/MachineRegisterInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,12 @@ class MachineRegisterInfo {
980980
/// expected.
981981
bool isReservedRegUnit(unsigned Unit) const;
982982

983+
/// Returns true when the given register unit is considered artificial.
984+
///
985+
/// Register units are considered artificial when at least one of the
986+
/// root registers is artificial.
987+
bool isArtificialRegUnit(unsigned Unit) const;
988+
983989
/// isAllocatable - Returns true when PhysReg belongs to an allocatable
984990
/// register class and it hasn't been reserved.
985991
///

llvm/lib/CodeGen/LiveIntervals.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,12 +734,8 @@ void LiveIntervals::addKillFlags(const VirtRegMap *VRM) {
734734
for (MCRegUnitMaskIterator UI(PhysReg, TRI); UI.isValid(); ++UI) {
735735
auto [Unit, Bitmask] = *UI;
736736
// Record lane mask for all artificial RegUnits for this physreg.
737-
for (MCRegUnitRootIterator Root(Unit, TRI); Root.isValid(); ++Root) {
738-
if (TRI->isArtificial(*Root)) {
739-
ArtificialLanes |= Bitmask;
740-
break;
741-
}
742-
}
737+
if (MRI->isArtificialRegUnit(Unit))
738+
ArtificialLanes |= Bitmask;
743739
const LiveRange &RURange = getRegUnit(Unit);
744740
if (RURange.empty())
745741
continue;

llvm/lib/CodeGen/MachineRegisterInfo.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,3 +659,11 @@ bool MachineRegisterInfo::isReservedRegUnit(unsigned Unit) const {
659659
}
660660
return false;
661661
}
662+
663+
bool MachineRegisterInfo::isArtificialRegUnit(unsigned Unit) const {
664+
const TargetRegisterInfo *TRI = getTargetRegisterInfo();
665+
for (MCRegUnitRootIterator Root(Unit, TRI); Root.isValid(); ++Root)
666+
if (TRI->isArtificial(*Root))
667+
return true;
668+
return false;
669+
}

0 commit comments

Comments
 (0)