changeset 225:f7655407a6ba

remove unnecessary files
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 19 Jul 2021 03:48:36 +0900
parents 292f64a68d8a
children f48a93eada0e
files llvm/lib/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.cpp llvm/lib/ExecutionEngine/Orc/TPCDebugObjectRegistrar.cpp llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp llvm/lib/ExecutionEngine/Orc/TPCEHFrameRegistrar.cpp llvm/lib/ExecutionEngine/Orc/TPCIndirectionUtils.cpp llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp
diffstat 6 files changed, 0 insertions(+), 832 deletions(-) [+]
line wrap: on
line diff
--- a/llvm/lib/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.cpp	Mon Jul 19 03:29:25 2021 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-//===---------- TargetProcessControlTypes.cpp - Shared TPC types ----------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// TargetProcessControl types.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
-
-namespace llvm {
-namespace orc {
-namespace tpctypes {
-
-WrapperFunctionResult WrapperFunctionResult::from(StringRef S) {
-  CWrapperFunctionResult R;
-  zeroInit(R);
-  R.Size = S.size();
-  if (R.Size > sizeof(uint64_t)) {
-    R.Data.ValuePtr = new uint8_t[R.Size];
-    memcpy(R.Data.ValuePtr, S.data(), R.Size);
-    R.Destroy = destroyWithDeleteArray;
-  } else
-    memcpy(R.Data.Value, S.data(), R.Size);
-  return R;
-}
-
-void WrapperFunctionResult::destroyWithFree(CWrapperFunctionResultData Data,
-                                            uint64_t Size) {
-  free(Data.ValuePtr);
-}
-
-void WrapperFunctionResult::destroyWithDeleteArray(
-    CWrapperFunctionResultData Data, uint64_t Size) {
-  delete[] Data.ValuePtr;
-}
-
-} // end namespace tpctypes
-} // end namespace orc
-} // end namespace llvm
--- a/llvm/lib/ExecutionEngine/Orc/TPCDebugObjectRegistrar.cpp	Mon Jul 19 03:29:25 2021 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-//===----- TPCDebugObjectRegistrar.cpp - TPC-based debug registration -----===//
-//
-// 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/TPCDebugObjectRegistrar.h"
-
-#include "llvm/ExecutionEngine/Orc/Core.h"
-#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
-#include "llvm/Support/BinaryStreamWriter.h"
-
-namespace llvm {
-namespace orc {
-
-// Counterpart for readDebugObjectInfo() in TargetProcess/JITLoaderGDB.cpp
-static std::vector<uint8_t>
-writeDebugObjectInfo(sys::MemoryBlock TargetMemBlock) {
-  auto DebugObjAddr = pointerToJITTargetAddress(TargetMemBlock.base());
-  uint64_t DebugObjSize = TargetMemBlock.allocatedSize();
-
-  std::vector<uint8_t> ArgBuffer;
-  ArgBuffer.resize(sizeof(decltype(DebugObjAddr)) +
-                   sizeof(decltype(DebugObjSize)));
-
-  BinaryStreamWriter ArgWriter(ArgBuffer, support::endianness::big);
-  cantFail(ArgWriter.writeInteger(DebugObjAddr));
-  cantFail(ArgWriter.writeInteger(DebugObjSize));
-
-  return ArgBuffer;
-}
-
-Expected<std::unique_ptr<TPCDebugObjectRegistrar>>
-createJITLoaderGDBRegistrar(TargetProcessControl &TPC) {
-  auto ProcessHandle = TPC.loadDylib(nullptr);
-  if (!ProcessHandle)
-    return ProcessHandle.takeError();
-
-  SymbolStringPtr RegisterFn =
-      TPC.getTargetTriple().isOSBinFormatMachO()
-          ? TPC.intern("_llvm_orc_registerJITLoaderGDBWrapper")
-          : TPC.intern("llvm_orc_registerJITLoaderGDBWrapper");
-
-  SymbolLookupSet RegistrationSymbols;
-  RegistrationSymbols.add(RegisterFn);
-
-  auto Result = TPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
-  if (!Result)
-    return Result.takeError();
-
-  assert(Result->size() == 1 && "Unexpected number of dylibs in result");
-  assert((*Result)[0].size() == 1 &&
-         "Unexpected number of addresses in result");
-
-  return std::make_unique<TPCDebugObjectRegistrar>(TPC, (*Result)[0][0],
-                                                   &writeDebugObjectInfo);
-}
-
-} // namespace orc
-} // namespace llvm
--- a/llvm/lib/ExecutionEngine/Orc/TPCDynamicLibrarySearchGenerator.cpp	Mon Jul 19 03:29:25 2021 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-//===---------------- TPCDynamicLibrarySearchGenerator.cpp ----------------===//
-//
-// 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/TPCDynamicLibrarySearchGenerator.h"
-
-namespace llvm {
-namespace orc {
-
-Expected<std::unique_ptr<TPCDynamicLibrarySearchGenerator>>
-TPCDynamicLibrarySearchGenerator::Load(TargetProcessControl &TPC,
-                                       const char *LibraryPath,
-                                       SymbolPredicate Allow) {
-  auto Handle = TPC.loadDylib(LibraryPath);
-  if (!Handle)
-    return Handle.takeError();
-
-  return std::make_unique<TPCDynamicLibrarySearchGenerator>(TPC, *Handle,
-                                                            std::move(Allow));
-}
-
-Error TPCDynamicLibrarySearchGenerator::tryToGenerate(
-    LookupState &LS, LookupKind K, JITDylib &JD,
-    JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) {
-
-  if (Symbols.empty())
-    return Error::success();
-
-  SymbolLookupSet LookupSymbols;
-
-  for (auto &KV : Symbols) {
-    // Skip symbols that don't match the filter.
-    if (Allow && !Allow(KV.first))
-      continue;
-    LookupSymbols.add(KV.first, SymbolLookupFlags::WeaklyReferencedSymbol);
-  }
-
-  SymbolMap NewSymbols;
-
-  TargetProcessControl::LookupRequest Request(H, LookupSymbols);
-  auto Result = TPC.lookupSymbols(Request);
-  if (!Result)
-    return Result.takeError();
-
-  assert(Result->size() == 1 && "Results for more than one library returned");
-  assert(Result->front().size() == LookupSymbols.size() &&
-         "Result has incorrect number of elements");
-
-  auto ResultI = Result->front().begin();
-  for (auto &KV : LookupSymbols) {
-    if (*ResultI)
-      NewSymbols[KV.first] =
-          JITEvaluatedSymbol(*ResultI, JITSymbolFlags::Exported);
-    ++ResultI;
-  }
-
-  // If there were no resolved symbols bail out.
-  if (NewSymbols.empty())
-    return Error::success();
-
-  // Define resolved symbols.
-  return JD.define(absoluteSymbols(std::move(NewSymbols)));
-}
-
-} // end namespace orc
-} // end namespace llvm
--- a/llvm/lib/ExecutionEngine/Orc/TPCEHFrameRegistrar.cpp	Mon Jul 19 03:29:25 2021 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-//===------ TPCEHFrameRegistrar.cpp - TPC-based eh-frame registration -----===//
-//
-// 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/TPCEHFrameRegistrar.h"
-#include "llvm/Support/BinaryStreamWriter.h"
-
-namespace llvm {
-namespace orc {
-
-Expected<std::unique_ptr<TPCEHFrameRegistrar>>
-TPCEHFrameRegistrar::Create(TargetProcessControl &TPC) {
-  // FIXME: Proper mangling here -- we really need to decouple linker mangling
-  // from DataLayout.
-
-  // Find the addresses of the registration/deregistration functions in the
-  // target process.
-  auto ProcessHandle = TPC.loadDylib(nullptr);
-  if (!ProcessHandle)
-    return ProcessHandle.takeError();
-
-  std::string RegisterWrapperName, DeregisterWrapperName;
-  if (TPC.getTargetTriple().isOSBinFormatMachO()) {
-    RegisterWrapperName += '_';
-    DeregisterWrapperName += '_';
-  }
-  RegisterWrapperName += "llvm_orc_registerEHFrameSectionWrapper";
-  DeregisterWrapperName += "llvm_orc_deregisterEHFrameSectionWrapper";
-
-  SymbolLookupSet RegistrationSymbols;
-  RegistrationSymbols.add(TPC.intern(RegisterWrapperName));
-  RegistrationSymbols.add(TPC.intern(DeregisterWrapperName));
-
-  auto Result = TPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
-  if (!Result)
-    return Result.takeError();
-
-  assert(Result->size() == 1 && "Unexpected number of dylibs in result");
-  assert((*Result)[0].size() == 2 &&
-         "Unexpected number of addresses in result");
-
-  auto RegisterEHFrameWrapperFnAddr = (*Result)[0][0];
-  auto DeregisterEHFrameWrapperFnAddr = (*Result)[0][1];
-
-  return std::make_unique<TPCEHFrameRegistrar>(
-      TPC, RegisterEHFrameWrapperFnAddr, DeregisterEHFrameWrapperFnAddr);
-}
-
-Error TPCEHFrameRegistrar::registerEHFrames(JITTargetAddress EHFrameSectionAddr,
-                                            size_t EHFrameSectionSize) {
-  constexpr size_t ArgBufferSize = sizeof(uint64_t) + sizeof(uint64_t);
-  uint8_t ArgBuffer[ArgBufferSize];
-  BinaryStreamWriter ArgWriter(
-      MutableArrayRef<uint8_t>(ArgBuffer, ArgBufferSize),
-      support::endianness::big);
-  cantFail(ArgWriter.writeInteger(static_cast<uint64_t>(EHFrameSectionAddr)));
-  cantFail(ArgWriter.writeInteger(static_cast<uint64_t>(EHFrameSectionSize)));
-
-  return TPC.runWrapper(RegisterEHFrameWrapperFnAddr, ArgBuffer).takeError();
-}
-
-Error TPCEHFrameRegistrar::deregisterEHFrames(
-    JITTargetAddress EHFrameSectionAddr, size_t EHFrameSectionSize) {
-  constexpr size_t ArgBufferSize = sizeof(uint64_t) + sizeof(uint64_t);
-  uint8_t ArgBuffer[ArgBufferSize];
-  BinaryStreamWriter ArgWriter(
-      MutableArrayRef<uint8_t>(ArgBuffer, ArgBufferSize),
-      support::endianness::big);
-  cantFail(ArgWriter.writeInteger(static_cast<uint64_t>(EHFrameSectionAddr)));
-  cantFail(ArgWriter.writeInteger(static_cast<uint64_t>(EHFrameSectionSize)));
-
-  return TPC.runWrapper(DeregisterEHFrameWrapperFnAddr, ArgBuffer).takeError();
-}
-
-} // end namespace orc
-} // end namespace llvm
--- a/llvm/lib/ExecutionEngine/Orc/TPCIndirectionUtils.cpp	Mon Jul 19 03:29:25 2021 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,423 +0,0 @@
-//===------ TargetProcessControl.cpp -- Target 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/TPCIndirectionUtils.h"
-
-#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
-#include "llvm/Support/MathExtras.h"
-
-#include <future>
-
-using namespace llvm;
-using namespace llvm::orc;
-
-namespace llvm {
-namespace orc {
-
-class TPCIndirectionUtilsAccess {
-public:
-  using IndirectStubInfo = TPCIndirectionUtils::IndirectStubInfo;
-  using IndirectStubInfoVector = TPCIndirectionUtils::IndirectStubInfoVector;
-
-  static Expected<IndirectStubInfoVector>
-  getIndirectStubs(TPCIndirectionUtils &TPCIU, unsigned NumStubs) {
-    return TPCIU.getIndirectStubs(NumStubs);
-  };
-};
-
-} // end namespace orc
-} // end namespace llvm
-
-namespace {
-
-class TPCTrampolinePool : public TrampolinePool {
-public:
-  TPCTrampolinePool(TPCIndirectionUtils &TPCIU);
-  Error deallocatePool();
-
-protected:
-  Error grow() override;
-
-  using Allocation = jitlink::JITLinkMemoryManager::Allocation;
-
-  TPCIndirectionUtils &TPCIU;
-  unsigned TrampolineSize = 0;
-  unsigned TrampolinesPerPage = 0;
-  std::vector<std::unique_ptr<Allocation>> TrampolineBlocks;
-};
-
-class TPCIndirectStubsManager : public IndirectStubsManager,
-                                private TPCIndirectionUtilsAccess {
-public:
-  TPCIndirectStubsManager(TPCIndirectionUtils &TPCIU) : TPCIU(TPCIU) {}
-
-  Error deallocateStubs();
-
-  Error createStub(StringRef StubName, JITTargetAddress StubAddr,
-                   JITSymbolFlags StubFlags) override;
-
-  Error createStubs(const StubInitsMap &StubInits) override;
-
-  JITEvaluatedSymbol findStub(StringRef Name, bool ExportedStubsOnly) override;
-
-  JITEvaluatedSymbol findPointer(StringRef Name) override;
-
-  Error updatePointer(StringRef Name, JITTargetAddress NewAddr) override;
-
-private:
-  using StubInfo = std::pair<IndirectStubInfo, JITSymbolFlags>;
-
-  std::mutex ISMMutex;
-  TPCIndirectionUtils &TPCIU;
-  StringMap<StubInfo> StubInfos;
-};
-
-TPCTrampolinePool::TPCTrampolinePool(TPCIndirectionUtils &TPCIU)
-    : TPCIU(TPCIU) {
-  auto &TPC = TPCIU.getTargetProcessControl();
-  auto &ABI = TPCIU.getABISupport();
-
-  TrampolineSize = ABI.getTrampolineSize();
-  TrampolinesPerPage =
-      (TPC.getPageSize() - ABI.getPointerSize()) / TrampolineSize;
-}
-
-Error TPCTrampolinePool::deallocatePool() {
-  Error Err = Error::success();
-  for (auto &Alloc : TrampolineBlocks)
-    Err = joinErrors(std::move(Err), Alloc->deallocate());
-  return Err;
-}
-
-Error TPCTrampolinePool::grow() {
-  assert(AvailableTrampolines.empty() &&
-         "Grow called with trampolines still available");
-
-  auto ResolverAddress = TPCIU.getResolverBlockAddress();
-  assert(ResolverAddress && "Resolver address can not be null");
-
-  auto &TPC = TPCIU.getTargetProcessControl();
-  constexpr auto TrampolinePagePermissions =
-      static_cast<sys::Memory::ProtectionFlags>(sys::Memory::MF_READ |
-                                                sys::Memory::MF_EXEC);
-  auto PageSize = TPC.getPageSize();
-  jitlink::JITLinkMemoryManager::SegmentsRequestMap Request;
-  Request[TrampolinePagePermissions] = {PageSize, static_cast<size_t>(PageSize),
-                                        0};
-  auto Alloc = TPC.getMemMgr().allocate(nullptr, Request);
-
-  if (!Alloc)
-    return Alloc.takeError();
-
-  unsigned NumTrampolines = TrampolinesPerPage;
-
-  auto WorkingMemory = (*Alloc)->getWorkingMemory(TrampolinePagePermissions);
-  auto TargetAddress = (*Alloc)->getTargetMemory(TrampolinePagePermissions);
-
-  TPCIU.getABISupport().writeTrampolines(WorkingMemory.data(), TargetAddress,
-                                         ResolverAddress, NumTrampolines);
-
-  auto TargetAddr = (*Alloc)->getTargetMemory(TrampolinePagePermissions);
-  for (unsigned I = 0; I < NumTrampolines; ++I)
-    AvailableTrampolines.push_back(TargetAddr + (I * TrampolineSize));
-
-  if (auto Err = (*Alloc)->finalize())
-    return Err;
-
-  TrampolineBlocks.push_back(std::move(*Alloc));
-
-  return Error::success();
-}
-
-Error TPCIndirectStubsManager::createStub(StringRef StubName,
-                                          JITTargetAddress StubAddr,
-                                          JITSymbolFlags StubFlags) {
-  StubInitsMap SIM;
-  SIM[StubName] = std::make_pair(StubAddr, StubFlags);
-  return createStubs(SIM);
-}
-
-Error TPCIndirectStubsManager::createStubs(const StubInitsMap &StubInits) {
-  auto AvailableStubInfos = getIndirectStubs(TPCIU, StubInits.size());
-  if (!AvailableStubInfos)
-    return AvailableStubInfos.takeError();
-
-  {
-    std::lock_guard<std::mutex> Lock(ISMMutex);
-    unsigned ASIdx = 0;
-    for (auto &SI : StubInits) {
-      auto &A = (*AvailableStubInfos)[ASIdx++];
-      StubInfos[SI.first()] = std::make_pair(A, SI.second.second);
-    }
-  }
-
-  auto &MemAccess = TPCIU.getTargetProcessControl().getMemoryAccess();
-  switch (TPCIU.getABISupport().getPointerSize()) {
-  case 4: {
-    unsigned ASIdx = 0;
-    std::vector<tpctypes::UInt32Write> PtrUpdates;
-    for (auto &SI : StubInits)
-      PtrUpdates.push_back({(*AvailableStubInfos)[ASIdx++].PointerAddress,
-                            static_cast<uint32_t>(SI.second.first)});
-    return MemAccess.writeUInt32s(PtrUpdates);
-  }
-  case 8: {
-    unsigned ASIdx = 0;
-    std::vector<tpctypes::UInt64Write> PtrUpdates;
-    for (auto &SI : StubInits)
-      PtrUpdates.push_back({(*AvailableStubInfos)[ASIdx++].PointerAddress,
-                            static_cast<uint64_t>(SI.second.first)});
-    return MemAccess.writeUInt64s(PtrUpdates);
-  }
-  default:
-    return make_error<StringError>("Unsupported pointer size",
-                                   inconvertibleErrorCode());
-  }
-}
-
-JITEvaluatedSymbol TPCIndirectStubsManager::findStub(StringRef Name,
-                                                     bool ExportedStubsOnly) {
-  std::lock_guard<std::mutex> Lock(ISMMutex);
-  auto I = StubInfos.find(Name);
-  if (I == StubInfos.end())
-    return nullptr;
-  return {I->second.first.StubAddress, I->second.second};
-}
-
-JITEvaluatedSymbol TPCIndirectStubsManager::findPointer(StringRef Name) {
-  std::lock_guard<std::mutex> Lock(ISMMutex);
-  auto I = StubInfos.find(Name);
-  if (I == StubInfos.end())
-    return nullptr;
-  return {I->second.first.PointerAddress, I->second.second};
-}
-
-Error TPCIndirectStubsManager::updatePointer(StringRef Name,
-                                             JITTargetAddress NewAddr) {
-
-  JITTargetAddress PtrAddr = 0;
-  {
-    std::lock_guard<std::mutex> Lock(ISMMutex);
-    auto I = StubInfos.find(Name);
-    if (I == StubInfos.end())
-      return make_error<StringError>("Unknown stub name",
-                                     inconvertibleErrorCode());
-    PtrAddr = I->second.first.PointerAddress;
-  }
-
-  auto &MemAccess = TPCIU.getTargetProcessControl().getMemoryAccess();
-  switch (TPCIU.getABISupport().getPointerSize()) {
-  case 4: {
-    tpctypes::UInt32Write PUpdate(PtrAddr, NewAddr);
-    return MemAccess.writeUInt32s(PUpdate);
-  }
-  case 8: {
-    tpctypes::UInt64Write PUpdate(PtrAddr, NewAddr);
-    return MemAccess.writeUInt64s(PUpdate);
-  }
-  default:
-    return make_error<StringError>("Unsupported pointer size",
-                                   inconvertibleErrorCode());
-  }
-}
-
-} // end anonymous namespace.
-
-namespace llvm {
-namespace orc {
-
-TPCIndirectionUtils::ABISupport::~ABISupport() {}
-
-Expected<std::unique_ptr<TPCIndirectionUtils>>
-TPCIndirectionUtils::Create(TargetProcessControl &TPC) {
-  const auto &TT = TPC.getTargetTriple();
-  switch (TT.getArch()) {
-  default:
-    return make_error<StringError>(
-        std::string("No TPCIndirectionUtils available for ") + TT.str(),
-        inconvertibleErrorCode());
-  case Triple::aarch64:
-  case Triple::aarch64_32:
-    return CreateWithABI<OrcAArch64>(TPC);
-
-  case Triple::x86:
-    return CreateWithABI<OrcI386>(TPC);
-
-  case Triple::mips:
-    return CreateWithABI<OrcMips32Be>(TPC);
-
-  case Triple::mipsel:
-    return CreateWithABI<OrcMips32Le>(TPC);
-
-  case Triple::mips64:
-  case Triple::mips64el:
-    return CreateWithABI<OrcMips64>(TPC);
-
-  case Triple::x86_64:
-    if (TT.getOS() == Triple::OSType::Win32)
-      return CreateWithABI<OrcX86_64_Win32>(TPC);
-    else
-      return CreateWithABI<OrcX86_64_SysV>(TPC);
-  }
-}
-
-Error TPCIndirectionUtils::cleanup() {
-  Error Err = Error::success();
-
-  for (auto &A : IndirectStubAllocs)
-    Err = joinErrors(std::move(Err), A->deallocate());
-
-  if (TP)
-    Err = joinErrors(std::move(Err),
-                     static_cast<TPCTrampolinePool &>(*TP).deallocatePool());
-
-  if (ResolverBlock)
-    Err = joinErrors(std::move(Err), ResolverBlock->deallocate());
-
-  return Err;
-}
-
-Expected<JITTargetAddress>
-TPCIndirectionUtils::writeResolverBlock(JITTargetAddress ReentryFnAddr,
-                                        JITTargetAddress ReentryCtxAddr) {
-  assert(ABI && "ABI can not be null");
-  constexpr auto ResolverBlockPermissions =
-      static_cast<sys::Memory::ProtectionFlags>(sys::Memory::MF_READ |
-                                                sys::Memory::MF_EXEC);
-  auto ResolverSize = ABI->getResolverCodeSize();
-
-  jitlink::JITLinkMemoryManager::SegmentsRequestMap Request;
-  Request[ResolverBlockPermissions] = {TPC.getPageSize(),
-                                       static_cast<size_t>(ResolverSize), 0};
-  auto Alloc = TPC.getMemMgr().allocate(nullptr, Request);
-  if (!Alloc)
-    return Alloc.takeError();
-
-  auto WorkingMemory = (*Alloc)->getWorkingMemory(ResolverBlockPermissions);
-  ResolverBlockAddr = (*Alloc)->getTargetMemory(ResolverBlockPermissions);
-  ABI->writeResolverCode(WorkingMemory.data(), ResolverBlockAddr, ReentryFnAddr,
-                         ReentryCtxAddr);
-
-  if (auto Err = (*Alloc)->finalize())
-    return std::move(Err);
-
-  ResolverBlock = std::move(*Alloc);
-  return ResolverBlockAddr;
-}
-
-std::unique_ptr<IndirectStubsManager>
-TPCIndirectionUtils::createIndirectStubsManager() {
-  return std::make_unique<TPCIndirectStubsManager>(*this);
-}
-
-TrampolinePool &TPCIndirectionUtils::getTrampolinePool() {
-  if (!TP)
-    TP = std::make_unique<TPCTrampolinePool>(*this);
-  return *TP;
-}
-
-LazyCallThroughManager &TPCIndirectionUtils::createLazyCallThroughManager(
-    ExecutionSession &ES, JITTargetAddress ErrorHandlerAddr) {
-  assert(!LCTM &&
-         "createLazyCallThroughManager can not have been called before");
-  LCTM = std::make_unique<LazyCallThroughManager>(ES, ErrorHandlerAddr,
-                                                  &getTrampolinePool());
-  return *LCTM;
-}
-
-TPCIndirectionUtils::TPCIndirectionUtils(TargetProcessControl &TPC,
-                                         std::unique_ptr<ABISupport> ABI)
-    : TPC(TPC), ABI(std::move(ABI)) {
-  assert(this->ABI && "ABI can not be null");
-
-  assert(TPC.getPageSize() > getABISupport().getStubSize() &&
-         "Stubs larger than one page are not supported");
-}
-
-Expected<TPCIndirectionUtils::IndirectStubInfoVector>
-TPCIndirectionUtils::getIndirectStubs(unsigned NumStubs) {
-
-  std::lock_guard<std::mutex> Lock(TPCUIMutex);
-
-  // If there aren't enough stubs available then allocate some more.
-  if (NumStubs > AvailableIndirectStubs.size()) {
-    auto NumStubsToAllocate = NumStubs;
-    auto PageSize = TPC.getPageSize();
-    auto StubBytes = alignTo(NumStubsToAllocate * ABI->getStubSize(), PageSize);
-    NumStubsToAllocate = StubBytes / ABI->getStubSize();
-    auto PointerBytes =
-        alignTo(NumStubsToAllocate * ABI->getPointerSize(), PageSize);
-
-    constexpr auto StubPagePermissions =
-        static_cast<sys::Memory::ProtectionFlags>(sys::Memory::MF_READ |
-                                                  sys::Memory::MF_EXEC);
-    constexpr auto PointerPagePermissions =
-        static_cast<sys::Memory::ProtectionFlags>(sys::Memory::MF_READ |
-                                                  sys::Memory::MF_WRITE);
-
-    jitlink::JITLinkMemoryManager::SegmentsRequestMap Request;
-    Request[StubPagePermissions] = {PageSize, static_cast<size_t>(StubBytes),
-                                    0};
-    Request[PointerPagePermissions] = {PageSize, 0, PointerBytes};
-    auto Alloc = TPC.getMemMgr().allocate(nullptr, Request);
-    if (!Alloc)
-      return Alloc.takeError();
-
-    auto StubTargetAddr = (*Alloc)->getTargetMemory(StubPagePermissions);
-    auto PointerTargetAddr = (*Alloc)->getTargetMemory(PointerPagePermissions);
-
-    ABI->writeIndirectStubsBlock(
-        (*Alloc)->getWorkingMemory(StubPagePermissions).data(), StubTargetAddr,
-        PointerTargetAddr, NumStubsToAllocate);
-
-    if (auto Err = (*Alloc)->finalize())
-      return std::move(Err);
-
-    for (unsigned I = 0; I != NumStubsToAllocate; ++I) {
-      AvailableIndirectStubs.push_back(
-          IndirectStubInfo(StubTargetAddr, PointerTargetAddr));
-      StubTargetAddr += ABI->getStubSize();
-      PointerTargetAddr += ABI->getPointerSize();
-    }
-
-    IndirectStubAllocs.push_back(std::move(*Alloc));
-  }
-
-  assert(NumStubs <= AvailableIndirectStubs.size() &&
-         "Sufficient stubs should have been allocated above");
-
-  IndirectStubInfoVector Result;
-  while (NumStubs--) {
-    Result.push_back(AvailableIndirectStubs.back());
-    AvailableIndirectStubs.pop_back();
-  }
-
-  return std::move(Result);
-}
-
-static JITTargetAddress reentry(JITTargetAddress LCTMAddr,
-                                JITTargetAddress TrampolineAddr) {
-  auto &LCTM = *jitTargetAddressToPointer<LazyCallThroughManager *>(LCTMAddr);
-  std::promise<JITTargetAddress> LandingAddrP;
-  auto LandingAddrF = LandingAddrP.get_future();
-  LCTM.resolveTrampolineLandingAddress(
-      TrampolineAddr,
-      [&](JITTargetAddress Addr) { LandingAddrP.set_value(Addr); });
-  return LandingAddrF.get();
-}
-
-Error setUpInProcessLCTMReentryViaTPCIU(TPCIndirectionUtils &TPCIU) {
-  auto &LCTM = TPCIU.getLazyCallThroughManager();
-  return TPCIU
-      .writeResolverBlock(pointerToJITTargetAddress(&reentry),
-                          pointerToJITTargetAddress(&LCTM))
-      .takeError();
-}
-
-} // end namespace orc
-} // end namespace llvm
--- a/llvm/lib/ExecutionEngine/Orc/TargetProcessControl.cpp	Mon Jul 19 03:29:25 2021 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-//===------ TargetProcessControl.cpp -- Target 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/TargetProcessControl.h"
-
-#include "llvm/ExecutionEngine/Orc/Core.h"
-#include "llvm/ExecutionEngine/Orc/TargetProcess/TargetExecutionUtils.h"
-#include "llvm/Support/Host.h"
-#include "llvm/Support/Process.h"
-
-#include <mutex>
-
-namespace llvm {
-namespace orc {
-
-TargetProcessControl::MemoryAccess::~MemoryAccess() {}
-
-TargetProcessControl::~TargetProcessControl() {}
-
-SelfTargetProcessControl::SelfTargetProcessControl(
-    std::shared_ptr<SymbolStringPool> SSP, Triple TargetTriple,
-    unsigned PageSize, std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr)
-    : TargetProcessControl(std::move(SSP)) {
-
-  OwnedMemMgr = std::move(MemMgr);
-  if (!OwnedMemMgr)
-    OwnedMemMgr = std::make_unique<jitlink::InProcessMemoryManager>();
-
-  this->TargetTriple = std::move(TargetTriple);
-  this->PageSize = PageSize;
-  this->MemMgr = OwnedMemMgr.get();
-  this->MemAccess = this;
-  if (this->TargetTriple.isOSBinFormatMachO())
-    GlobalManglingPrefix = '_';
-}
-
-Expected<std::unique_ptr<SelfTargetProcessControl>>
-SelfTargetProcessControl::Create(
-    std::shared_ptr<SymbolStringPool> SSP,
-    std::unique_ptr<jitlink::JITLinkMemoryManager> MemMgr) {
-  auto PageSize = sys::Process::getPageSize();
-  if (!PageSize)
-    return PageSize.takeError();
-
-  Triple TT(sys::getProcessTriple());
-
-  return std::make_unique<SelfTargetProcessControl>(
-      std::move(SSP), std::move(TT), *PageSize, std::move(MemMgr));
-}
-
-Expected<tpctypes::DylibHandle>
-SelfTargetProcessControl::loadDylib(const char *DylibPath) {
-  std::string ErrMsg;
-  auto Dylib = std::make_unique<sys::DynamicLibrary>(
-      sys::DynamicLibrary::getPermanentLibrary(DylibPath, &ErrMsg));
-  if (!Dylib->isValid())
-    return make_error<StringError>(std::move(ErrMsg), inconvertibleErrorCode());
-  DynamicLibraries.push_back(std::move(Dylib));
-  return pointerToJITTargetAddress(DynamicLibraries.back().get());
-}
-
-Expected<std::vector<tpctypes::LookupResult>>
-SelfTargetProcessControl::lookupSymbols(ArrayRef<LookupRequest> Request) {
-  std::vector<tpctypes::LookupResult> R;
-
-  for (auto &Elem : Request) {
-    auto *Dylib = jitTargetAddressToPointer<sys::DynamicLibrary *>(Elem.Handle);
-    assert(llvm::any_of(DynamicLibraries,
-                        [=](const std::unique_ptr<sys::DynamicLibrary> &DL) {
-                          return DL.get() == Dylib;
-                        }) &&
-           "Invalid handle");
-
-    R.push_back(std::vector<JITTargetAddress>());
-    for (auto &KV : Elem.Symbols) {
-      auto &Sym = KV.first;
-      std::string Tmp((*Sym).data() + !!GlobalManglingPrefix,
-                      (*Sym).size() - !!GlobalManglingPrefix);
-      void *Addr = Dylib->getAddressOfSymbol(Tmp.c_str());
-      if (!Addr && KV.second == SymbolLookupFlags::RequiredSymbol) {
-        // FIXME: Collect all failing symbols before erroring out.
-        SymbolNameVector MissingSymbols;
-        MissingSymbols.push_back(Sym);
-        return make_error<SymbolsNotFound>(std::move(MissingSymbols));
-      }
-      R.back().push_back(pointerToJITTargetAddress(Addr));
-    }
-  }
-
-  return R;
-}
-
-Expected<int32_t>
-SelfTargetProcessControl::runAsMain(JITTargetAddress MainFnAddr,
-                                    ArrayRef<std::string> Args) {
-  using MainTy = int (*)(int, char *[]);
-  return orc::runAsMain(jitTargetAddressToFunction<MainTy>(MainFnAddr), Args);
-}
-
-Expected<tpctypes::WrapperFunctionResult>
-SelfTargetProcessControl::runWrapper(JITTargetAddress WrapperFnAddr,
-                                     ArrayRef<uint8_t> ArgBuffer) {
-  using WrapperFnTy =
-      tpctypes::CWrapperFunctionResult (*)(const uint8_t *Data, uint64_t Size);
-  auto *WrapperFn = jitTargetAddressToFunction<WrapperFnTy>(WrapperFnAddr);
-  return WrapperFn(ArgBuffer.data(), ArgBuffer.size());
-}
-
-Error SelfTargetProcessControl::disconnect() { return Error::success(); }
-
-void SelfTargetProcessControl::writeUInt8s(ArrayRef<tpctypes::UInt8Write> Ws,
-                                           WriteResultFn OnWriteComplete) {
-  for (auto &W : Ws)
-    *jitTargetAddressToPointer<uint8_t *>(W.Address) = W.Value;
-  OnWriteComplete(Error::success());
-}
-
-void SelfTargetProcessControl::writeUInt16s(ArrayRef<tpctypes::UInt16Write> Ws,
-                                            WriteResultFn OnWriteComplete) {
-  for (auto &W : Ws)
-    *jitTargetAddressToPointer<uint16_t *>(W.Address) = W.Value;
-  OnWriteComplete(Error::success());
-}
-
-void SelfTargetProcessControl::writeUInt32s(ArrayRef<tpctypes::UInt32Write> Ws,
-                                            WriteResultFn OnWriteComplete) {
-  for (auto &W : Ws)
-    *jitTargetAddressToPointer<uint32_t *>(W.Address) = W.Value;
-  OnWriteComplete(Error::success());
-}
-
-void SelfTargetProcessControl::writeUInt64s(ArrayRef<tpctypes::UInt64Write> Ws,
-                                            WriteResultFn OnWriteComplete) {
-  for (auto &W : Ws)
-    *jitTargetAddressToPointer<uint64_t *>(W.Address) = W.Value;
-  OnWriteComplete(Error::success());
-}
-
-void SelfTargetProcessControl::writeBuffers(ArrayRef<tpctypes::BufferWrite> Ws,
-                                            WriteResultFn OnWriteComplete) {
-  for (auto &W : Ws)
-    memcpy(jitTargetAddressToPointer<char *>(W.Address), W.Buffer.data(),
-           W.Buffer.size());
-  OnWriteComplete(Error::success());
-}
-
-} // end namespace orc
-} // end namespace llvm