diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp index f7f36901e4d49..45a5bdb48f01a 100644 --- a/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/PDBStringTableBuilder.cpp @@ -71,7 +71,7 @@ static uint32_t computeBucketCount(uint32_t NumStrings) { // This list contains all StringCount, BucketCount pairs where BucketCount was // just incremented. It ends before the first BucketCount entry where // BucketCount * 3 would overflow a 32-bit unsigned int. - static std::map StringsToBuckets = { + static const std::pair StringsToBuckets[] = { {0, 1}, {1, 2}, {2, 4}, @@ -124,8 +124,9 @@ static uint32_t computeBucketCount(uint32_t NumStrings) { {517197275, 1034394550}, {775795913, 1551591826}, {1163693870, 2327387740}}; - auto Entry = StringsToBuckets.lower_bound(NumStrings); - assert(Entry != StringsToBuckets.end()); + const auto *Entry = llvm::lower_bound( + StringsToBuckets, std::make_pair(NumStrings, 0U), llvm::less_first()); + assert(Entry != std::end(StringsToBuckets)); return Entry->second; } diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index d6a87526c5c38..51f17b37a8d6a 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -12799,12 +12799,15 @@ SDValue AArch64TargetLowering::LowerSVEStructLoad(unsigned Intrinsic, assert(VT.isScalableVector() && "Can only lower scalable vectors"); unsigned N, Opcode; - static std::map> IntrinsicMap = { - {Intrinsic::aarch64_sve_ld2, {2, AArch64ISD::SVE_LD2_MERGE_ZERO}}, - {Intrinsic::aarch64_sve_ld3, {3, AArch64ISD::SVE_LD3_MERGE_ZERO}}, - {Intrinsic::aarch64_sve_ld4, {4, AArch64ISD::SVE_LD4_MERGE_ZERO}}}; - - std::tie(N, Opcode) = IntrinsicMap[Intrinsic]; + static const std::pair> + IntrinsicMap[] = { + {Intrinsic::aarch64_sve_ld2, {2, AArch64ISD::SVE_LD2_MERGE_ZERO}}, + {Intrinsic::aarch64_sve_ld3, {3, AArch64ISD::SVE_LD3_MERGE_ZERO}}, + {Intrinsic::aarch64_sve_ld4, {4, AArch64ISD::SVE_LD4_MERGE_ZERO}}}; + + std::tie(N, Opcode) = llvm::find_if(IntrinsicMap, [&](auto P) { + return P.first == Intrinsic; + })->second; assert(VT.getVectorElementCount().getKnownMinValue() % N == 0 && "invalid tuple vector type!"); diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp index 991d6591682c2..accc281bc5527 100644 --- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp +++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp @@ -126,7 +126,7 @@ const uint32_t *RISCVRegisterInfo::getNoPreservedMask() const { // Frame indexes representing locations of CSRs which are given a fixed location // by save/restore libcalls. -static const std::map FixedCSRFIMap = { +static const std::pair FixedCSRFIMap[] = { {/*ra*/ RISCV::X1, -1}, {/*s0*/ RISCV::X8, -2}, {/*s1*/ RISCV::X9, -3}, @@ -149,8 +149,9 @@ bool RISCVRegisterInfo::hasReservedSpillSlot(const MachineFunction &MF, if (!RVFI->useSaveRestoreLibCalls(MF)) return false; - auto FII = FixedCSRFIMap.find(Reg); - if (FII == FixedCSRFIMap.end()) + const auto *FII = + llvm::find_if(FixedCSRFIMap, [&](auto P) { return P.first == Reg; }); + if (FII == std::end(FixedCSRFIMap)) return false; FrameIdx = FII->second; diff --git a/llvm/lib/Target/VE/VEInstrInfo.cpp b/llvm/lib/Target/VE/VEInstrInfo.cpp index 7c1bd52018672..94ebb59c4c771 100644 --- a/llvm/lib/Target/VE/VEInstrInfo.cpp +++ b/llvm/lib/Target/VE/VEInstrInfo.cpp @@ -811,7 +811,7 @@ static void expandPseudoVFMK(const TargetInstrInfo &TI, MachineInstr &MI) { // replace to pvfmk.w.up and pvfmk.w.lo // replace to pvfmk.s.up and pvfmk.s.lo - static std::map> VFMKMap = { + static const std::pair> VFMKMap[] = { {VE::VFMKyal, {VE::VFMKLal, VE::VFMKLal}}, {VE::VFMKynal, {VE::VFMKLnal, VE::VFMKLnal}}, {VE::VFMKWyvl, {VE::PVFMKWUPvl, VE::PVFMKWLOvl}}, @@ -822,8 +822,9 @@ static void expandPseudoVFMK(const TargetInstrInfo &TI, MachineInstr &MI) { unsigned Opcode = MI.getOpcode(); - auto Found = VFMKMap.find(Opcode); - if (Found == VFMKMap.end()) + const auto *Found = + llvm::find_if(VFMKMap, [&](auto P) { return P.first == Opcode; }); + if (Found == std::end(VFMKMap)) report_fatal_error("unexpected opcode for pseudo vfmk"); unsigned OpcodeUpper = (*Found).second.first;