Skip to content

Commit 825ecfe

Browse files
[ExecutionEngine] Avoid repeated hash lookups (NFC) (#133615)
1 parent fea6b38 commit 825ecfe

File tree

7 files changed

+11
-20
lines changed

7 files changed

+11
-20
lines changed

llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ Error EHFrameEdgeFixer::operator()(LinkGraph &G) {
7070
// Sort eh-frame blocks into address order to ensure we visit CIEs before
7171
// their child FDEs.
7272
std::vector<Block *> EHFrameBlocks;
73-
for (auto *B : EHFrame->blocks())
74-
EHFrameBlocks.push_back(B);
73+
llvm::append_range(EHFrameBlocks, EHFrame->blocks());
7574
llvm::sort(EHFrameBlocks, [](const Block *LHS, const Block *RHS) {
7675
return LHS->getAddress() < RHS->getAddress();
7776
});

llvm/lib/ExecutionEngine/Orc/COFFVCRuntimeSupport.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ Error COFFVCRuntimeBootstrapper::loadVCRuntime(
8686
if (!G)
8787
return G.takeError();
8888

89-
for (auto &Lib : (*G)->getImportedDynamicLibraries())
90-
ImportedLibraries.push_back(Lib);
89+
llvm::append_range(ImportedLibraries, (*G)->getImportedDynamicLibraries());
9190

9291
JD.addGenerator(std::move(*G));
9392

llvm/lib/ExecutionEngine/Orc/Core.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ void UnsatisfiedSymbolDependencies::log(raw_ostream &OS) const {
127127
SymbolsNotFound::SymbolsNotFound(std::shared_ptr<SymbolStringPool> SSP,
128128
SymbolNameSet Symbols)
129129
: SSP(std::move(SSP)) {
130-
for (auto &Sym : Symbols)
131-
this->Symbols.push_back(Sym);
130+
llvm::append_range(this->Symbols, Symbols);
132131
assert(!this->Symbols.empty() && "Can not fail to resolve an empty set");
133132
}
134133

@@ -2387,8 +2386,8 @@ void ExecutionSession::OL_applyQueryPhase1(
23872386
// Build the definition generator stack for this JITDylib.
23882387
runSessionLocked([&] {
23892388
IPLS->CurDefGeneratorStack.reserve(JD.DefGenerators.size());
2390-
for (auto &DG : reverse(JD.DefGenerators))
2391-
IPLS->CurDefGeneratorStack.push_back(DG);
2389+
llvm::append_range(IPLS->CurDefGeneratorStack,
2390+
reverse(JD.DefGenerators));
23922391
});
23932392

23942393
// Flag that we've done our initialization.

llvm/lib/ExecutionEngine/Orc/IRPartitionLayer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ void IRPartitionLayer::emitPartition(
260260
{
261261
std::vector<const GlobalValue *> HashGVs;
262262
HashGVs.reserve(GVsToExtract->size());
263-
for (const auto *GV : *GVsToExtract)
264-
HashGVs.push_back(GV);
263+
llvm::append_range(HashGVs, *GVsToExtract);
265264
llvm::sort(HashGVs, [](const GlobalValue *LHS, const GlobalValue *RHS) {
266265
return LHS->getName() < RHS->getName();
267266
});

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ Function *addHelperAndWrapper(Module &M, StringRef WrapperName,
5757
std::vector<Type *> HelperArgTypes;
5858
for (auto *Arg : HelperPrefixArgs)
5959
HelperArgTypes.push_back(Arg->getType());
60-
for (auto *T : WrapperFnType->params())
61-
HelperArgTypes.push_back(T);
60+
llvm::append_range(HelperArgTypes, WrapperFnType->params());
6261
auto *HelperFnType =
6362
FunctionType::get(WrapperFnType->getReturnType(), HelperArgTypes, false);
6463
auto *HelperFn = Function::Create(HelperFnType, GlobalValue::ExternalLinkage,
@@ -72,8 +71,7 @@ Function *addHelperAndWrapper(Module &M, StringRef WrapperName,
7271
IRBuilder<> IB(EntryBlock);
7372

7473
std::vector<Value *> HelperArgs;
75-
for (auto *Arg : HelperPrefixArgs)
76-
HelperArgs.push_back(Arg);
74+
llvm::append_range(HelperArgs, HelperPrefixArgs);
7775
for (auto &Arg : WrapperFn->args())
7876
HelperArgs.push_back(&Arg);
7977
auto *HelperResult = IB.CreateCall(HelperFn, HelperArgs);

llvm/lib/ExecutionEngine/Orc/MachOPlatform.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,10 +1676,8 @@ Error MachOPlatform::MachOPlatformPlugin::prepareSymbolTableRegistration(
16761676
// those names.
16771677
{
16781678
SmallVector<jitlink::Symbol *> SymsToProcess;
1679-
for (auto *Sym : G.defined_symbols())
1680-
SymsToProcess.push_back(Sym);
1681-
for (auto *Sym : G.absolute_symbols())
1682-
SymsToProcess.push_back(Sym);
1679+
llvm::append_range(SymsToProcess, G.defined_symbols());
1680+
llvm::append_range(SymsToProcess, G.absolute_symbols());
16831681

16841682
for (auto *Sym : SymsToProcess) {
16851683
if (!Sym->hasName())

llvm/lib/ExecutionEngine/Orc/SimpleRemoteEPC.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ lookupSymbolsAsyncHelper(EPCGenericDylibManager &DylibMgr,
4747
return Complete(R.takeError());
4848
Result.push_back({});
4949
Result.back().reserve(R->size());
50-
for (auto Addr : *R)
51-
Result.back().push_back(Addr);
50+
llvm::append_range(Result.back(), *R);
5251

5352
lookupSymbolsAsyncHelper(
5453
DylibMgr, Request.drop_front(), std::move(Result),

0 commit comments

Comments
 (0)