[llvm] 1c35973 - [llvm] Call *(Set|Map)::erase directly (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 24 09:33:21 PDT 2021
Author: Kazu Hirata
Date: 2021-10-24T09:32:59-07:00
New Revision: 1c35973c772b0c5e9c82d0c5d57d218a3eb6417d
URL: https://github.com/llvm/llvm-project/commit/1c35973c772b0c5e9c82d0c5d57d218a3eb6417d
DIFF: https://github.com/llvm/llvm-project/commit/1c35973c772b0c5e9c82d0c5d57d218a3eb6417d.diff
LOG: [llvm] Call *(Set|Map)::erase directly (NFC)
We can erase an item in a set or map without checking its membership
first.
Added:
Modified:
llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
llvm/lib/IR/Attributes.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index 214f9040471f8..a632d3d9ce76b 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -1525,8 +1525,7 @@ void VarLocBasedLDV::transferRegisterDef(MachineInstr &MI,
for (MCRegAliasIterator RAI(MO.getReg(), TRI, true); RAI.isValid(); ++RAI)
// FIXME: Can we break out of this loop early if no insertion occurs?
DeadRegs.insert(*RAI);
- if (RegSetInstrs.find(MO.getReg()) != RegSetInstrs.end())
- RegSetInstrs.erase(MO.getReg());
+ RegSetInstrs.erase(MO.getReg());
RegSetInstrs.insert({MO.getReg(), &MI});
} else if (MO.isRegMask()) {
RegMasks.push_back(MO.getRegMask());
@@ -1555,8 +1554,7 @@ void VarLocBasedLDV::transferRegisterDef(MachineInstr &MI,
if (AnyRegMaskKillsReg)
DeadRegs.insert(Reg);
if (AnyRegMaskKillsReg) {
- if (RegSetInstrs.find(Reg) != RegSetInstrs.end())
- RegSetInstrs.erase(Reg);
+ RegSetInstrs.erase(Reg);
RegSetInstrs.insert({Reg, &MI});
}
}
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp
index e431dc8afb808..f81a446d6e46d 100644
--- a/llvm/lib/IR/Attributes.cpp
+++ b/llvm/lib/IR/Attributes.cpp
@@ -1599,9 +1599,7 @@ AttrBuilder &AttrBuilder::removeAttributes(AttributeList A, uint64_t Index) {
}
AttrBuilder &AttrBuilder::removeAttribute(StringRef A) {
- auto I = TargetDepAttrs.find(A);
- if (I != TargetDepAttrs.end())
- TargetDepAttrs.erase(I);
+ TargetDepAttrs.erase(A);
return *this;
}
More information about the llvm-commits
mailing list