Skip to content

[CodeGen] Remove atEnd method from defusechain iterators #120610

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

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions llvm/include/llvm/CodeGen/MachineRegisterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down Expand Up @@ -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!");
Expand Down
8 changes: 5 additions & 3 deletions llvm/lib/CodeGen/MachineRegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/CodeGen/MachineTraceMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
};

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SwiftErrorValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading