Files
TheRock/compiler/amd-llvm/llvm/lib/ExecutionEngine/Orc/ExecutorResolutionGenerator.cpp
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

96 lines
3.1 KiB
C++

//===---- ExecutorProcessControl.cpp -- Executor process control APIs -----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/Orc/ExecutorResolutionGenerator.h"
#include "llvm/ExecutionEngine/Orc/DebugUtils.h"
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h"
#include "llvm/Support/Error.h"
#define DEBUG_TYPE "orc"
namespace llvm {
namespace orc {
Expected<std::unique_ptr<ExecutorResolutionGenerator>>
ExecutorResolutionGenerator::Load(ExecutionSession &ES, DylibManager &DylibMgr,
const char *LibraryPath,
SymbolPredicate Allow,
AbsoluteSymbolsFn AbsoluteSymbols) {
auto H = DylibMgr.loadDylib(LibraryPath);
if (H)
return H.takeError();
return std::make_unique<ExecutorResolutionGenerator>(
ES, DylibMgr, *H, std::move(Allow), std::move(AbsoluteSymbols));
}
Error ExecutorResolutionGenerator::tryToGenerate(
LookupState &LS, LookupKind K, JITDylib &JD,
JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &LookupSet) {
if (LookupSet.empty())
return Error::success();
LLVM_DEBUG({
dbgs() << "ExecutorResolutionGenerator trying to generate " << LookupSet
<< "\n";
});
SymbolLookupSet LookupSymbols;
for (auto &[Name, LookupFlag] : LookupSet) {
if (Allow && !Allow(Name))
continue;
LookupSymbols.add(Name, LookupFlag);
}
DylibMgr.lookupSymbolsAsync(
H, LookupSymbols,
[this, LS = std::move(LS), JD = JITDylibSP(&JD),
LookupSymbols](auto Result) mutable {
if (Result) {
LLVM_DEBUG({
dbgs() << "ExecutorResolutionGenerator lookup failed due to error";
});
return LS.continueLookup(Result.takeError());
}
assert(Result->size() == LookupSymbols.size() &&
"Result has incorrect number of elements");
auto Syms = Result->begin();
SymbolNameSet MissingSymbols;
SymbolMap NewSyms;
for (auto &[Name, Flags] : LookupSymbols) {
const auto &Sym = *Syms++;
if (Sym && Sym->getAddress())
NewSyms[Name] = *Sym;
else if (LLVM_UNLIKELY(!Sym &&
Flags == SymbolLookupFlags::RequiredSymbol))
MissingSymbols.insert(Name);
}
LLVM_DEBUG({
dbgs() << "ExecutorResolutionGenerator lookup returned " << NewSyms
<< "\n";
});
if (NewSyms.empty())
return LS.continueLookup(Error::success());
if (LLVM_UNLIKELY(!MissingSymbols.empty()))
return LS.continueLookup(make_error<SymbolsNotFound>(
this->ES.getSymbolStringPool(), std::move(MissingSymbols)));
LS.continueLookup(JD->define(AbsoluteSymbols(std::move(NewSyms))));
});
return Error::success();
}
} // end namespace orc
} // end namespace llvm