[llvm] 437f960 - [llvm] Call *set::insert without checking membership first (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 18 10:22:12 PDT 2022
Author: Kazu Hirata
Date: 2022-06-18T10:22:05-07:00
New Revision: 437f960062e37d3ad656b97bd9a87a148093adbc
URL: https://github.com/llvm/llvm-project/commit/437f960062e37d3ad656b97bd9a87a148093adbc
DIFF: https://github.com/llvm/llvm-project/commit/437f960062e37d3ad656b97bd9a87a148093adbc.diff
LOG: [llvm] Call *set::insert without checking membership first (NFC)
Added:
Modified:
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
llvm/lib/Target/ARM/A15SDOptimizer.cpp
llvm/lib/Target/BPF/BPFMIPeephole.cpp
llvm/lib/Target/BPF/BTFDebug.cpp
llvm/utils/TableGen/DirectiveEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 8de7fae1c789b..db77b0eb3dc17 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -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;
diff --git a/llvm/lib/Target/ARM/A15SDOptimizer.cpp b/llvm/lib/Target/ARM/A15SDOptimizer.cpp
index d0efecad63bc5..65da95b0fc8de 100644
--- a/llvm/lib/Target/ARM/A15SDOptimizer.cpp
+++ b/llvm/lib/Target/ARM/A15SDOptimizer.cpp
@@ -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();
diff --git a/llvm/lib/Target/BPF/BPFMIPeephole.cpp b/llvm/lib/Target/BPF/BPFMIPeephole.cpp
index 9c2442fd766d9..cefbe48b72174 100644
--- a/llvm/lib/Target/BPF/BPFMIPeephole.cpp
+++ b/llvm/lib/Target/BPF/BPFMIPeephole.cpp
@@ -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) {
diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp
index d206c06fe2895..a949e925eb600 100644
--- a/llvm/lib/Target/BPF/BTFDebug.cpp
+++ b/llvm/lib/Target/BPF/BTFDebug.cpp
@@ -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;
diff --git a/llvm/utils/TableGen/DirectiveEmitter.cpp b/llvm/utils/TableGen/DirectiveEmitter.cpp
index 76a9b549eb2c3..f3751591f3d95 100644
--- a/llvm/utils/TableGen/DirectiveEmitter.cpp
+++ b/llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -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()
More information about the llvm-commits
mailing list