[llvm] 1849244 - [CodeGen] Remove atEnd method from defusechain iterators (#120610)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 09:29:59 PST 2025
Author: Jay Foad
Date: 2025-01-02T17:29:55Z
New Revision: 1849244685bc42b07b1b14e3f62e15c535e74c39
URL: https://github.com/llvm/llvm-project/commit/1849244685bc42b07b1b14e3f62e15c535e74c39
DIFF: https://github.com/llvm/llvm-project/commit/1849244685bc42b07b1b14e3f62e15c535e74c39.diff
LOG: [CodeGen] Remove atEnd method from defusechain iterators (#120610)
This was not used much and there are better ways of writing it.
Added:
Modified:
llvm/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/lib/CodeGen/MachineRegisterInfo.cpp
llvm/lib/CodeGen/MachineTraceMetrics.cpp
llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
index 5dc51aaed81c7b..5ee3aef28a4fb6 100644
--- a/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineRegisterInfo.h
@@ -1095,9 +1095,6 @@ class MachineRegisterInfo {
return !operator==(x);
}
- /// atEnd - return true if this iterator is equal to reg_end() on the value.
- bool atEnd() const { return Op == nullptr; }
-
// Iterator traversal: forward iteration only
defusechain_iterator &operator++() { // Preincrement
assert(Op && "Cannot increment end iterator!");
@@ -1203,9 +1200,6 @@ class MachineRegisterInfo {
return !operator==(x);
}
- /// atEnd - return true if this iterator is equal to reg_end() on the value.
- bool atEnd() const { return Op == nullptr; }
-
// Iterator traversal: forward iteration only
defusechain_instr_iterator &operator++() { // Preincrement
assert(Op && "Cannot increment end iterator!");
diff --git a/llvm/lib/CodeGen/MachineRegisterInfo.cpp b/llvm/lib/CodeGen/MachineRegisterInfo.cpp
index 6f636a161f5000..394b99b85ddcc5 100644
--- a/llvm/lib/CodeGen/MachineRegisterInfo.cpp
+++ b/llvm/lib/CodeGen/MachineRegisterInfo.cpp
@@ -407,9 +407,11 @@ void MachineRegisterInfo::replaceRegWith(Register FromReg, Register ToReg) {
MachineInstr *MachineRegisterInfo::getVRegDef(Register Reg) const {
// Since we are in SSA form, we can use the first definition.
def_instr_iterator I = def_instr_begin(Reg);
- assert((I.atEnd() || std::next(I) == def_instr_end()) &&
- "getVRegDef assumes a single definition or no definition");
- return !I.atEnd() ? &*I : nullptr;
+ if (I == def_instr_end())
+ return nullptr;
+ assert(std::next(I) == def_instr_end() &&
+ "getVRegDef assumes at most one definition");
+ return &*I;
}
/// getUniqueVRegDef - Return the unique machine instr that defines the
diff --git a/llvm/lib/CodeGen/MachineTraceMetrics.cpp b/llvm/lib/CodeGen/MachineTraceMetrics.cpp
index 6576f97bea25f8..021c1a058c0204 100644
--- a/llvm/lib/CodeGen/MachineTraceMetrics.cpp
+++ b/llvm/lib/CodeGen/MachineTraceMetrics.cpp
@@ -683,11 +683,10 @@ struct DataDep {
DataDep(const MachineRegisterInfo *MRI, unsigned VirtReg, unsigned UseOp)
: UseOp(UseOp) {
assert(Register::isVirtualRegister(VirtReg));
- MachineRegisterInfo::def_iterator DefI = MRI->def_begin(VirtReg);
- assert(!DefI.atEnd() && "Register has no defs");
- DefMI = DefI->getParent();
- DefOp = DefI.getOperandNo();
- assert((++DefI).atEnd() && "Register has multiple defs");
+ MachineOperand *DefMO = MRI->getOneDef(VirtReg);
+ assert(DefMO && "Register does not have unique def");
+ DefMI = DefMO->getParent();
+ DefOp = DefMO->getOperandNo();
}
};
diff --git a/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp b/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
index 74a94d6110f418..decffdc7dfe45b 100644
--- a/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
+++ b/llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
@@ -259,7 +259,7 @@ void SwiftErrorValueTracking::propagateVRegs() {
for (const auto &Use : VRegUpwardsUse) {
const MachineBasicBlock *UseBB = Use.first.first;
Register VReg = Use.second;
- if (!MRI.def_begin(VReg).atEnd())
+ if (!MRI.def_empty(VReg))
continue;
#ifdef EXPENSIVE_CHECKS
More information about the llvm-commits
mailing list