[llvm] d41f6cf - [CodeGen] Skip null physical register in AntiDepBreaker (NFCI)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 24 02:58:53 PDT 2023
Author: Sergei Barannikov
Date: 2023-05-24T12:58:29+03:00
New Revision: d41f6cff030369d99ad62bbdba732552c08d48a6
URL: https://github.com/llvm/llvm-project/commit/d41f6cff030369d99ad62bbdba732552c08d48a6
DIFF: https://github.com/llvm/llvm-project/commit/d41f6cff030369d99ad62bbdba732552c08d48a6.diff
LOG: [CodeGen] Skip null physical register in AntiDepBreaker (NFCI)
D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.
The only place where the assertion is currently triggering is in
CriticalAntiDepBreaker::ScanInstruction. Other places are changed
in case new assertions are added and should be harmless otherwise.
Differential Revision: https://reviews.llvm.org/D151288
Added:
Modified:
llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp b/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
index c9c437282b85..3c24e81b935c 100644
--- a/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
+++ b/llvm/lib/CodeGen/AggressiveAntiDepBreaker.cpp
@@ -200,7 +200,7 @@ void AggressiveAntiDepBreaker::Observe(MachineInstr &MI, unsigned Count,
LLVM_DEBUG(dbgs() << "\tRegs:");
std::vector<unsigned> &DefIndices = State->GetDefIndices();
- for (unsigned Reg = 0; Reg != TRI->getNumRegs(); ++Reg) {
+ for (unsigned Reg = 1; Reg != TRI->getNumRegs(); ++Reg) {
// If Reg is current live, then mark that it can't be renamed as
// we don't know the extent of its live-range anymore (now that it
// has been scheduled). If it is not live but was defined in the
@@ -776,7 +776,7 @@ unsigned AggressiveAntiDepBreaker::BreakAntiDependencies(
#ifndef NDEBUG
LLVM_DEBUG(dbgs() << "\n===== Aggressive anti-dependency breaking\n");
LLVM_DEBUG(dbgs() << "Available regs:");
- for (unsigned Reg = 0; Reg < TRI->getNumRegs(); ++Reg) {
+ for (unsigned Reg = 1; Reg < TRI->getNumRegs(); ++Reg) {
if (!State->IsLive(Reg))
LLVM_DEBUG(dbgs() << " " << printReg(Reg, TRI));
}
diff --git a/llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp b/llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp
index 88f42d8dfd5d..106db7c51f27 100644
--- a/llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp
+++ b/llvm/lib/CodeGen/CriticalAntiDepBreaker.cpp
@@ -49,7 +49,7 @@ CriticalAntiDepBreaker::~CriticalAntiDepBreaker() = default;
void CriticalAntiDepBreaker::StartBlock(MachineBasicBlock *BB) {
const unsigned BBSize = BB->size();
- for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i) {
+ for (unsigned i = 1, e = TRI->getNumRegs(); i != e; ++i) {
// Clear out the register class data.
Classes[i] = nullptr;
@@ -111,7 +111,7 @@ void CriticalAntiDepBreaker::Observe(MachineInstr &MI, unsigned Count,
return;
assert(Count < InsertPosIndex && "Instruction index out of expected range!");
- for (unsigned Reg = 0; Reg != TRI->getNumRegs(); ++Reg) {
+ for (unsigned Reg = 1; Reg != TRI->getNumRegs(); ++Reg) {
if (KillIndices[Reg] != ~0u) {
// If Reg is currently live, then mark that it can't be renamed as
// we don't know the extent of its live-range anymore (now that it
@@ -265,7 +265,7 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr &MI, unsigned Count) {
[&](MCPhysReg SR) { return MO.clobbersPhysReg(SR); });
};
- for (unsigned i = 0, e = TRI->getNumRegs(); i != e; ++i) {
+ for (unsigned i = 1, e = TRI->getNumRegs(); i != e; ++i) {
if (ClobbersPhysRegAndSubRegs(i)) {
DefIndices[i] = Count;
KillIndices[i] = ~0u;
@@ -463,7 +463,7 @@ BreakAntiDependencies(const std::vector<SUnit> &SUnits,
LLVM_DEBUG(dbgs() << "Critical path has total latency "
<< (Max->getDepth() + Max->Latency) << "\n");
LLVM_DEBUG(dbgs() << "Available regs:");
- for (unsigned Reg = 0; Reg < TRI->getNumRegs(); ++Reg) {
+ for (unsigned Reg = 1; Reg < TRI->getNumRegs(); ++Reg) {
if (KillIndices[Reg] == ~0u)
LLVM_DEBUG(dbgs() << " " << printReg(Reg, TRI));
}
More information about the llvm-commits
mailing list