-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AMDGPU] Delete some dead code (NFC) #167891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-backend-amdgpu Author: Sergei Barannikov (s-barannikov) ChangesThis synchronizes the copy & paste with recent changes to RPTracker. Full diff: https://github.com/llvm/llvm-project/pull/167891.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
index 0c5e3d0837800..43a35a54912d2 100644
--- a/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
@@ -313,11 +313,11 @@ collectVirtualRegUses(SmallVectorImpl<VRegMaskOrUnit> &VRegMaskOrUnits,
/// Mostly copy/paste from CodeGen/RegisterPressure.cpp
static LaneBitmask getLanesWithProperty(
const LiveIntervals &LIS, const MachineRegisterInfo &MRI,
- bool TrackLaneMasks, Register RegUnit, SlotIndex Pos,
+ bool TrackLaneMasks, VirtRegOrUnit VRegOrUnit, SlotIndex Pos,
LaneBitmask SafeDefault,
function_ref<bool(const LiveRange &LR, SlotIndex Pos)> Property) {
- if (RegUnit.isVirtual()) {
- const LiveInterval &LI = LIS.getInterval(RegUnit);
+ if (VRegOrUnit.isVirtualReg()) {
+ const LiveInterval &LI = LIS.getInterval(VRegOrUnit.asVirtualReg());
LaneBitmask Result;
if (TrackLaneMasks && LI.hasSubRanges()) {
for (const LiveInterval::SubRange &SR : LI.subranges()) {
@@ -325,14 +325,15 @@ static LaneBitmask getLanesWithProperty(
Result |= SR.LaneMask;
}
} else if (Property(LI, Pos)) {
- Result = TrackLaneMasks ? MRI.getMaxLaneMaskForVReg(RegUnit)
+ Result = TrackLaneMasks
+ ? MRI.getMaxLaneMaskForVReg(VRegOrUnit.asVirtualReg())
: LaneBitmask::getAll();
}
return Result;
}
- const LiveRange *LR = LIS.getCachedRegUnit(RegUnit);
+ const LiveRange *LR = LIS.getCachedRegUnit(VRegOrUnit.asMCRegUnit());
if (LR == nullptr)
return SafeDefault;
return Property(*LR, Pos) ? LaneBitmask::getAll() : LaneBitmask::getNone();
@@ -503,10 +504,10 @@ void GCNRPTracker::reset(const MachineRegisterInfo &MRI_,
}
/// Mostly copy/paste from CodeGen/RegisterPressure.cpp
-LaneBitmask GCNRPTracker::getLastUsedLanes(Register RegUnit,
+LaneBitmask GCNRPTracker::getLastUsedLanes(VirtRegOrUnit VRegOrUnit,
SlotIndex Pos) const {
return getLanesWithProperty(
- LIS, *MRI, true, RegUnit, Pos.getBaseIndex(), LaneBitmask::getNone(),
+ LIS, *MRI, true, VRegOrUnit, Pos.getBaseIndex(), LaneBitmask::getNone(),
[](const LiveRange &LR, SlotIndex Pos) {
const LiveRange::Segment *S = LR.getSegmentContaining(Pos);
return S != nullptr && S->end == Pos.getRegSlot();
@@ -752,7 +753,7 @@ GCNDownwardRPTracker::bumpDownwardPressure(const MachineInstr *MI,
if (!Use.VRegOrUnit.isVirtualReg())
continue;
Register Reg = Use.VRegOrUnit.asVirtualReg();
- LaneBitmask LastUseMask = getLastUsedLanes(Reg, SlotIdx);
+ LaneBitmask LastUseMask = getLastUsedLanes(Use.VRegOrUnit, SlotIdx);
if (LastUseMask.none())
continue;
// The LastUseMask is queried from the liveness information of instruction
diff --git a/llvm/lib/Target/AMDGPU/GCNRegPressure.h b/llvm/lib/Target/AMDGPU/GCNRegPressure.h
index 4b22c68ef01c5..ea0e2bdcb7122 100644
--- a/llvm/lib/Target/AMDGPU/GCNRegPressure.h
+++ b/llvm/lib/Target/AMDGPU/GCNRegPressure.h
@@ -292,7 +292,7 @@ class GCNRPTracker {
/// Mostly copy/paste from CodeGen/RegisterPressure.cpp
void bumpDeadDefs(ArrayRef<VRegMaskOrUnit> DeadDefs);
- LaneBitmask getLastUsedLanes(Register RegUnit, SlotIndex Pos) const;
+ LaneBitmask getLastUsedLanes(VirtRegOrUnit VRegOrUnit, SlotIndex Pos) const;
public:
// reset tracker and set live register set to the specified value.
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
| } | ||
|
|
||
| const LiveRange *LR = LIS.getCachedRegUnit(RegUnit); | ||
| const LiveRange *LR = LIS.getCachedRegUnit(VRegOrUnit.asMCRegUnit()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually dead code because getLastUsedLanes is called only when VRegOrUnit.isVirtualReg() below returns true. Not sure what is best: keep the copy synchronized with the source or delete the dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably delete dead code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done
This synchronizes the copy & paste with recent changes to RPTracker.
37ed793 to
c275dd0
Compare
arsenm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a bug but ok
|
FWIW The original function can be called with MCRegUnit; AMDGPU version is only called with virtual registers. |
getLanesWithProperty()is called with virtual registers only.