[llvm] Call *(Set|Map)::erase directly (NFC)

We can erase an item in a set or map without checking its membership
first.
This commit is contained in:
Kazu Hirata 2021-10-24 09:32:59 -07:00
parent 7cc8fa2dd2
commit 1c35973c77
2 changed files with 3 additions and 7 deletions

View File

@ -1525,8 +1525,7 @@ void VarLocBasedLDV::transferRegisterDef(MachineInstr &MI,
for (MCRegAliasIterator RAI(MO.getReg(), TRI, true); RAI.isValid(); ++RAI) for (MCRegAliasIterator RAI(MO.getReg(), TRI, true); RAI.isValid(); ++RAI)
// FIXME: Can we break out of this loop early if no insertion occurs? // FIXME: Can we break out of this loop early if no insertion occurs?
DeadRegs.insert(*RAI); DeadRegs.insert(*RAI);
if (RegSetInstrs.find(MO.getReg()) != RegSetInstrs.end()) RegSetInstrs.erase(MO.getReg());
RegSetInstrs.erase(MO.getReg());
RegSetInstrs.insert({MO.getReg(), &MI}); RegSetInstrs.insert({MO.getReg(), &MI});
} else if (MO.isRegMask()) { } else if (MO.isRegMask()) {
RegMasks.push_back(MO.getRegMask()); RegMasks.push_back(MO.getRegMask());
@ -1555,8 +1554,7 @@ void VarLocBasedLDV::transferRegisterDef(MachineInstr &MI,
if (AnyRegMaskKillsReg) if (AnyRegMaskKillsReg)
DeadRegs.insert(Reg); DeadRegs.insert(Reg);
if (AnyRegMaskKillsReg) { if (AnyRegMaskKillsReg) {
if (RegSetInstrs.find(Reg) != RegSetInstrs.end()) RegSetInstrs.erase(Reg);
RegSetInstrs.erase(Reg);
RegSetInstrs.insert({Reg, &MI}); RegSetInstrs.insert({Reg, &MI});
} }
} }

View File

@ -1599,9 +1599,7 @@ AttrBuilder &AttrBuilder::removeAttributes(AttributeList A, uint64_t Index) {
} }
AttrBuilder &AttrBuilder::removeAttribute(StringRef A) { AttrBuilder &AttrBuilder::removeAttribute(StringRef A) {
auto I = TargetDepAttrs.find(A); TargetDepAttrs.erase(A);
if (I != TargetDepAttrs.end())
TargetDepAttrs.erase(I);
return *this; return *this;
} }