[llvm] Call *set::insert without checking membership first (NFC)

This commit is contained in:
Kazu Hirata 2022-06-18 10:22:05 -07:00
parent 4271a1ff33
commit 437f960062
5 changed files with 6 additions and 12 deletions

View File

@ -4910,9 +4910,8 @@ bool AMDGPUAsmParser::ParseDirectiveAMDHSAKernel() {
if (ID == ".end_amdhsa_kernel")
break;
if (Seen.find(ID) != Seen.end())
if (!Seen.insert(ID).second)
return TokError(".amdhsa_ directives cannot be repeated");
Seen.insert(ID);
SMLoc ValStart = getLoc();
int64_t IVal;

View File

@ -361,9 +361,8 @@ void A15SDOptimizer::elideCopiesAndPHIs(MachineInstr *MI,
MI = Front.pop_back_val();
// If we have already explored this MachineInstr, ignore it.
if (Reached.find(MI) != Reached.end())
if (!Reached.insert(MI).second)
continue;
Reached.insert(MI);
if (MI->isPHI()) {
for (unsigned I = 1, E = MI->getNumOperands(); I != E; I += 2) {
Register Reg = MI->getOperand(I).getReg();

View File

@ -124,9 +124,8 @@ bool BPFMIPeephole::isPhiFrom32Def(MachineInstr *PhiMI)
if (!PhiDef)
return false;
if (PhiDef->isPHI()) {
if (PhiInsns.find(PhiDef) != PhiInsns.end())
if (!PhiInsns.insert(PhiDef).second)
return false;
PhiInsns.insert(PhiDef);
if (!isPhiFrom32Def(PhiDef))
return false;
}
@ -144,9 +143,8 @@ bool BPFMIPeephole::isInsnFrom32Def(MachineInstr *DefInsn)
return false;
if (DefInsn->isPHI()) {
if (PhiInsns.find(DefInsn) != PhiInsns.end())
if (!PhiInsns.insert(DefInsn).second)
return false;
PhiInsns.insert(DefInsn);
if (!isPhiFrom32Def(DefInsn))
return false;
} else if (DefInsn->getOpcode() == BPF::COPY) {

View File

@ -1526,9 +1526,8 @@ void BTFDebug::processFuncPrototypes(const Function *F) {
return;
// Do not emit again if already emitted.
if (ProtoFunctions.find(F) != ProtoFunctions.end())
if (!ProtoFunctions.insert(F).second)
return;
ProtoFunctions.insert(F);
uint32_t ProtoTypeId;
const std::unordered_map<uint32_t, StringRef> FuncArgNames;

View File

@ -367,8 +367,7 @@ void GenerateCaseForVersionedClauses(const std::vector<Record *> &Clauses,
const auto ClauseFormattedName = VerClause.getClause().getFormattedName();
if (Cases.find(ClauseFormattedName) == Cases.end()) {
Cases.insert(ClauseFormattedName);
if (Cases.insert(ClauseFormattedName).second) {
OS << " case " << DirLang.getClausePrefix() << ClauseFormattedName
<< ":\n";
OS << " return " << VerClause.getMinVersion()