Skip to content

[llvm] Use *(Set|Map)::contains (NFC) #138431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions llvm/lib/Support/Mustache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,7 @@ void ASTNode::render(const json::Value &Data, raw_ostream &OS) {
return;
}
case InvertSection: {
bool IsLambda =
SectionLambdas.find(AccessorValue[0]) != SectionLambdas.end();
bool IsLambda = SectionLambdas.contains(AccessorValue[0]);
if (!isFalsey(Context) || IsLambda)
return;
renderChild(Context, OS);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3798,7 +3798,7 @@ InstructionCost AArch64TTIImpl::getVectorInstrCostHelper(
return false;
for (auto &[S, U, L] : ScalarUserAndIdx) {
for (auto *U : S->users()) {
if (UserToExtractIdx.find(U) != UserToExtractIdx.end()) {
if (UserToExtractIdx.contains(U)) {
auto *FMul = cast<BinaryOperator>(U);
auto *Op0 = FMul->getOperand(0);
auto *Op1 = FMul->getOperand(1);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ class AMDGPULowerModuleLDS {
auto NewGV = uniquifyGVPerKernel(M, GV, F);
Changed |= (NewGV != GV);
int BarId = (NumAbsolutes + 1);
if (Kernel2BarId.find(F) != Kernel2BarId.end()) {
if (Kernel2BarId.contains(F)) {
BarId = (Kernel2BarId[F] + 1);
}
Kernel2BarId[F] = BarId;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,7 @@ bool AMDGPUSwLowerLDS::run() {
}
for (Function *Func : FuncLDSAccessInfo.NonKernelsWithLDSArgument) {
auto &K = FuncLDSAccessInfo.NonKernelToLDSAccessMap;
if (K.find(Func) != K.end())
if (K.contains(Func))
continue;
SetVector<llvm::GlobalVariable *> Vec;
lowerNonKernelLDSAccesses(Func, Vec, NKLDSParams);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/GCNSchedStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class RegionPressureMap {

// Retrieve the LiveReg for a given RegionIdx
GCNRPTracker::LiveRegSet &getLiveRegsForRegionIdx(unsigned RegionIdx) {
assert(IdxToInstruction.find(RegionIdx) != IdxToInstruction.end());
assert(IdxToInstruction.contains(RegionIdx));
MachineInstr *Key = IdxToInstruction[RegionIdx];
return RegionLiveRegMap[Key];
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonOptAddrMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ bool HexagonOptAddrMode::processAddBases(NodeAddr<StmtNode *> AddSN,
[](const MachineInstr *MI,
const DenseSet<MachineInstr *> &ProcessedAddiInsts) -> bool {
// If we've already processed this Addi, just return
if (ProcessedAddiInsts.find(MI) != ProcessedAddiInsts.end()) {
if (ProcessedAddiInsts.contains(MI)) {
LLVM_DEBUG(dbgs() << "\t\t\tAddi already found in ProcessedAddiInsts: "
<< *MI << "\n\t\t\tSkipping...");
return true;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/SPIRV/SPIRVIRMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class SPIRVIRMapping {
erase(MI);
return nullptr;
}
assert(Defs.find(MI) != Defs.end() && Defs.find(MI)->second == HandleMF);
assert(Defs.contains(MI) && Defs.find(MI)->second == HandleMF);
return MI;
}
Register find(SPIRV::IRHandle Handle, const MachineFunction *MF) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,7 @@ class ValueToShadowMap {

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

// Returns the shadow value for a given value. Asserts that the value has
// a shadow value. Lazily creates shadows for constant values.
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ class LowerMatrixIntrinsics {
for (Instruction &I : *BB) {
if (match(&I, m_Intrinsic<Intrinsic::lifetime_end>()))
LifetimeEnds.push_back(cast<IntrinsicInst>(&I));
if (ShapeMap.find(&I) == ShapeMap.end())
if (!ShapeMap.contains(&I))
continue;
if (match(&I, m_Intrinsic<Intrinsic::matrix_multiply>()))
MaybeFusableInsts.push_back(cast<CallInst>(&I));
Expand Down Expand Up @@ -1354,7 +1354,7 @@ class LowerMatrixIntrinsics {
ToRemove.push_back(Inst);
Value *Flattened = nullptr;
for (Use &U : llvm::make_early_inc_range(Inst->uses())) {
if (ShapeMap.find(U.getUser()) == ShapeMap.end()) {
if (!ShapeMap.contains(U.getUser())) {
if (!Flattened)
Flattened = Matrix.embedInVector(Builder);
U.set(Flattened);
Expand Down Expand Up @@ -1401,7 +1401,7 @@ class LowerMatrixIntrinsics {
// the returned cost is < 0, the argument is cheaper to use in the
// dot-product lowering.
auto GetCostForArg = [this, &CanBeFlattened](Value *Op, unsigned N) {
if (ShapeMap.find(Op) == ShapeMap.end())
if (!ShapeMap.contains(Op))
return InstructionCost::getInvalid();

if (!isa<Instruction>(Op))
Expand All @@ -1420,7 +1420,7 @@ class LowerMatrixIntrinsics {
return EmbedCost;
}

if (match(Op, m_BinOp()) && ShapeMap.find(Op) != ShapeMap.end()) {
if (match(Op, m_BinOp()) && ShapeMap.contains(Op)) {
InstructionCost OriginalCost =
TTI.getArithmeticInstrCost(cast<Instruction>(Op)->getOpcode(),
EltTy) *
Expand Down
Loading