LLVM  14.0.0git
OrcRemoteTargetClient.h
Go to the documentation of this file.
1 //===- OrcRemoteTargetClient.h - Orc Remote-target Client -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the OrcRemoteTargetClient class and helpers. This class
10 // can be used to communicate over an RawByteChannel with an
11 // OrcRemoteTargetServer instance to support remote-JITing.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
16 #define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
17 
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
27 #include "llvm/Support/Debug.h"
28 #include "llvm/Support/Error.h"
30 #include "llvm/Support/Format.h"
32 #include "llvm/Support/Memory.h"
34 #include <algorithm>
35 #include <cassert>
36 #include <cstdint>
37 #include <memory>
38 #include <string>
39 #include <tuple>
40 #include <utility>
41 #include <vector>
42 
43 #define DEBUG_TYPE "orc-remote"
44 
45 namespace llvm {
46 namespace orc {
47 namespace remote {
48 
49 /// This class provides utilities (including memory manager, indirect stubs
50 /// manager, and compile callback manager types) that support remote JITing
51 /// in ORC.
52 ///
53 /// Each of the utility classes talks to a JIT server (an instance of the
54 /// OrcRemoteTargetServer class) via an RPC system (see RPCUtils.h) to carry out
55 /// its actions.
57  : public shared::SingleThreadedRPCEndpoint<shared::RawByteChannel> {
58 public:
59  /// Remote-mapped RuntimeDyld-compatible memory manager.
61  friend class OrcRemoteTargetClient;
62 
63  public:
65  Client.destroyRemoteAllocator(Id);
66  LLVM_DEBUG(dbgs() << "Destroyed remote allocator " << Id << "\n");
67  }
68 
71  operator=(const RemoteRTDyldMemoryManager &) = delete;
74 
75  uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
76  unsigned SectionID,
77  StringRef SectionName) override {
78  Unmapped.back().CodeAllocs.emplace_back(Size, Alignment);
79  uint8_t *Alloc = reinterpret_cast<uint8_t *>(
80  Unmapped.back().CodeAllocs.back().getLocalAddress());
81  LLVM_DEBUG(dbgs() << "Allocator " << Id << " allocated code for "
82  << SectionName << ": " << Alloc << " (" << Size
83  << " bytes, alignment " << Alignment << ")\n");
84  return Alloc;
85  }
86 
87  uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
88  unsigned SectionID, StringRef SectionName,
89  bool IsReadOnly) override {
90  if (IsReadOnly) {
91  Unmapped.back().RODataAllocs.emplace_back(Size, Alignment);
92  uint8_t *Alloc = reinterpret_cast<uint8_t *>(
93  Unmapped.back().RODataAllocs.back().getLocalAddress());
94  LLVM_DEBUG(dbgs() << "Allocator " << Id << " allocated ro-data for "
95  << SectionName << ": " << Alloc << " (" << Size
96  << " bytes, alignment " << Alignment << ")\n");
97  return Alloc;
98  } // else...
99 
100  Unmapped.back().RWDataAllocs.emplace_back(Size, Alignment);
101  uint8_t *Alloc = reinterpret_cast<uint8_t *>(
102  Unmapped.back().RWDataAllocs.back().getLocalAddress());
103  LLVM_DEBUG(dbgs() << "Allocator " << Id << " allocated rw-data for "
104  << SectionName << ": " << Alloc << " (" << Size
105  << " bytes, alignment " << Alignment << ")\n");
106  return Alloc;
107  }
108 
109  void reserveAllocationSpace(uintptr_t CodeSize, uint32_t CodeAlign,
110  uintptr_t RODataSize, uint32_t RODataAlign,
111  uintptr_t RWDataSize,
112  uint32_t RWDataAlign) override {
113  Unmapped.push_back(ObjectAllocs());
114 
115  LLVM_DEBUG(dbgs() << "Allocator " << Id << " reserved:\n");
116 
117  if (CodeSize != 0) {
118  Unmapped.back().RemoteCodeAddr =
119  Client.reserveMem(Id, CodeSize, CodeAlign);
120 
121  LLVM_DEBUG(
122  dbgs() << " code: "
123  << format("0x%016" PRIx64, Unmapped.back().RemoteCodeAddr)
124  << " (" << CodeSize << " bytes, alignment " << CodeAlign
125  << ")\n");
126  }
127 
128  if (RODataSize != 0) {
129  Unmapped.back().RemoteRODataAddr =
130  Client.reserveMem(Id, RODataSize, RODataAlign);
131 
132  LLVM_DEBUG(
133  dbgs() << " ro-data: "
134  << format("0x%016" PRIx64, Unmapped.back().RemoteRODataAddr)
135  << " (" << RODataSize << " bytes, alignment " << RODataAlign
136  << ")\n");
137  }
138 
139  if (RWDataSize != 0) {
140  Unmapped.back().RemoteRWDataAddr =
141  Client.reserveMem(Id, RWDataSize, RWDataAlign);
142 
143  LLVM_DEBUG(
144  dbgs() << " rw-data: "
145  << format("0x%016" PRIx64, Unmapped.back().RemoteRWDataAddr)
146  << " (" << RWDataSize << " bytes, alignment " << RWDataAlign
147  << ")\n");
148  }
149  }
150 
151  bool needsToReserveAllocationSpace() override { return true; }
152 
153  void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr,
154  size_t Size) override {
155  UnfinalizedEHFrames.push_back({LoadAddr, Size});
156  }
157 
158  void deregisterEHFrames() override {
159  for (auto &Frame : RegisteredEHFrames) {
160  // FIXME: Add error poll.
161  Client.deregisterEHFrames(Frame.Addr, Frame.Size);
162  }
163  }
164 
166  const object::ObjectFile &Obj) override {
167  LLVM_DEBUG(dbgs() << "Allocator " << Id << " applied mappings:\n");
168  for (auto &ObjAllocs : Unmapped) {
169  mapAllocsToRemoteAddrs(Dyld, ObjAllocs.CodeAllocs,
170  ObjAllocs.RemoteCodeAddr);
171  mapAllocsToRemoteAddrs(Dyld, ObjAllocs.RODataAllocs,
172  ObjAllocs.RemoteRODataAddr);
173  mapAllocsToRemoteAddrs(Dyld, ObjAllocs.RWDataAllocs,
174  ObjAllocs.RemoteRWDataAddr);
175  Unfinalized.push_back(std::move(ObjAllocs));
176  }
177  Unmapped.clear();
178  }
179 
180  bool finalizeMemory(std::string *ErrMsg = nullptr) override {
181  LLVM_DEBUG(dbgs() << "Allocator " << Id << " finalizing:\n");
182 
183  for (auto &ObjAllocs : Unfinalized) {
184  if (copyAndProtect(ObjAllocs.CodeAllocs, ObjAllocs.RemoteCodeAddr,
186  return true;
187 
188  if (copyAndProtect(ObjAllocs.RODataAllocs, ObjAllocs.RemoteRODataAddr,
190  return true;
191 
192  if (copyAndProtect(ObjAllocs.RWDataAllocs, ObjAllocs.RemoteRWDataAddr,
194  return true;
195  }
196  Unfinalized.clear();
197 
198  for (auto &EHFrame : UnfinalizedEHFrames) {
199  if (auto Err = Client.registerEHFrames(EHFrame.Addr, EHFrame.Size)) {
200  // FIXME: Replace this once finalizeMemory can return an Error.
201  handleAllErrors(std::move(Err), [&](ErrorInfoBase &EIB) {
202  if (ErrMsg) {
203  raw_string_ostream ErrOut(*ErrMsg);
204  EIB.log(ErrOut);
205  }
206  });
207  return false;
208  }
209  }
210  RegisteredEHFrames = std::move(UnfinalizedEHFrames);
211  UnfinalizedEHFrames = {};
212 
213  return false;
214  }
215 
216  private:
217  class Alloc {
218  public:
219  Alloc(uint64_t Size, unsigned Align)
220  : Size(Size), Align(Align), Contents(new char[Size + Align - 1]) {}
221 
222  Alloc(const Alloc &) = delete;
223  Alloc &operator=(const Alloc &) = delete;
224  Alloc(Alloc &&) = default;
225  Alloc &operator=(Alloc &&) = default;
226 
227  uint64_t getSize() const { return Size; }
228 
229  unsigned getAlign() const { return Align; }
230 
231  char *getLocalAddress() const {
232  uintptr_t LocalAddr = reinterpret_cast<uintptr_t>(Contents.get());
233  LocalAddr = alignTo(LocalAddr, Align);
234  return reinterpret_cast<char *>(LocalAddr);
235  }
236 
237  void setRemoteAddress(JITTargetAddress RemoteAddr) {
238  this->RemoteAddr = RemoteAddr;
239  }
240 
241  JITTargetAddress getRemoteAddress() const { return RemoteAddr; }
242 
243  private:
244  uint64_t Size;
245  unsigned Align;
246  std::unique_ptr<char[]> Contents;
247  JITTargetAddress RemoteAddr = 0;
248  };
249 
250  struct ObjectAllocs {
251  ObjectAllocs() = default;
252  ObjectAllocs(const ObjectAllocs &) = delete;
253  ObjectAllocs &operator=(const ObjectAllocs &) = delete;
254  ObjectAllocs(ObjectAllocs &&) = default;
255  ObjectAllocs &operator=(ObjectAllocs &&) = default;
256 
257  JITTargetAddress RemoteCodeAddr = 0;
258  JITTargetAddress RemoteRODataAddr = 0;
259  JITTargetAddress RemoteRWDataAddr = 0;
260  std::vector<Alloc> CodeAllocs, RODataAllocs, RWDataAllocs;
261  };
262 
265  : Client(Client), Id(Id) {
266  LLVM_DEBUG(dbgs() << "Created remote allocator " << Id << "\n");
267  }
268 
269  // Maps all allocations in Allocs to aligned blocks
270  void mapAllocsToRemoteAddrs(RuntimeDyld &Dyld, std::vector<Alloc> &Allocs,
271  JITTargetAddress NextAddr) {
272  for (auto &Alloc : Allocs) {
273  NextAddr = alignTo(NextAddr, Alloc.getAlign());
274  Dyld.mapSectionAddress(Alloc.getLocalAddress(), NextAddr);
275  LLVM_DEBUG(
276  dbgs() << " " << static_cast<void *>(Alloc.getLocalAddress())
277  << " -> " << format("0x%016" PRIx64, NextAddr) << "\n");
278  Alloc.setRemoteAddress(NextAddr);
279 
280  // Only advance NextAddr if it was non-null to begin with,
281  // otherwise leave it as null.
282  if (NextAddr)
283  NextAddr += Alloc.getSize();
284  }
285  }
286 
287  // Copies data for each alloc in the list, then set permissions on the
288  // segment.
289  bool copyAndProtect(const std::vector<Alloc> &Allocs,
290  JITTargetAddress RemoteSegmentAddr,
291  unsigned Permissions) {
292  if (RemoteSegmentAddr) {
293  assert(!Allocs.empty() && "No sections in allocated segment");
294 
295  for (auto &Alloc : Allocs) {
296  LLVM_DEBUG(dbgs() << " copying section: "
297  << static_cast<void *>(Alloc.getLocalAddress())
298  << " -> "
299  << format("0x%016" PRIx64, Alloc.getRemoteAddress())
300  << " (" << Alloc.getSize() << " bytes)\n";);
301 
302  if (Client.writeMem(Alloc.getRemoteAddress(), Alloc.getLocalAddress(),
303  Alloc.getSize()))
304  return true;
305  }
306 
307  LLVM_DEBUG(dbgs() << " setting "
308  << (Permissions & sys::Memory::MF_READ ? 'R' : '-')
309  << (Permissions & sys::Memory::MF_WRITE ? 'W' : '-')
310  << (Permissions & sys::Memory::MF_EXEC ? 'X' : '-')
311  << " permissions on block: "
312  << format("0x%016" PRIx64, RemoteSegmentAddr)
313  << "\n");
314  if (Client.setProtections(Id, RemoteSegmentAddr, Permissions))
315  return true;
316  }
317  return false;
318  }
319 
320  OrcRemoteTargetClient &Client;
322  std::vector<ObjectAllocs> Unmapped;
323  std::vector<ObjectAllocs> Unfinalized;
324 
325  struct EHFrame {
327  uint64_t Size;
328  };
329  std::vector<EHFrame> UnfinalizedEHFrames;
330  std::vector<EHFrame> RegisteredEHFrames;
331  };
332 
335  using FinalizeContinuation =
338  using SegmentsRequestMap =
340 
342  : Client(Client), Id(Id) {}
343 
344  public:
347  const SegmentsRequestMap &Request) {
348  auto *MM = new RPCMMAlloc(Client, Id);
349 
350  if (Error Err = MM->allocateHostBlocks(Request))
351  return std::move(Err);
352 
353  if (Error Err = MM->allocateTargetBlocks())
354  return std::move(Err);
355 
356  return std::unique_ptr<RPCMMAlloc>(MM);
357  }
358 
360  assert(HostSegBlocks.count(Seg) && "No allocation for segment");
361  return {static_cast<char *>(HostSegBlocks[Seg].base()),
362  HostSegBlocks[Seg].allocatedSize()};
363  }
364 
366  assert(TargetSegBlocks.count(Seg) && "No allocation for segment");
367  return pointerToJITTargetAddress(TargetSegBlocks[Seg].base());
368  }
369 
370  void finalizeAsync(FinalizeContinuation OnFinalize) override {
371  // Host allocations (working memory) remain ReadWrite.
372  OnFinalize(copyAndProtect());
373  }
374 
375  Error deallocate() override {
376  // TODO: Cannot release target allocation. RPCAPI has no function
377  // symmetric to reserveMem(). Add RPC call like freeMem()?
378  return errorCodeToError(sys::Memory::releaseMappedMemory(HostAllocation));
379  }
380 
381  private:
382  OrcRemoteTargetClient &Client;
384  AllocationMap HostSegBlocks;
385  AllocationMap TargetSegBlocks;
386  JITTargetAddress TargetSegmentAddr;
387  sys::MemoryBlock HostAllocation;
388 
389  Error allocateHostBlocks(const SegmentsRequestMap &Request) {
390  unsigned TargetPageSize = Client.getPageSize();
391 
392  if (!isPowerOf2_64(static_cast<uint64_t>(TargetPageSize)))
393  return make_error<StringError>("Host page size is not a power of 2",
395 
396  auto TotalSize = calcTotalAllocSize(Request, TargetPageSize);
397  if (!TotalSize)
398  return TotalSize.takeError();
399 
400  // Allocate one slab to cover all the segments.
401  const sys::Memory::ProtectionFlags ReadWrite =
404  std::error_code EC;
405  HostAllocation =
406  sys::Memory::allocateMappedMemory(*TotalSize, nullptr, ReadWrite, EC);
407  if (EC)
408  return errorCodeToError(EC);
409 
410  char *SlabAddr = static_cast<char *>(HostAllocation.base());
411 #ifndef NDEBUG
412  char *SlabAddrEnd = SlabAddr + HostAllocation.allocatedSize();
413 #endif
414 
415  // Allocate segment memory from the slab.
416  for (auto &KV : Request) {
417  const auto &Seg = KV.second;
418 
419  uint64_t SegmentSize = Seg.getContentSize() + Seg.getZeroFillSize();
420  uint64_t AlignedSegmentSize = alignTo(SegmentSize, TargetPageSize);
421 
422  // Zero out zero-fill memory.
423  char *ZeroFillBegin = SlabAddr + Seg.getContentSize();
424  memset(ZeroFillBegin, 0, Seg.getZeroFillSize());
425 
426  // Record the block for this segment.
427  HostSegBlocks[KV.first] =
428  sys::MemoryBlock(SlabAddr, AlignedSegmentSize);
429 
430  SlabAddr += AlignedSegmentSize;
431  assert(SlabAddr <= SlabAddrEnd && "Out of range");
432  }
433 
434  return Error::success();
435  }
436 
437  Error allocateTargetBlocks() {
438  // Reserve memory for all blocks on the target. We need as much space on
439  // the target as we allocated on the host.
440  TargetSegmentAddr = Client.reserveMem(Id, HostAllocation.allocatedSize(),
441  Client.getPageSize());
442  if (!TargetSegmentAddr)
443  return make_error<StringError>("Failed to reserve memory on the target",
445 
446  // Map memory blocks into the allocation, that match the host allocation.
447  JITTargetAddress TargetAllocAddr = TargetSegmentAddr;
448  for (const auto &KV : HostSegBlocks) {
449  size_t TargetAllocSize = KV.second.allocatedSize();
450 
451  TargetSegBlocks[KV.first] =
452  sys::MemoryBlock(jitTargetAddressToPointer<void *>(TargetAllocAddr),
453  TargetAllocSize);
454 
455  TargetAllocAddr += TargetAllocSize;
456  assert(TargetAllocAddr - TargetSegmentAddr <=
457  HostAllocation.allocatedSize() &&
458  "Out of range on target");
459  }
460 
461  return Error::success();
462  }
463 
464  Error copyAndProtect() {
465  unsigned Permissions = 0u;
466 
467  // Copy segments one by one.
468  for (auto &KV : TargetSegBlocks) {
469  Permissions |= KV.first;
470 
471  const sys::MemoryBlock &TargetBlock = KV.second;
472  const sys::MemoryBlock &HostBlock = HostSegBlocks.lookup(KV.first);
473 
474  size_t TargetAllocSize = TargetBlock.allocatedSize();
475  auto TargetAllocAddr = pointerToJITTargetAddress(TargetBlock.base());
476  auto *HostAllocBegin = static_cast<const char *>(HostBlock.base());
477 
478  bool CopyErr =
479  Client.writeMem(TargetAllocAddr, HostAllocBegin, TargetAllocSize);
480  if (CopyErr)
482  "Failed to copy %d segment to the target",
483  KV.first);
484  }
485 
486  // Set permission flags for all segments at once.
487  bool ProtectErr =
488  Client.setProtections(Id, TargetSegmentAddr, Permissions);
489  if (ProtectErr)
491  "Failed to apply permissions for %d segment "
492  "on the target",
493  Permissions);
494  return Error::success();
495  }
496 
497  static Expected<size_t>
498  calcTotalAllocSize(const SegmentsRequestMap &Request,
499  unsigned TargetPageSize) {
500  size_t TotalSize = 0;
501  for (const auto &KV : Request) {
502  const auto &Seg = KV.second;
503 
504  if (Seg.getAlignment() > TargetPageSize)
505  return make_error<StringError>("Cannot request alignment higher than "
506  "page alignment on target",
508 
509  TotalSize = alignTo(TotalSize, TargetPageSize);
510  TotalSize += Seg.getContentSize();
511  TotalSize += Seg.getZeroFillSize();
512  }
513 
514  return TotalSize;
515  }
516  };
517 
519  public:
522  : Client(Client), Id(Id) {}
523 
526 
528  operator=(const RemoteJITLinkMemoryManager &) = delete;
531 
533  Client.destroyRemoteAllocator(Id);
534  LLVM_DEBUG(dbgs() << "Destroyed remote allocator " << Id << "\n");
535  }
536 
539  const SegmentsRequestMap &Request) override {
540  return RPCMMAlloc::Create(Client, Id, Request);
541  }
542 
543  private:
544  OrcRemoteTargetClient &Client;
546  };
547 
548  /// Remote indirect stubs manager.
550  public:
553  : Client(Client), Id(Id) {}
554 
556  Client.destroyIndirectStubsManager(Id);
557  }
558 
560  JITSymbolFlags StubFlags) override {
561  if (auto Err = reserveStubs(1))
562  return Err;
563 
564  return createStubInternal(StubName, StubAddr, StubFlags);
565  }
566 
567  Error createStubs(const StubInitsMap &StubInits) override {
568  if (auto Err = reserveStubs(StubInits.size()))
569  return Err;
570 
571  for (auto &Entry : StubInits)
572  if (auto Err = createStubInternal(Entry.first(), Entry.second.first,
573  Entry.second.second))
574  return Err;
575 
576  return Error::success();
577  }
578 
579  JITEvaluatedSymbol findStub(StringRef Name, bool ExportedStubsOnly) override {
580  auto I = StubIndexes.find(Name);
581  if (I == StubIndexes.end())
582  return nullptr;
583  auto Key = I->second.first;
584  auto Flags = I->second.second;
585  auto StubSymbol = JITEvaluatedSymbol(getStubAddr(Key), Flags);
586  if (ExportedStubsOnly && !StubSymbol.getFlags().isExported())
587  return nullptr;
588  return StubSymbol;
589  }
590 
592  auto I = StubIndexes.find(Name);
593  if (I == StubIndexes.end())
594  return nullptr;
595  auto Key = I->second.first;
596  auto Flags = I->second.second;
597  return JITEvaluatedSymbol(getPtrAddr(Key), Flags);
598  }
599 
601  auto I = StubIndexes.find(Name);
602  assert(I != StubIndexes.end() && "No stub pointer for symbol");
603  auto Key = I->second.first;
604  return Client.writePointer(getPtrAddr(Key), NewAddr);
605  }
606 
607  private:
608  struct RemoteIndirectStubsInfo {
609  JITTargetAddress StubBase;
610  JITTargetAddress PtrBase;
611  unsigned NumStubs;
612  };
613 
614  using StubKey = std::pair<uint16_t, uint16_t>;
615 
616  Error reserveStubs(unsigned NumStubs) {
617  if (NumStubs <= FreeStubs.size())
618  return Error::success();
619 
620  unsigned NewStubsRequired = NumStubs - FreeStubs.size();
621  JITTargetAddress StubBase;
622  JITTargetAddress PtrBase;
623  unsigned NumStubsEmitted;
624 
625  if (auto StubInfoOrErr = Client.emitIndirectStubs(Id, NewStubsRequired))
626  std::tie(StubBase, PtrBase, NumStubsEmitted) = *StubInfoOrErr;
627  else
628  return StubInfoOrErr.takeError();
629 
630  unsigned NewBlockId = RemoteIndirectStubsInfos.size();
631  RemoteIndirectStubsInfos.push_back({StubBase, PtrBase, NumStubsEmitted});
632 
633  for (unsigned I = 0; I < NumStubsEmitted; ++I)
634  FreeStubs.push_back(std::make_pair(NewBlockId, I));
635 
636  return Error::success();
637  }
638 
639  Error createStubInternal(StringRef StubName, JITTargetAddress InitAddr,
640  JITSymbolFlags StubFlags) {
641  auto Key = FreeStubs.back();
642  FreeStubs.pop_back();
643  StubIndexes[StubName] = std::make_pair(Key, StubFlags);
644  return Client.writePointer(getPtrAddr(Key), InitAddr);
645  }
646 
647  JITTargetAddress getStubAddr(StubKey K) {
648  assert(RemoteIndirectStubsInfos[K.first].StubBase != 0 &&
649  "Missing stub address");
650  return RemoteIndirectStubsInfos[K.first].StubBase +
651  K.second * Client.getIndirectStubSize();
652  }
653 
654  JITTargetAddress getPtrAddr(StubKey K) {
655  assert(RemoteIndirectStubsInfos[K.first].PtrBase != 0 &&
656  "Missing pointer address");
657  return RemoteIndirectStubsInfos[K.first].PtrBase +
658  K.second * Client.getPointerSize();
659  }
660 
661  OrcRemoteTargetClient &Client;
663  std::vector<RemoteIndirectStubsInfo> RemoteIndirectStubsInfos;
664  std::vector<StubKey> FreeStubs;
665  StringMap<std::pair<StubKey, JITSymbolFlags>> StubIndexes;
666  };
667 
669  public:
670  RemoteTrampolinePool(OrcRemoteTargetClient &Client) : Client(Client) {}
671 
672  private:
673  Error grow() override {
674  JITTargetAddress BlockAddr = 0;
675  uint32_t NumTrampolines = 0;
676  if (auto TrampolineInfoOrErr = Client.emitTrampolineBlock())
677  std::tie(BlockAddr, NumTrampolines) = *TrampolineInfoOrErr;
678  else
679  return TrampolineInfoOrErr.takeError();
680 
681  uint32_t TrampolineSize = Client.getTrampolineSize();
682  for (unsigned I = 0; I < NumTrampolines; ++I)
683  AvailableTrampolines.push_back(BlockAddr + (I * TrampolineSize));
684 
685  return Error::success();
686  }
687 
688  OrcRemoteTargetClient &Client;
689  };
690 
691  /// Remote compile callback manager.
693  public:
695  ExecutionSession &ES,
696  JITTargetAddress ErrorHandlerAddress)
698  std::make_unique<RemoteTrampolinePool>(Client), ES,
699  ErrorHandlerAddress) {}
700  };
701 
702  /// Create an OrcRemoteTargetClient.
703  /// Channel is the ChannelT instance to communicate on. It is assumed that
704  /// the channel is ready to be read from and written to.
707  Error Err = Error::success();
708  auto Client = std::unique_ptr<OrcRemoteTargetClient>(
709  new OrcRemoteTargetClient(Channel, ES, Err));
710  if (Err)
711  return std::move(Err);
712  return std::move(Client);
713  }
714 
715  /// Call the int(void) function at the given address in the target and return
716  /// its result.
718  LLVM_DEBUG(dbgs() << "Calling int(*)(void) "
719  << format("0x%016" PRIx64, Addr) << "\n");
720  return callB<exec::CallIntVoid>(Addr);
721  }
722 
723  /// Call the int(int) function at the given address in the target and return
724  /// its result.
726  LLVM_DEBUG(dbgs() << "Calling int(*)(int) " << format("0x%016" PRIx64, Addr)
727  << "\n");
728  return callB<exec::CallIntInt>(Addr, Arg);
729  }
730 
731  /// Call the int(int, char*[]) function at the given address in the target and
732  /// return its result.
734  const std::vector<std::string> &Args) {
735  LLVM_DEBUG(dbgs() << "Calling int(*)(int, char*[]) "
736  << format("0x%016" PRIx64, Addr) << "\n");
737  return callB<exec::CallMain>(Addr, Args);
738  }
739 
740  /// Call the void() function at the given address in the target and wait for
741  /// it to finish.
743  LLVM_DEBUG(dbgs() << "Calling void(*)(void) "
744  << format("0x%016" PRIx64, Addr) << "\n");
745  return callB<exec::CallVoidVoid>(Addr);
746  }
747 
748  /// Create an RCMemoryManager which will allocate its memory on the remote
749  /// target.
752  auto Id = AllocatorIds.getNext();
753  if (auto Err = callB<mem::CreateRemoteAllocator>(Id))
754  return std::move(Err);
755  return std::unique_ptr<RemoteRTDyldMemoryManager>(
756  new RemoteRTDyldMemoryManager(*this, Id));
757  }
758 
759  /// Create a JITLink-compatible memory manager which will allocate working
760  /// memory on the host and target memory on the remote target.
763  auto Id = AllocatorIds.getNext();
764  if (auto Err = callB<mem::CreateRemoteAllocator>(Id))
765  return std::move(Err);
766  LLVM_DEBUG(dbgs() << "Created remote allocator " << Id << "\n");
767  return std::unique_ptr<RemoteJITLinkMemoryManager>(
768  new RemoteJITLinkMemoryManager(*this, Id));
769  }
770 
771  /// Create an RCIndirectStubsManager that will allocate stubs on the remote
772  /// target.
775  auto Id = IndirectStubOwnerIds.getNext();
776  if (auto Err = callB<stubs::CreateIndirectStubsOwner>(Id))
777  return std::move(Err);
778  return std::make_unique<RemoteIndirectStubsManager>(*this, Id);
779  }
780 
783  assert(!CallbackManager && "CallbackManager already obtained");
784 
785  // Emit the resolver block on the JIT server.
786  if (auto Err = callB<stubs::EmitResolverBlock>())
787  return std::move(Err);
788 
789  // Create the callback manager.
790  CallbackManager.emplace(*this, ES, ErrorHandlerAddress);
791  RemoteCompileCallbackManager &Mgr = *CallbackManager;
792  return Mgr;
793  }
794 
795  /// Search for symbols in the remote process. Note: This should be used by
796  /// symbol resolvers *after* they've searched the local symbol table in the
797  /// JIT stack.
799  return callB<utils::GetSymbolAddress>(Name);
800  }
801 
802  /// Get the triple for the remote target.
803  const std::string &getTargetTriple() const { return RemoteTargetTriple; }
804 
805  Error terminateSession() { return callB<utils::TerminateSession>(); }
806 
807 private:
809  Error &Err)
810  : shared::SingleThreadedRPCEndpoint<shared::RawByteChannel>(Channel,
811  true),
812  ES(ES) {
813  ErrorAsOutParameter EAO(&Err);
814 
815  addHandler<utils::RequestCompile>(
817  if (CallbackManager)
818  return CallbackManager->executeCompileCallback(Addr);
819  return 0;
820  });
821 
822  if (auto RIOrErr = callB<utils::GetRemoteInfo>()) {
823  std::tie(RemoteTargetTriple, RemotePointerSize, RemotePageSize,
824  RemoteTrampolineSize, RemoteIndirectStubSize) = *RIOrErr;
825  Err = Error::success();
826  } else
827  Err = RIOrErr.takeError();
828  }
829 
830  void deregisterEHFrames(JITTargetAddress Addr, uint32_t Size) {
831  if (auto Err = callB<eh::RegisterEHFrames>(Addr, Size))
832  ES.reportError(std::move(Err));
833  }
834 
835  void destroyRemoteAllocator(ResourceIdMgr::ResourceId Id) {
836  if (auto Err = callB<mem::DestroyRemoteAllocator>(Id)) {
837  // FIXME: This will be triggered by a removeModuleSet call: Propagate
838  // error return up through that.
839  llvm_unreachable("Failed to destroy remote allocator.");
840  AllocatorIds.release(Id);
841  }
842  }
843 
844  void destroyIndirectStubsManager(ResourceIdMgr::ResourceId Id) {
845  IndirectStubOwnerIds.release(Id);
846  if (auto Err = callB<stubs::DestroyIndirectStubsOwner>(Id))
847  ES.reportError(std::move(Err));
848  }
849 
850  Expected<std::tuple<JITTargetAddress, JITTargetAddress, uint32_t>>
851  emitIndirectStubs(ResourceIdMgr::ResourceId Id, uint32_t NumStubsRequired) {
852  return callB<stubs::EmitIndirectStubs>(Id, NumStubsRequired);
853  }
854 
855  Expected<std::tuple<JITTargetAddress, uint32_t>> emitTrampolineBlock() {
856  return callB<stubs::EmitTrampolineBlock>();
857  }
858 
859  uint32_t getIndirectStubSize() const { return RemoteIndirectStubSize; }
860  uint32_t getPageSize() const { return RemotePageSize; }
861  uint32_t getPointerSize() const { return RemotePointerSize; }
862 
863  uint32_t getTrampolineSize() const { return RemoteTrampolineSize; }
864 
865  Expected<std::vector<uint8_t>> readMem(char *Dst, JITTargetAddress Src,
866  uint64_t Size) {
867  return callB<mem::ReadMem>(Src, Size);
868  }
869 
870  Error registerEHFrames(JITTargetAddress &RAddr, uint32_t Size) {
871  // FIXME: Duplicate error and report it via ReportError too?
872  return callB<eh::RegisterEHFrames>(RAddr, Size);
873  }
874 
876  uint32_t Align) {
877  if (auto AddrOrErr = callB<mem::ReserveMem>(Id, Size, Align))
878  return *AddrOrErr;
879  else {
880  ES.reportError(AddrOrErr.takeError());
881  return 0;
882  }
883  }
884 
885  bool setProtections(ResourceIdMgr::ResourceId Id,
886  JITTargetAddress RemoteSegAddr, unsigned ProtFlags) {
887  if (auto Err = callB<mem::SetProtections>(Id, RemoteSegAddr, ProtFlags)) {
888  ES.reportError(std::move(Err));
889  return true;
890  } else
891  return false;
892  }
893 
894  bool writeMem(JITTargetAddress Addr, const char *Src, uint64_t Size) {
895  if (auto Err = callB<mem::WriteMem>(DirectBufferWriter(Src, Addr, Size))) {
896  ES.reportError(std::move(Err));
897  return true;
898  } else
899  return false;
900  }
901 
902  Error writePointer(JITTargetAddress Addr, JITTargetAddress PtrVal) {
903  return callB<mem::WritePtr>(Addr, PtrVal);
904  }
905 
906  static Error doNothing() { return Error::success(); }
907 
908  ExecutionSession &ES;
909  std::function<void(Error)> ReportError;
910  std::string RemoteTargetTriple;
911  uint32_t RemotePointerSize = 0;
912  uint32_t RemotePageSize = 0;
913  uint32_t RemoteTrampolineSize = 0;
914  uint32_t RemoteIndirectStubSize = 0;
915  ResourceIdMgr AllocatorIds, IndirectStubOwnerIds;
916  Optional<RemoteCompileCallbackManager> CallbackManager;
917 };
918 
919 } // end namespace remote
920 } // end namespace orc
921 } // end namespace llvm
922 
923 #undef DEBUG_TYPE
924 
925 #endif // LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETCLIENT_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:148
llvm::ErrorInfoBase::log
virtual void log(raw_ostream &OS) const =0
Print an error message to an output stream.
llvm::sys::Memory::MF_READ
@ MF_READ
Definition: Memory.h:55
llvm::orc::remote::OrcRemoteTargetClient::RemoteIndirectStubsManager::updatePointer
Error updatePointer(StringRef Name, JITTargetAddress NewAddr) override
Change the value of the implementation pointer for the stub.
Definition: OrcRemoteTargetClient.h:600
MathExtras.h
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::sys::Memory::MF_WRITE
@ MF_WRITE
Definition: Memory.h:56
llvm::orc::remote::OrcRemoteTargetClient
This class provides utilities (including memory manager, indirect stubs manager, and compile callback...
Definition: OrcRemoteTargetClient.h:56
llvm::orc::remote::OrcRemoteTargetClient::RPCMMAlloc::getWorkingMemory
MutableArrayRef< char > getWorkingMemory(ProtectionFlags Seg) override
Should return the address of linker working memory for the segment with the given protection flags.
Definition: OrcRemoteTargetClient.h:359
llvm::orc::remote::OrcRemoteTargetClient::createRemoteMemoryManager
Expected< std::unique_ptr< RemoteRTDyldMemoryManager > > createRemoteMemoryManager()
Create an RCMemoryManager which will allocate its memory on the remote target.
Definition: OrcRemoteTargetClient.h:751
JITSymbol.h
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::orc::remote::OrcRemoteTargetClient::RemoteTrampolinePool
Definition: OrcRemoteTargetClient.h:668
llvm::orc::remote::OrcRemoteTargetClient::RemoteIndirectStubsManager
Remote indirect stubs manager.
Definition: OrcRemoteTargetClient.h:549
Optional.h
llvm::orc::ExecutionSession::reportError
void reportError(Error Err)
Report a error for this execution session.
Definition: Core.h:1371
StringRef.h
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:625
llvm::orc::IndirectStubsManager
Base class for managing collections of named indirect stubs.
Definition: IndirectionUtils.h:275
ErrorHandling.h
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::sys::Memory::allocateMappedMemory
static MemoryBlock allocateMappedMemory(size_t NumBytes, const MemoryBlock *const NearBlock, unsigned Flags, std::error_code &EC)
This method allocates a block of memory that is suitable for loading dynamically generated code (e....
Error.h
llvm::sys::Memory::releaseMappedMemory
static std::error_code releaseMappedMemory(MemoryBlock &Block)
This method releases a block of memory that was allocated with the allocateMappedMemory method.
llvm::orc::remote::OrcRemoteTargetClient::RemoteJITLinkMemoryManager
Definition: OrcRemoteTargetClient.h:518
llvm::sys::MemoryBlock
This class encapsulates the notion of a memory block which has an address and a size.
Definition: Memory.h:31
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::notifyObjectLoaded
void notifyObjectLoaded(RuntimeDyld &Dyld, const object::ObjectFile &Obj) override
This method is called after an object has been loaded into memory but before relocations are applied ...
Definition: OrcRemoteTargetClient.h:165
llvm::DenseMapBase::count
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:145
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
STLExtras.h
Format.h
RuntimeDyld.h
llvm::JITSymbolFlags
Flags for symbols in the JIT.
Definition: JITSymbol.h:74
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
new
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj * new
Definition: README.txt:125
llvm::JITEvaluatedSymbol
Represents a symbol that has been evaluated to an address already.
Definition: JITSymbol.h:229
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::orc::remote::OrcRemoteTargetClient::RPCMMAlloc::deallocate
Error deallocate() override
Should deallocate target memory.
Definition: OrcRemoteTargetClient.h:375
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:206
llvm::orc::remote::OrcRemoteTargetClient::callMain
Expected< int > callMain(JITTargetAddress Addr, const std::vector< std::string > &Args)
Call the int(int, char*[]) function at the given address in the target and return its result.
Definition: OrcRemoteTargetClient.h:733
llvm::orc::shared::SingleThreadedRPCEndpoint< shared::RawByteChannel >::SingleThreadedRPCEndpoint
SingleThreadedRPCEndpoint(shared::RawByteChannel &C, bool LazyAutoNegotiation)
Definition: RPCUtils.h:1470
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
llvm::orc::remote::OrcRemoteTargetClient::RemoteIndirectStubsManager::createStub
Error createStub(StringRef StubName, JITTargetAddress StubAddr, JITSymbolFlags StubFlags) override
Create a single stub with the given name, target address and flags.
Definition: OrcRemoteTargetClient.h:559
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::reserveAllocationSpace
void reserveAllocationSpace(uintptr_t CodeSize, uint32_t CodeAlign, uintptr_t RODataSize, uint32_t RODataAlign, uintptr_t RWDataSize, uint32_t RWDataAlign) override
Inform the memory manager about the total amount of memory required to allocate all sections to be lo...
Definition: OrcRemoteTargetClient.h:109
llvm::orc::JITCompileCallbackManager
Target-independent base class for compile callback management.
Definition: IndirectionUtils.h:196
llvm::errorCodeToError
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
Definition: Error.cpp:87
llvm::sys::Memory::ProtectionFlags
ProtectionFlags
Definition: Memory.h:54
llvm::orc::shared::SingleThreadedRPCEndpoint
Definition: RPCUtils.h:1460
llvm::orc::remote::OrcRemoteTargetClient::callIntVoid
Expected< int > callIntVoid(JITTargetAddress Addr)
Call the int(void) function at the given address in the target and return its result.
Definition: OrcRemoteTargetClient.h:717
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:481
llvm::orc::TrampolinePool
Base class for pools of compiler re-entry trampolines.
Definition: IndirectionUtils.h:56
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::registerEHFrames
void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) override
Register the EH frames with the runtime so that c++ exceptions work.
Definition: OrcRemoteTargetClient.h:153
llvm::orc::remote::OrcRemoteTargetClient::RPCMMAlloc::finalizeAsync
void finalizeAsync(FinalizeContinuation OnFinalize) override
Should transfer from working memory to target memory, and release working memory.
Definition: OrcRemoteTargetClient.h:370
llvm::ErrorAsOutParameter
Helper for Errors used as out-parameters.
Definition: Error.h:1089
llvm::orc::remote::OrcRemoteTargetClient::RemoteTrampolinePool::RemoteTrampolinePool
RemoteTrampolinePool(OrcRemoteTargetClient &Client)
Definition: OrcRemoteTargetClient.h:670
llvm::orc::remote::OrcRemoteTargetClient::RemoteIndirectStubsManager::findStub
JITEvaluatedSymbol findStub(StringRef Name, bool ExportedStubsOnly) override
Find the stub with the given name.
Definition: OrcRemoteTargetClient.h:579
llvm::sys::MemoryBlock::base
void * base() const
Definition: Memory.h:36
StringMap.h
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::orc::remote::OrcRemoteTargetClient::getTargetTriple
const std::string & getTargetTriple() const
Get the triple for the remote target.
Definition: OrcRemoteTargetClient.h:803
llvm::ErrorInfoBase
Base class for error info classes.
Definition: Error.h:48
llvm::StringMap
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:108
llvm::orc::remote::OrcRemoteTargetClient::RemoteJITLinkMemoryManager::RemoteJITLinkMemoryManager
RemoteJITLinkMemoryManager(OrcRemoteTargetClient &Client, ResourceIdMgr::ResourceId Id)
Definition: OrcRemoteTargetClient.h:520
llvm::sys::MemoryBlock::allocatedSize
size_t allocatedSize() const
The size as it was allocated.
Definition: Memory.h:39
llvm::sys::Memory::MF_EXEC
@ MF_EXEC
Definition: Memory.h:57
llvm::orc::remote::OrcRemoteTargetClient::RemoteJITLinkMemoryManager::~RemoteJITLinkMemoryManager
~RemoteJITLinkMemoryManager()
Definition: OrcRemoteTargetClient.h:532
llvm::orc::TrampolinePool::AvailableTrampolines
std::vector< JITTargetAddress > AvailableTrampolines
Definition: IndirectionUtils.h:91
uint64_t
llvm::orc::remote::ResourceIdMgr::release
void release(ResourceId I)
Definition: OrcRemoteTargetRPCAPI.h:158
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::needsToReserveAllocationSpace
bool needsToReserveAllocationSpace() override
Override to return true to enable the reserveAllocationSpace callback.
Definition: OrcRemoteTargetClient.h:151
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::finalizeMemory
bool finalizeMemory(std::string *ErrMsg=nullptr) override
This method is called when object loading is complete and section page permissions can be applied.
Definition: OrcRemoteTargetClient.h:180
llvm::DenseMap< unsigned, sys::MemoryBlock >
I
#define I(x, y, z)
Definition: MD5.cpp:59
OrcRemoteTargetRPCAPI.h
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::allocateDataSection
uint8_t * allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool IsReadOnly) override
Allocate a memory block of (at least) the given size suitable for data.
Definition: OrcRemoteTargetClient.h:87
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::orc::remote::OrcRemoteTargetClient::enableCompileCallbacks
Expected< RemoteCompileCallbackManager & > enableCompileCallbacks(JITTargetAddress ErrorHandlerAddress)
Definition: OrcRemoteTargetClient.h:782
llvm::orc::remote::OrcRemoteTargetClient::RemoteIndirectStubsManager::RemoteIndirectStubsManager
RemoteIndirectStubsManager(OrcRemoteTargetClient &Client, ResourceIdMgr::ResourceId Id)
Definition: OrcRemoteTargetClient.h:551
base
therefore end up llgh r3 lr r0 br r14 but truncating the load would lh r3 br r14 Functions ret i64 and ought to be implemented ngr r0 br r14 but two address optimizations reverse the order of the AND and ngr r2 lgr r0 br r14 CodeGen SystemZ and ll has several examples of this Out of range displacements are usually handled by loading the full address into a register In many cases it would be better to create an anchor point instead E g i64 base
Definition: README.txt:125
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager
Remote-mapped RuntimeDyld-compatible memory manager.
Definition: OrcRemoteTargetClient.h:60
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::orc::remote::OrcRemoteTargetClient::callVoidVoid
Error callVoidVoid(JITTargetAddress Addr)
Call the void() function at the given address in the target and wait for it to finish.
Definition: OrcRemoteTargetClient.h:742
llvm::StringMapImpl::size
unsigned size() const
Definition: StringMap.h:93
llvm::orc::shared::RawByteChannel
Interface for byte-streams to be used with ORC Serialization.
Definition: RawByteChannel.h:26
llvm::orc::remote::OrcRemoteTargetClient::RemoteCompileCallbackManager::RemoteCompileCallbackManager
RemoteCompileCallbackManager(OrcRemoteTargetClient &Client, ExecutionSession &ES, JITTargetAddress ErrorHandlerAddress)
Definition: OrcRemoteTargetClient.h:694
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::deregisterEHFrames
void deregisterEHFrames() override
Definition: OrcRemoteTargetClient.h:158
llvm::orc::remote::OrcRemoteTargetClient::RemoteIndirectStubsManager::~RemoteIndirectStubsManager
~RemoteIndirectStubsManager() override
Definition: OrcRemoteTargetClient.h:555
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:228
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::orc::remote::OrcRemoteTargetClient::RemoteIndirectStubsManager::createStubs
Error createStubs(const StubInitsMap &StubInits) override
Create StubInits.size() stubs with the given names, target addresses, and flags.
Definition: OrcRemoteTargetClient.h:567
llvm::orc::remote::OrcRemoteTargetClient::RPCMMAlloc::Create
static Expected< std::unique_ptr< RPCMMAlloc > > Create(OrcRemoteTargetClient &Client, ResourceIdMgr::ResourceId Id, const SegmentsRequestMap &Request)
Definition: OrcRemoteTargetClient.h:346
uint32_t
llvm::orc::remote::ResourceIdMgr::ResourceId
uint64_t ResourceId
Definition: OrcRemoteTargetRPCAPI.h:141
JITLinkMemoryManager.h
Memory.h
llvm::orc::remote::ResourceIdMgr::getNext
ResourceId getNext()
Definition: OrcRemoteTargetRPCAPI.h:148
llvm::format
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
Definition: Format.h:124
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::RemoteRTDyldMemoryManager
RemoteRTDyldMemoryManager(const RemoteRTDyldMemoryManager &)=delete
llvm::orc::remote::OrcRemoteTargetClient::Create
static Expected< std::unique_ptr< OrcRemoteTargetClient > > Create(shared::RawByteChannel &Channel, ExecutionSession &ES)
Create an OrcRemoteTargetClient.
Definition: OrcRemoteTargetClient.h:706
llvm::pointerToJITTargetAddress
JITTargetAddress pointerToJITTargetAddress(T *Ptr)
Convert a pointer to a JITTargetAddress.
Definition: JITSymbol.h:69
llvm::createStringError
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Definition: Error.h:1231
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:838
llvm::orc::remote::OrcRemoteTargetClient::terminateSession
Error terminateSession()
Definition: OrcRemoteTargetClient.h:805
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:77
llvm::SectionName
Definition: DWARFSection.h:21
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::~RemoteRTDyldMemoryManager
~RemoteRTDyldMemoryManager()
Definition: OrcRemoteTargetClient.h:64
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::allocateCodeSection
uint8_t * allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) override
Allocate a memory block of (at least) the given size suitable for executable code.
Definition: OrcRemoteTargetClient.h:75
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1275
llvm::orc::remote::OrcRemoteTargetClient::RPCMMAlloc::getTargetMemory
JITTargetAddress getTargetMemory(ProtectionFlags Seg) override
Should return the final address in the target process where the segment will reside.
Definition: OrcRemoteTargetClient.h:365
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::OrcRemoteTargetClient
friend class OrcRemoteTargetClient
Definition: OrcRemoteTargetClient.h:61
llvm::JITTargetAddress
uint64_t JITTargetAddress
Represents an address in the target process's address space.
Definition: JITSymbol.h:42
llvm::orc::remote::OrcRemoteTargetClient::callIntInt
Expected< int > callIntInt(JITTargetAddress Addr, int Arg)
Call the int(int) function at the given address in the target and return its result.
Definition: OrcRemoteTargetClient.h:725
llvm::getAlign
bool getAlign(const Function &F, unsigned index, unsigned &align)
Definition: NVPTXUtilities.cpp:284
llvm::orc::remote::OrcRemoteTargetClient::createRemoteJITLinkMemoryManager
Expected< std::unique_ptr< RemoteJITLinkMemoryManager > > createRemoteJITLinkMemoryManager()
Create a JITLink-compatible memory manager which will allocate working memory on the host and target ...
Definition: OrcRemoteTargetClient.h:762
llvm::orc::remote::OrcRemoteTargetClient::createIndirectStubsManager
Expected< std::unique_ptr< RemoteIndirectStubsManager > > createIndirectStubsManager()
Create an RCIndirectStubsManager that will allocate stubs on the remote target.
Definition: OrcRemoteTargetClient.h:774
llvm::orc::remote::OrcRemoteTargetClient::RemoteRTDyldMemoryManager::operator=
RemoteRTDyldMemoryManager & operator=(const RemoteRTDyldMemoryManager &)=delete
llvm::orc::remote::OrcRemoteTargetClient::RemoteCompileCallbackManager
Remote compile callback manager.
Definition: OrcRemoteTargetClient.h:692
llvm::RuntimeDyld::MemoryManager::RuntimeDyld
friend class RuntimeDyld
Definition: RuntimeDyld.h:93
IndirectionUtils.h
llvm::RuntimeDyld
Definition: RuntimeDyld.h:58
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::orc::remote::OrcRemoteTargetClient::RPCMMAlloc
Definition: OrcRemoteTargetClient.h:333
raw_ostream.h
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:228
llvm::orc::remote::OrcRemoteTargetClient::RemoteIndirectStubsManager::findPointer
JITEvaluatedSymbol findPointer(StringRef Name) override
Find the implementation-pointer for the stub.
Definition: OrcRemoteTargetClient.h:591
true
basic Basic Alias true
Definition: BasicAliasAnalysis.cpp:1857
llvm::isPowerOf2_64
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
Definition: MathExtras.h:496
llvm::handleAllErrors
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
Definition: Error.h:958
Debug.h
llvm::orc::remote::OrcRemoteTargetClient::RemoteJITLinkMemoryManager::allocate
Expected< std::unique_ptr< Allocation > > allocate(const jitlink::JITLinkDylib *JD, const SegmentsRequestMap &Request) override
Create an Allocation object.
Definition: OrcRemoteTargetClient.h:538
llvm::RuntimeDyld::MemoryManager
Memory Management.
Definition: RuntimeDyld.h:92
llvm::orc::remote::OrcRemoteTargetClient::RemoteJITLinkMemoryManager::operator=
RemoteJITLinkMemoryManager & operator=(const RemoteJITLinkMemoryManager &)=delete
llvm::orc::remote::OrcRemoteTargetClient::getSymbolAddress
Expected< JITTargetAddress > getSymbolAddress(StringRef Name)
Search for symbols in the remote process.
Definition: OrcRemoteTargetClient.h:798