Skip to content

[llvm] Use *Set::insert_range (NFC) #133041

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
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/include/llvm/Transforms/IPO/Attributor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5103,8 +5103,7 @@ template <typename MemberTy> struct PotentialValuesState : AbstractState {
indicatePessimisticFixpoint();
return;
}
for (const MemberTy &C : R.Set)
Set.insert(C);
Set.insert_range(R.Set);
UndefIsContained |= R.undefIsContained();
checkAndInvalidate();
}
Expand Down
3 changes: 1 addition & 2 deletions llvm/include/llvm/Transforms/Utils/LockstepReverseIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ class LockstepReverseIterator
Fail = false;
if constexpr (!EarlyFailure) {
this->ActiveBlocks.clear();
for (BasicBlock *BB : Blocks)
this->ActiveBlocks.insert(BB);
this->ActiveBlocks.insert_range(Blocks);
}
Insts.clear();
for (BasicBlock *BB : Blocks) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/ExecutionEngine/MCJIT/MCJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ class MCJIT : public ExecutionEngine {
}

void markAllLoadedModulesAsFinalized() {
for (Module *M : LoadedModules)
FinalizedModules.insert(M);
FinalizedModules.insert_range(LoadedModules);
LoadedModules.clear();
}

Expand Down
9 changes: 3 additions & 6 deletions llvm/lib/ExecutionEngine/Orc/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,7 @@ JITDylib::RemoveTrackerResult JITDylib::IL_removeTracker(ResourceTracker &RT) {
if (&RT == DefaultTracker.get()) {
SymbolNameSet TrackedSymbols;
for (auto &KV : TrackerSymbols)
for (auto &Sym : KV.second)
TrackedSymbols.insert(Sym);
TrackedSymbols.insert_range(KV.second);

for (auto &KV : Symbols) {
auto &Sym = KV.first;
Expand Down Expand Up @@ -1346,8 +1345,7 @@ void JITDylib::transferTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT) {
if (DstMRs.empty())
DstMRs = std::move(SrcMRs);
else
for (auto *MR : SrcMRs)
DstMRs.insert(MR);
DstMRs.insert_range(SrcMRs);
// Erase SrcRT entry in TrackerMRs. Use &SrcRT key rather than iterator I
// for this, since I may have been invalidated by 'TrackerMRs[&DstRT]'.
TrackerMRs.erase(&SrcRT);
Expand All @@ -1371,8 +1369,7 @@ void JITDylib::transferTracker(ResourceTracker &DstRT, ResourceTracker &SrcRT) {

SymbolNameSet CurrentlyTrackedSymbols;
for (auto &KV : TrackerSymbols)
for (auto &Sym : KV.second)
CurrentlyTrackedSymbols.insert(Sym);
CurrentlyTrackedSymbols.insert_range(KV.second);

for (auto &KV : Symbols) {
auto &Sym = KV.first;
Expand Down
9 changes: 3 additions & 6 deletions llvm/lib/ExecutionEngine/Orc/LinkGraphLinkingLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,16 +396,13 @@ class LinkGraphLinkingLayer::JITLinkCtx final : public JITLinkContext {

for (auto *FB : BI.AnonEdges) {
auto &FBI = BlockInfos[FB];
for (auto *BB : BI.AnonBackEdges)
FBI.AnonBackEdges.insert(BB);
FBI.AnonBackEdges.insert_range(BI.AnonBackEdges);
}

for (auto *BB : BI.AnonBackEdges) {
auto &BBI = BlockInfos[BB];
for (auto *SD : BI.SymbolDeps)
BBI.SymbolDeps.insert(SD);
for (auto *FB : BI.AnonEdges)
BBI.AnonEdges.insert(FB);
BBI.SymbolDeps.insert_range(BI.SymbolDeps);
BBI.AnonEdges.insert_range(BI.AnonEdges);
}
}

Expand Down
12 changes: 4 additions & 8 deletions llvm/lib/FileCheck/FileCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2491,14 +2491,10 @@ static bool ValidatePrefixes(StringRef Kind, StringSet<> &UniquePrefixes,
bool FileCheck::ValidateCheckPrefixes() {
StringSet<> UniquePrefixes;
// Add default prefixes to catch user-supplied duplicates of them below.
if (Req.CheckPrefixes.empty()) {
for (const char *Prefix : DefaultCheckPrefixes)
UniquePrefixes.insert(Prefix);
}
if (Req.CommentPrefixes.empty()) {
for (const char *Prefix : DefaultCommentPrefixes)
UniquePrefixes.insert(Prefix);
}
if (Req.CheckPrefixes.empty())
UniquePrefixes.insert_range(DefaultCheckPrefixes);
if (Req.CommentPrefixes.empty())
UniquePrefixes.insert_range(DefaultCommentPrefixes);
// Do not validate the default prefixes, or diagnostics about duplicates might
// incorrectly indicate that they were supplied by the user.
if (!ValidatePrefixes("check", UniquePrefixes, Req.CheckPrefixes))
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/IR/Assumptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ DenseSet<StringRef> getAssumptions(const Attribute &A) {
SmallVector<StringRef, 8> Strings;
A.getValueAsString().split(Strings, ",");

for (StringRef Str : Strings)
Assumptions.insert(Str);
Assumptions.insert_range(Strings);
return Assumptions;
}

Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/LTO/LTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context)
LTOCodeGenerator::~LTOCodeGenerator() = default;

void LTOCodeGenerator::setAsmUndefinedRefs(LTOModule *Mod) {
for (const StringRef &Undef : Mod->getAsmUndefinedRefs())
AsmUndefinedRefs.insert(Undef);
AsmUndefinedRefs.insert_range(Mod->getAsmUndefinedRefs());
}

bool LTOCodeGenerator::addModule(LTOModule *Mod) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/LTO/ThinLTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,7 @@ void ThinLTOCodeGenerator::run() {
std::map<ValueInfo, std::vector<VTableSlotSummary>> LocalWPDTargetsMap;
std::set<GlobalValue::GUID> ExportedGUIDs;
runWholeProgramDevirtOnIndex(*Index, ExportedGUIDs, LocalWPDTargetsMap);
for (auto GUID : ExportedGUIDs)
GUIDPreservedSymbols.insert(GUID);
GUIDPreservedSymbols.insert_range(ExportedGUIDs);

// Compute prevailing symbols
DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
Expand Down
9 changes: 3 additions & 6 deletions llvm/tools/bugpoint/CrashDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,8 @@ void simpleSimplifyCfg(Function &F, SmallVectorImpl<BasicBlock *> &BBs) {
// undefined behavior into unreachables, but bugpoint was the thing that
// generated the undefined behavior, and we don't want it to kill the entire
// program.
SmallPtrSet<BasicBlock *, 16> Visited;
for (auto *BB : depth_first(&F.getEntryBlock()))
Visited.insert(BB);
SmallPtrSet<BasicBlock *, 16> Visited(llvm::from_range,
depth_first(&F.getEntryBlock()));

SmallVector<BasicBlock *, 16> Unreachable;
for (auto &BB : F)
Expand Down Expand Up @@ -917,9 +916,7 @@ bool ReduceCrashingNamedMD::TestNamedMDs(std::vector<std::string> &NamedMDs) {
outs() << ": ";

// Make a StringMap for faster lookup
StringSet<> Names;
for (const std::string &Name : NamedMDs)
Names.insert(Name);
StringSet<> Names(llvm::from_range, NamedMDs);

// First collect all the metadata to delete in a vector, then
// delete them all at once to avoid invalidating the iterator
Expand Down
6 changes: 2 additions & 4 deletions llvm/tools/llvm-reduce/ReducerWorkItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,9 @@ static std::unique_ptr<MachineFunction> cloneMF(MachineFunction *SrcMF,
}
}

DenseSet<const uint32_t *> ConstRegisterMasks;

// Track predefined/named regmasks which we ignore.
for (const uint32_t *Mask : TRI->getRegMasks())
ConstRegisterMasks.insert(Mask);
DenseSet<const uint32_t *> ConstRegisterMasks(llvm::from_range,
TRI->getRegMasks());

// Clone instructions.
for (auto &SrcMBB : *SrcMF) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/tools/llvm-reduce/deltas/ReduceRegisterMasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ static void reduceMasksInFunction(Oracle &O, MachineFunction &MF) {

// Track predefined/named regmasks which we ignore.
const unsigned NumRegs = TRI->getNumRegs();
for (const uint32_t *Mask : TRI->getRegMasks())
ConstRegisterMasks.insert(Mask);
ConstRegisterMasks.insert_range(TRI->getRegMasks());

for (MachineBasicBlock &MBB : MF) {
for (MachineInstr &MI : MBB) {
Expand Down