Skip to content

Commit 2d287f5

Browse files
[llvm] Use *(Set|Map)::contains (NFC) (#138431)
1 parent f7b2c9a commit 2d287f5

9 files changed

+12
-15
lines changed

llvm/lib/Support/Mustache.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,7 @@ void ASTNode::render(const json::Value &Data, raw_ostream &OS) {
619619
return;
620620
}
621621
case InvertSection: {
622-
bool IsLambda =
623-
SectionLambdas.find(AccessorValue[0]) != SectionLambdas.end();
622+
bool IsLambda = SectionLambdas.contains(AccessorValue[0]);
624623
if (!isFalsey(Context) || IsLambda)
625624
return;
626625
renderChild(Context, OS);

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3798,7 +3798,7 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
37983798
return false;
37993799
for (auto &[S, U, L] : ScalarUserAndIdx) {
38003800
for (auto *U : S->users()) {
3801-
if (UserToExtractIdx.find(U) != UserToExtractIdx.end()) {
3801+
if (UserToExtractIdx.contains(U)) {
38023802
auto *FMul = cast<BinaryOperator>(U);
38033803
auto *Op0 = FMul->getOperand(0);
38043804
auto *Op1 = FMul->getOperand(1);

llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ class AMDGPULowerModuleLDS {
10161016
auto NewGV = uniquifyGVPerKernel(M, GV, F);
10171017
Changed |= (NewGV != GV);
10181018
int BarId = (NumAbsolutes + 1);
1019-
if (Kernel2BarId.find(F) != Kernel2BarId.end()) {
1019+
if (Kernel2BarId.contains(F)) {
10201020
BarId = (Kernel2BarId[F] + 1);
10211021
}
10221022
Kernel2BarId[F] = BarId;

llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ bool AMDGPUSwLowerLDS::run() {
12561256
}
12571257
for (Function *Func : FuncLDSAccessInfo.NonKernelsWithLDSArgument) {
12581258
auto &K = FuncLDSAccessInfo.NonKernelToLDSAccessMap;
1259-
if (K.find(Func) != K.end())
1259+
if (K.contains(Func))
12601260
continue;
12611261
SetVector<llvm::GlobalVariable *> Vec;
12621262
lowerNonKernelLDSAccesses(Func, Vec, NKLDSParams);

llvm/lib/Target/AMDGPU/GCNSchedStrategy.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ class RegionPressureMap {
208208

209209
// Retrieve the LiveReg for a given RegionIdx
210210
GCNRPTracker::LiveRegSet &getLiveRegsForRegionIdx(unsigned RegionIdx) {
211-
assert(IdxToInstruction.find(RegionIdx) != IdxToInstruction.end());
211+
assert(IdxToInstruction.contains(RegionIdx));
212212
MachineInstr *Key = IdxToInstruction[RegionIdx];
213213
return RegionLiveRegMap[Key];
214214
}

llvm/lib/Target/Hexagon/HexagonOptAddrMode.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ bool HexagonOptAddrMode::processAddBases(NodeAddr<StmtNode *> AddSN,
533533
[](const MachineInstr *MI,
534534
const DenseSet<MachineInstr *> &ProcessedAddiInsts) -> bool {
535535
// If we've already processed this Addi, just return
536-
if (ProcessedAddiInsts.find(MI) != ProcessedAddiInsts.end()) {
536+
if (ProcessedAddiInsts.contains(MI)) {
537537
LLVM_DEBUG(dbgs() << "\t\t\tAddi already found in ProcessedAddiInsts: "
538538
<< *MI << "\n\t\t\tSkipping...");
539539
return true;

llvm/lib/Target/SPIRV/SPIRVIRMapping.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class SPIRVIRMapping {
216216
erase(MI);
217217
return nullptr;
218218
}
219-
assert(Defs.find(MI) != Defs.end() && Defs.find(MI)->second == HandleMF);
219+
assert(Defs.contains(MI) && Defs.find(MI)->second == HandleMF);
220220
return MI;
221221
}
222222
Register find(SPIRV::IRHandle Handle, const MachineFunction *MF) {

llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,7 @@ class ValueToShadowMap {
439439

440440
// Returns true if the value already has a shadow (including if the value is a
441441
// constant). If true, calling getShadow() is valid.
442-
bool hasShadow(Value *V) const {
443-
return isa<Constant>(V) || (Map.find(V) != Map.end());
444-
}
442+
bool hasShadow(Value *V) const { return isa<Constant>(V) || Map.contains(V); }
445443

446444
// Returns the shadow value for a given value. Asserts that the value has
447445
// a shadow value. Lazily creates shadows for constant values.

llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ class LowerMatrixIntrinsics {
10361036
for (Instruction &I : *BB) {
10371037
if (match(&I, m_Intrinsic<Intrinsic::lifetime_end>()))
10381038
LifetimeEnds.push_back(cast<IntrinsicInst>(&I));
1039-
if (ShapeMap.find(&I) == ShapeMap.end())
1039+
if (!ShapeMap.contains(&I))
10401040
continue;
10411041
if (match(&I, m_Intrinsic<Intrinsic::matrix_multiply>()))
10421042
MaybeFusableInsts.push_back(cast<CallInst>(&I));
@@ -1354,7 +1354,7 @@ class LowerMatrixIntrinsics {
13541354
ToRemove.push_back(Inst);
13551355
Value *Flattened = nullptr;
13561356
for (Use &U : llvm::make_early_inc_range(Inst->uses())) {
1357-
if (ShapeMap.find(U.getUser()) == ShapeMap.end()) {
1357+
if (!ShapeMap.contains(U.getUser())) {
13581358
if (!Flattened)
13591359
Flattened = Matrix.embedInVector(Builder);
13601360
U.set(Flattened);
@@ -1401,7 +1401,7 @@ class LowerMatrixIntrinsics {
14011401
// the returned cost is < 0, the argument is cheaper to use in the
14021402
// dot-product lowering.
14031403
auto GetCostForArg = [this, &CanBeFlattened](Value *Op, unsigned N) {
1404-
if (ShapeMap.find(Op) == ShapeMap.end())
1404+
if (!ShapeMap.contains(Op))
14051405
return InstructionCost::getInvalid();
14061406

14071407
if (!isa<Instruction>(Op))
@@ -1420,7 +1420,7 @@ class LowerMatrixIntrinsics {
14201420
return EmbedCost;
14211421
}
14221422

1423-
if (match(Op, m_BinOp()) && ShapeMap.find(Op) != ShapeMap.end()) {
1423+
if (match(Op, m_BinOp()) && ShapeMap.contains(Op)) {
14241424
InstructionCost OriginalCost =
14251425
TTI.getArithmeticInstrCost(cast<Instruction>(Op)->getOpcode(),
14261426
EltTy) *

0 commit comments

Comments
 (0)