LLVM  16.0.0git
ELFNixPlatform.cpp
Go to the documentation of this file.
1 //===------ ELFNixPlatform.cpp - Utilities for executing MachO in Orc -----===//
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 
10 
11 #include "llvm/BinaryFormat/ELF.h"
18 #include "llvm/Support/Debug.h"
19 #include <optional>
20 
21 #define DEBUG_TYPE "orc"
22 
23 using namespace llvm;
24 using namespace llvm::orc;
25 using namespace llvm::orc::shared;
26 
27 namespace {
28 
29 class DSOHandleMaterializationUnit : public MaterializationUnit {
30 public:
31  DSOHandleMaterializationUnit(ELFNixPlatform &ENP,
32  const SymbolStringPtr &DSOHandleSymbol)
34  createDSOHandleSectionInterface(ENP, DSOHandleSymbol)),
35  ENP(ENP) {}
36 
37  StringRef getName() const override { return "DSOHandleMU"; }
38 
39  void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
40  unsigned PointerSize;
42  jitlink::Edge::Kind EdgeKind;
43  const auto &TT =
45 
46  switch (TT.getArch()) {
47  case Triple::x86_64:
48  PointerSize = 8;
50  EdgeKind = jitlink::x86_64::Pointer64;
51  break;
52  case Triple::aarch64:
53  PointerSize = 8;
55  EdgeKind = jitlink::aarch64::Pointer64;
56  break;
57  default:
58  llvm_unreachable("Unrecognized architecture");
59  }
60 
61  // void *__dso_handle = &__dso_handle;
62  auto G = std::make_unique<jitlink::LinkGraph>(
63  "<DSOHandleMU>", TT, PointerSize, Endianness,
65  auto &DSOHandleSection =
66  G->createSection(".data.__dso_handle", MemProt::Read);
67  auto &DSOHandleBlock = G->createContentBlock(
68  DSOHandleSection, getDSOHandleContent(PointerSize), orc::ExecutorAddr(),
69  8, 0);
70  auto &DSOHandleSymbol = G->addDefinedSymbol(
71  DSOHandleBlock, 0, *R->getInitializerSymbol(), DSOHandleBlock.getSize(),
73  DSOHandleBlock.addEdge(EdgeKind, 0, DSOHandleSymbol, 0);
74 
76  }
77 
78  void discard(const JITDylib &JD, const SymbolStringPtr &Sym) override {}
79 
80 private:
82  createDSOHandleSectionInterface(ELFNixPlatform &ENP,
83  const SymbolStringPtr &DSOHandleSymbol) {
85  SymbolFlags[DSOHandleSymbol] = JITSymbolFlags::Exported;
87  DSOHandleSymbol);
88  }
89 
90  ArrayRef<char> getDSOHandleContent(size_t PointerSize) {
91  static const char Content[8] = {0};
92  assert(PointerSize <= sizeof Content);
93  return {Content, PointerSize};
94  }
95 
96  ELFNixPlatform &ENP;
97 };
98 
99 StringRef EHFrameSectionName = ".eh_frame";
100 StringRef InitArrayFuncSectionName = ".init_array";
101 
102 StringRef ThreadBSSSectionName = ".tbss";
103 StringRef ThreadDataSectionName = ".tdata";
104 
105 } // end anonymous namespace
106 
107 namespace llvm {
108 namespace orc {
109 
112  ObjectLinkingLayer &ObjLinkingLayer,
113  JITDylib &PlatformJD, const char *OrcRuntimePath,
114  Optional<SymbolAliasMap> RuntimeAliases) {
115 
116  auto &EPC = ES.getExecutorProcessControl();
117 
118  // If the target is not supported then bail out immediately.
119  if (!supportedTarget(EPC.getTargetTriple()))
120  return make_error<StringError>("Unsupported ELFNixPlatform triple: " +
121  EPC.getTargetTriple().str(),
123 
124  // Create default aliases if the caller didn't supply any.
125  if (!RuntimeAliases) {
126  auto StandardRuntimeAliases = standardPlatformAliases(ES, PlatformJD);
127  if (!StandardRuntimeAliases)
128  return StandardRuntimeAliases.takeError();
129  RuntimeAliases = std::move(*StandardRuntimeAliases);
130  }
131 
132  // Define the aliases.
133  if (auto Err = PlatformJD.define(symbolAliases(std::move(*RuntimeAliases))))
134  return std::move(Err);
135 
136  // Add JIT-dispatch function support symbols.
137  if (auto Err = PlatformJD.define(absoluteSymbols(
138  {{ES.intern("__orc_rt_jit_dispatch"),
139  {EPC.getJITDispatchInfo().JITDispatchFunction.getValue(),
141  {ES.intern("__orc_rt_jit_dispatch_ctx"),
142  {EPC.getJITDispatchInfo().JITDispatchContext.getValue(),
144  return std::move(Err);
145 
146  // Create a generator for the ORC runtime archive.
147  auto OrcRuntimeArchiveGenerator = StaticLibraryDefinitionGenerator::Load(
148  ObjLinkingLayer, OrcRuntimePath, EPC.getTargetTriple());
149  if (!OrcRuntimeArchiveGenerator)
150  return OrcRuntimeArchiveGenerator.takeError();
151 
152  // Create the instance.
153  Error Err = Error::success();
154  auto P = std::unique_ptr<ELFNixPlatform>(
155  new ELFNixPlatform(ES, ObjLinkingLayer, PlatformJD,
156  std::move(*OrcRuntimeArchiveGenerator), Err));
157  if (Err)
158  return std::move(Err);
159  return std::move(P);
160 }
161 
163  return JD.define(
164  std::make_unique<DSOHandleMaterializationUnit>(*this, DSOHandleSymbol));
165 }
166 
168  return Error::success();
169 }
170 
172  const MaterializationUnit &MU) {
173  auto &JD = RT.getJITDylib();
174  const auto &InitSym = MU.getInitializerSymbol();
175  if (!InitSym)
176  return Error::success();
177 
178  RegisteredInitSymbols[&JD].add(InitSym,
180  LLVM_DEBUG({
181  dbgs() << "ELFNixPlatform: Registered init symbol " << *InitSym
182  << " for MU " << MU.getName() << "\n";
183  });
184  return Error::success();
185 }
186 
188  llvm_unreachable("Not supported yet");
189 }
190 
191 static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases,
192  ArrayRef<std::pair<const char *, const char *>> AL) {
193  for (auto &KV : AL) {
194  auto AliasName = ES.intern(KV.first);
195  assert(!Aliases.count(AliasName) && "Duplicate symbol name in alias map");
196  Aliases[std::move(AliasName)] = {ES.intern(KV.second),
198  }
199 }
200 
203  JITDylib &PlatformJD) {
204  SymbolAliasMap Aliases;
205  addAliases(ES, Aliases, requiredCXXAliases());
206  addAliases(ES, Aliases, standardRuntimeUtilityAliases());
207 
208  // Determine whether or not the libunwind extended-API function for
209  // dynamically registering an entire .eh_frame section is available.
210  // If it is not, we assume that libgcc_s is being used, and alias to
211  // its __register_frame with the same functionality.
212  auto RTRegisterFrame = ES.intern("__orc_rt_register_eh_frame_section");
213  auto LibUnwindRegisterFrame = ES.intern("__unw_add_dynamic_eh_frame_section");
214  auto RTDeregisterFrame = ES.intern("__orc_rt_deregister_eh_frame_section");
215  auto LibUnwindDeregisterFrame =
216  ES.intern("__unw_remove_dynamic_eh_frame_section");
217  auto SM = ES.lookup(makeJITDylibSearchOrder(&PlatformJD),
219  .add(LibUnwindRegisterFrame,
221  .add(LibUnwindDeregisterFrame,
223  if (!SM) { // Weak-ref means no "missing symbol" errors, so this must be
224  // something more serious that we should report.
225  return SM.takeError();
226  } else if (SM->size() == 2) {
227  LLVM_DEBUG({
228  dbgs() << "Using libunwind " << LibUnwindRegisterFrame
229  << " for unwind info registration\n";
230  });
231  Aliases[std::move(RTRegisterFrame)] = {LibUnwindRegisterFrame,
233  Aliases[std::move(RTDeregisterFrame)] = {LibUnwindDeregisterFrame,
235  } else {
236  // Since LLVM libunwind is not present, we assume that unwinding
237  // is provided by libgcc
238  LLVM_DEBUG({
239  dbgs() << "Using libgcc __register_frame"
240  << " for unwind info registration\n";
241  });
242  Aliases[std::move(RTRegisterFrame)] = {ES.intern("__register_frame"),
244  Aliases[std::move(RTDeregisterFrame)] = {ES.intern("__deregister_frame"),
246  }
247 
248  return Aliases;
249 }
250 
253  static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
254  {"__cxa_atexit", "__orc_rt_elfnix_cxa_atexit"},
255  {"atexit", "__orc_rt_elfnix_atexit"}};
256 
257  return ArrayRef<std::pair<const char *, const char *>>(RequiredCXXAliases);
258 }
259 
262  static const std::pair<const char *, const char *>
263  StandardRuntimeUtilityAliases[] = {
264  {"__orc_rt_run_program", "__orc_rt_elfnix_run_program"},
265  {"__orc_rt_jit_dlerror", "__orc_rt_elfnix_jit_dlerror"},
266  {"__orc_rt_jit_dlopen", "__orc_rt_elfnix_jit_dlopen"},
267  {"__orc_rt_jit_dlclose", "__orc_rt_elfnix_jit_dlclose"},
268  {"__orc_rt_jit_dlsym", "__orc_rt_elfnix_jit_dlsym"},
269  {"__orc_rt_log_error", "__orc_rt_log_error_to_stderr"}};
270 
272  StandardRuntimeUtilityAliases);
273 }
274 
276  if (SecName.consume_front(InitArrayFuncSectionName) &&
277  (SecName.empty() || SecName[0] == '.'))
278  return true;
279  return false;
280 }
281 
282 bool ELFNixPlatform::supportedTarget(const Triple &TT) {
283  switch (TT.getArch()) {
284  case Triple::x86_64:
285  case Triple::aarch64:
286  return true;
287  default:
288  return false;
289  }
290 }
291 
292 ELFNixPlatform::ELFNixPlatform(
293  ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer,
294  JITDylib &PlatformJD,
295  std::unique_ptr<DefinitionGenerator> OrcRuntimeGenerator, Error &Err)
296  : ES(ES), ObjLinkingLayer(ObjLinkingLayer),
297  DSOHandleSymbol(ES.intern("__dso_handle")) {
298  ErrorAsOutParameter _(&Err);
299 
300  ObjLinkingLayer.addPlugin(std::make_unique<ELFNixPlatformPlugin>(*this));
301 
302  PlatformJD.addGenerator(std::move(OrcRuntimeGenerator));
303 
304  // PlatformJD hasn't been 'set-up' by the platform yet (since we're creating
305  // the platform now), so set it up.
306  if (auto E2 = setupJITDylib(PlatformJD)) {
307  Err = std::move(E2);
308  return;
309  }
310 
311  RegisteredInitSymbols[&PlatformJD].add(
313 
314  // Associate wrapper function tags with JIT-side function implementations.
315  if (auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
316  Err = std::move(E2);
317  return;
318  }
319 
320  // Lookup addresses of runtime functions callable by the platform,
321  // call the platform bootstrap function to initialize the platform-state
322  // object in the executor.
323  if (auto E2 = bootstrapELFNixRuntime(PlatformJD)) {
324  Err = std::move(E2);
325  return;
326  }
327 }
328 
329 Error ELFNixPlatform::associateRuntimeSupportFunctions(JITDylib &PlatformJD) {
331 
332  using GetInitializersSPSSig =
334  WFs[ES.intern("__orc_rt_elfnix_get_initializers_tag")] =
335  ES.wrapAsyncWithSPS<GetInitializersSPSSig>(
336  this, &ELFNixPlatform::rt_getInitializers);
337 
338  using GetDeinitializersSPSSig =
340  WFs[ES.intern("__orc_rt_elfnix_get_deinitializers_tag")] =
341  ES.wrapAsyncWithSPS<GetDeinitializersSPSSig>(
342  this, &ELFNixPlatform::rt_getDeinitializers);
343 
344  using LookupSymbolSPSSig =
346  WFs[ES.intern("__orc_rt_elfnix_symbol_lookup_tag")] =
347  ES.wrapAsyncWithSPS<LookupSymbolSPSSig>(this,
348  &ELFNixPlatform::rt_lookupSymbol);
349 
350  return ES.registerJITDispatchHandlers(PlatformJD, std::move(WFs));
351 }
352 
353 void ELFNixPlatform::getInitializersBuildSequencePhase(
354  SendInitializerSequenceFn SendResult, JITDylib &JD,
355  std::vector<JITDylibSP> DFSLinkOrder) {
357  {
358  std::lock_guard<std::mutex> Lock(PlatformMutex);
359  for (auto &InitJD : reverse(DFSLinkOrder)) {
360  LLVM_DEBUG({
361  dbgs() << "ELFNixPlatform: Appending inits for \"" << InitJD->getName()
362  << "\" to sequence\n";
363  });
364  auto ISItr = InitSeqs.find(InitJD.get());
365  if (ISItr != InitSeqs.end()) {
366  FullInitSeq.emplace_back(std::move(ISItr->second));
367  InitSeqs.erase(ISItr);
368  }
369  }
370  }
371 
372  SendResult(std::move(FullInitSeq));
373 }
374 
375 void ELFNixPlatform::getInitializersLookupPhase(
376  SendInitializerSequenceFn SendResult, JITDylib &JD) {
377 
378  auto DFSLinkOrder = JD.getDFSLinkOrder();
379  if (!DFSLinkOrder) {
380  SendResult(DFSLinkOrder.takeError());
381  return;
382  }
383 
385  ES.runSessionLocked([&]() {
386  for (auto &InitJD : *DFSLinkOrder) {
387  auto RISItr = RegisteredInitSymbols.find(InitJD.get());
388  if (RISItr != RegisteredInitSymbols.end()) {
389  NewInitSymbols[InitJD.get()] = std::move(RISItr->second);
390  RegisteredInitSymbols.erase(RISItr);
391  }
392  }
393  });
394 
395  // If there are no further init symbols to look up then move on to the next
396  // phase.
397  if (NewInitSymbols.empty()) {
398  getInitializersBuildSequencePhase(std::move(SendResult), JD,
399  std::move(*DFSLinkOrder));
400  return;
401  }
402 
403  // Otherwise issue a lookup and re-run this phase when it completes.
405  [this, SendResult = std::move(SendResult), &JD](Error Err) mutable {
406  if (Err)
407  SendResult(std::move(Err));
408  else
409  getInitializersLookupPhase(std::move(SendResult), JD);
410  },
411  ES, std::move(NewInitSymbols));
412 }
413 
414 void ELFNixPlatform::rt_getInitializers(SendInitializerSequenceFn SendResult,
415  StringRef JDName) {
416  LLVM_DEBUG({
417  dbgs() << "ELFNixPlatform::rt_getInitializers(\"" << JDName << "\")\n";
418  });
419 
420  JITDylib *JD = ES.getJITDylibByName(JDName);
421  if (!JD) {
422  LLVM_DEBUG({
423  dbgs() << " No such JITDylib \"" << JDName << "\". Sending error.\n";
424  });
425  SendResult(make_error<StringError>("No JITDylib named " + JDName,
427  return;
428  }
429 
430  getInitializersLookupPhase(std::move(SendResult), *JD);
431 }
432 
433 void ELFNixPlatform::rt_getDeinitializers(
434  SendDeinitializerSequenceFn SendResult, ExecutorAddr Handle) {
435  LLVM_DEBUG({
436  dbgs() << "ELFNixPlatform::rt_getDeinitializers(\""
437  << formatv("{0:x}", Handle.getValue()) << "\")\n";
438  });
439 
440  JITDylib *JD = nullptr;
441 
442  {
443  std::lock_guard<std::mutex> Lock(PlatformMutex);
444  auto I = HandleAddrToJITDylib.find(Handle);
445  if (I != HandleAddrToJITDylib.end())
446  JD = I->second;
447  }
448 
449  if (!JD) {
450  LLVM_DEBUG({
451  dbgs() << " No JITDylib for handle "
452  << formatv("{0:x}", Handle.getValue()) << "\n";
453  });
454  SendResult(make_error<StringError>("No JITDylib associated with handle " +
455  formatv("{0:x}", Handle.getValue()),
457  return;
458  }
459 
461 }
462 
463 void ELFNixPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
464  ExecutorAddr Handle,
466  LLVM_DEBUG({
467  dbgs() << "ELFNixPlatform::rt_lookupSymbol(\""
468  << formatv("{0:x}", Handle.getValue()) << "\")\n";
469  });
470 
471  JITDylib *JD = nullptr;
472 
473  {
474  std::lock_guard<std::mutex> Lock(PlatformMutex);
475  auto I = HandleAddrToJITDylib.find(Handle);
476  if (I != HandleAddrToJITDylib.end())
477  JD = I->second;
478  }
479 
480  if (!JD) {
481  LLVM_DEBUG({
482  dbgs() << " No JITDylib for handle "
483  << formatv("{0:x}", Handle.getValue()) << "\n";
484  });
485  SendResult(make_error<StringError>("No JITDylib associated with handle " +
486  formatv("{0:x}", Handle.getValue()),
488  return;
489  }
490 
491  // Use functor class to work around XL build compiler issue on AIX.
492  class RtLookupNotifyComplete {
493  public:
494  RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
495  : SendResult(std::move(SendResult)) {}
496  void operator()(Expected<SymbolMap> Result) {
497  if (Result) {
498  assert(Result->size() == 1 && "Unexpected result map count");
499  SendResult(ExecutorAddr(Result->begin()->second.getAddress()));
500  } else {
501  SendResult(Result.takeError());
502  }
503  }
504 
505  private:
506  SendSymbolAddressFn SendResult;
507  };
508 
509  ES.lookup(
512  RtLookupNotifyComplete(std::move(SendResult)), NoDependenciesToRegister);
513 }
514 
515 Error ELFNixPlatform::bootstrapELFNixRuntime(JITDylib &PlatformJD) {
516 
517  std::pair<const char *, ExecutorAddr *> Symbols[] = {
518  {"__orc_rt_elfnix_platform_bootstrap", &orc_rt_elfnix_platform_bootstrap},
519  {"__orc_rt_elfnix_platform_shutdown", &orc_rt_elfnix_platform_shutdown},
520  {"__orc_rt_elfnix_register_object_sections",
521  &orc_rt_elfnix_register_object_sections},
522  {"__orc_rt_elfnix_create_pthread_key",
523  &orc_rt_elfnix_create_pthread_key}};
524 
525  SymbolLookupSet RuntimeSymbols;
526  std::vector<std::pair<SymbolStringPtr, ExecutorAddr *>> AddrsToRecord;
527  for (const auto &KV : Symbols) {
528  auto Name = ES.intern(KV.first);
529  RuntimeSymbols.add(Name);
530  AddrsToRecord.push_back({std::move(Name), KV.second});
531  }
532 
533  auto RuntimeSymbolAddrs = ES.lookup(
534  {{&PlatformJD, JITDylibLookupFlags::MatchAllSymbols}}, RuntimeSymbols);
535  if (!RuntimeSymbolAddrs)
536  return RuntimeSymbolAddrs.takeError();
537 
538  for (const auto &KV : AddrsToRecord) {
539  auto &Name = KV.first;
540  assert(RuntimeSymbolAddrs->count(Name) && "Missing runtime symbol?");
541  KV.second->setValue((*RuntimeSymbolAddrs)[Name].getAddress());
542  }
543 
544  auto PJDDSOHandle = ES.lookup(
545  {{&PlatformJD, JITDylibLookupFlags::MatchAllSymbols}}, DSOHandleSymbol);
546  if (!PJDDSOHandle)
547  return PJDDSOHandle.takeError();
548 
549  if (auto Err = ES.callSPSWrapper<void(uint64_t)>(
550  orc_rt_elfnix_platform_bootstrap, PJDDSOHandle->getAddress()))
551  return Err;
552 
553  // FIXME: Ordering is fuzzy here. We're probably best off saying
554  // "behavior is undefined if code that uses the runtime is added before
555  // the platform constructor returns", then move all this to the constructor.
556  RuntimeBootstrapped = true;
557  std::vector<ELFPerObjectSectionsToRegister> DeferredPOSRs;
558  {
559  std::lock_guard<std::mutex> Lock(PlatformMutex);
560  DeferredPOSRs = std::move(BootstrapPOSRs);
561  }
562 
563  for (auto &D : DeferredPOSRs)
564  if (auto Err = registerPerObjectSections(D))
565  return Err;
566 
567  return Error::success();
568 }
569 
570 Error ELFNixPlatform::registerInitInfo(
571  JITDylib &JD, ArrayRef<jitlink::Section *> InitSections) {
572 
573  std::unique_lock<std::mutex> Lock(PlatformMutex);
574 
575  ELFNixJITDylibInitializers *InitSeq = nullptr;
576  {
577  auto I = InitSeqs.find(&JD);
578  if (I == InitSeqs.end()) {
579  // If there's no init sequence entry yet then we need to look up the
580  // header symbol to force creation of one.
581  Lock.unlock();
582 
583  auto SearchOrder =
584  JD.withLinkOrderDo([](const JITDylibSearchOrder &SO) { return SO; });
585  if (auto Err = ES.lookup(SearchOrder, DSOHandleSymbol).takeError())
586  return Err;
587 
588  Lock.lock();
589  I = InitSeqs.find(&JD);
590  assert(I != InitSeqs.end() &&
591  "Entry missing after header symbol lookup?");
592  }
593  InitSeq = &I->second;
594  }
595 
596  for (auto *Sec : InitSections) {
597  // FIXME: Avoid copy here.
598  jitlink::SectionRange R(*Sec);
599  InitSeq->InitSections[Sec->getName()].push_back(
600  {ExecutorAddr(R.getStart()), ExecutorAddr(R.getEnd())});
601  }
602 
603  return Error::success();
604 }
605 
606 Error ELFNixPlatform::registerPerObjectSections(
607  const ELFPerObjectSectionsToRegister &POSR) {
608 
609  if (!orc_rt_elfnix_register_object_sections)
610  return make_error<StringError>("Attempting to register per-object "
611  "sections, but runtime support has not "
612  "been loaded yet",
614 
615  Error ErrResult = Error::success();
616  if (auto Err = ES.callSPSWrapper<shared::SPSError(
618  orc_rt_elfnix_register_object_sections, ErrResult, POSR))
619  return Err;
620  return ErrResult;
621 }
622 
623 Expected<uint64_t> ELFNixPlatform::createPThreadKey() {
624  if (!orc_rt_elfnix_create_pthread_key)
625  return make_error<StringError>(
626  "Attempting to create pthread key in target, but runtime support has "
627  "not been loaded yet",
629 
631  if (auto Err = ES.callSPSWrapper<SPSExpected<uint64_t>(void)>(
632  orc_rt_elfnix_create_pthread_key, Result))
633  return std::move(Err);
634  return Result;
635 }
636 
637 void ELFNixPlatform::ELFNixPlatformPlugin::modifyPassConfig(
639  jitlink::PassConfiguration &Config) {
640 
641  // If the initializer symbol is the __dso_handle symbol then just add
642  // the DSO handle support passes.
643  if (MR.getInitializerSymbol() == MP.DSOHandleSymbol) {
644  addDSOHandleSupportPasses(MR, Config);
645  // The DSOHandle materialization unit doesn't require any other
646  // support, so we can bail out early.
647  return;
648  }
649 
650  // If the object contains initializers then add passes to record them.
651  if (MR.getInitializerSymbol())
652  addInitializerSupportPasses(MR, Config);
653 
654  // Add passes for eh-frame and TLV support.
655  addEHAndTLVSupportPasses(MR, Config);
656 }
657 
659 ELFNixPlatform::ELFNixPlatformPlugin::getSyntheticSymbolDependencies(
661  std::lock_guard<std::mutex> Lock(PluginMutex);
662  auto I = InitSymbolDeps.find(&MR);
663  if (I != InitSymbolDeps.end()) {
664  SyntheticSymbolDependenciesMap Result;
665  Result[MR.getInitializerSymbol()] = std::move(I->second);
666  InitSymbolDeps.erase(&MR);
667  return Result;
668  }
669  return SyntheticSymbolDependenciesMap();
670 }
671 
672 void ELFNixPlatform::ELFNixPlatformPlugin::addInitializerSupportPasses(
674 
675  /// Preserve init sections.
676  Config.PrePrunePasses.push_back([this, &MR](jitlink::LinkGraph &G) -> Error {
677  if (auto Err = preserveInitSections(G, MR))
678  return Err;
679  return Error::success();
680  });
681 
682  Config.PostFixupPasses.push_back(
683  [this, &JD = MR.getTargetJITDylib()](jitlink::LinkGraph &G) {
684  return registerInitSections(G, JD);
685  });
686 }
687 
688 void ELFNixPlatform::ELFNixPlatformPlugin::addDSOHandleSupportPasses(
690 
691  Config.PostAllocationPasses.push_back([this, &JD = MR.getTargetJITDylib()](
692  jitlink::LinkGraph &G) -> Error {
693  auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
694  return Sym->getName() == *MP.DSOHandleSymbol;
695  });
696  assert(I != G.defined_symbols().end() && "Missing DSO handle symbol");
697  {
698  std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
699  auto HandleAddr = (*I)->getAddress();
700  MP.HandleAddrToJITDylib[HandleAddr] = &JD;
701  assert(!MP.InitSeqs.count(&JD) && "InitSeq entry for JD already exists");
702  MP.InitSeqs.insert(std::make_pair(
703  &JD, ELFNixJITDylibInitializers(JD.getName(), HandleAddr)));
704  }
705  return Error::success();
706  });
707 }
708 
709 void ELFNixPlatform::ELFNixPlatformPlugin::addEHAndTLVSupportPasses(
711 
712  // Insert TLV lowering at the start of the PostPrunePasses, since we want
713  // it to run before GOT/PLT lowering.
714 
715  // TODO: Check that before the fixTLVSectionsAndEdges pass, the GOT/PLT build
716  // pass has done. Because the TLS descriptor need to be allocate in GOT.
717  Config.PostPrunePasses.push_back(
718  [this, &JD = MR.getTargetJITDylib()](jitlink::LinkGraph &G) {
719  return fixTLVSectionsAndEdges(G, JD);
720  });
721 
722  // Add a pass to register the final addresses of the eh-frame and TLV sections
723  // with the runtime.
724  Config.PostFixupPasses.push_back([this](jitlink::LinkGraph &G) -> Error {
726 
727  if (auto *EHFrameSection = G.findSectionByName(EHFrameSectionName)) {
728  jitlink::SectionRange R(*EHFrameSection);
729  if (!R.empty())
730  POSR.EHFrameSection = {ExecutorAddr(R.getStart()),
731  ExecutorAddr(R.getEnd())};
732  }
733 
734  // Get a pointer to the thread data section if there is one. It will be used
735  // below.
736  jitlink::Section *ThreadDataSection =
737  G.findSectionByName(ThreadDataSectionName);
738 
739  // Handle thread BSS section if there is one.
740  if (auto *ThreadBSSSection = G.findSectionByName(ThreadBSSSectionName)) {
741  // If there's already a thread data section in this graph then merge the
742  // thread BSS section content into it, otherwise just treat the thread
743  // BSS section as the thread data section.
744  if (ThreadDataSection)
745  G.mergeSections(*ThreadDataSection, *ThreadBSSSection);
746  else
747  ThreadDataSection = ThreadBSSSection;
748  }
749 
750  // Having merged thread BSS (if present) and thread data (if present),
751  // record the resulting section range.
752  if (ThreadDataSection) {
753  jitlink::SectionRange R(*ThreadDataSection);
754  if (!R.empty())
755  POSR.ThreadDataSection = {ExecutorAddr(R.getStart()),
756  ExecutorAddr(R.getEnd())};
757  }
758 
759  if (POSR.EHFrameSection.Start || POSR.ThreadDataSection.Start) {
760 
761  // If we're still bootstrapping the runtime then just record this
762  // frame for now.
763  if (!MP.RuntimeBootstrapped) {
764  std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
765  MP.BootstrapPOSRs.push_back(POSR);
766  return Error::success();
767  }
768 
769  // Otherwise register it immediately.
770  if (auto Err = MP.registerPerObjectSections(POSR))
771  return Err;
772  }
773 
774  return Error::success();
775  });
776 }
777 
778 Error ELFNixPlatform::ELFNixPlatformPlugin::preserveInitSections(
780 
781  JITLinkSymbolSet InitSectionSymbols;
782  for (auto &InitSection : G.sections()) {
783  // Skip non-init sections.
784  if (!isInitializerSection(InitSection.getName()))
785  continue;
786 
787  // Make a pass over live symbols in the section: those blocks are already
788  // preserved.
789  DenseSet<jitlink::Block *> AlreadyLiveBlocks;
790  for (auto &Sym : InitSection.symbols()) {
791  auto &B = Sym->getBlock();
792  if (Sym->isLive() && Sym->getOffset() == 0 &&
793  Sym->getSize() == B.getSize() && !AlreadyLiveBlocks.count(&B)) {
794  InitSectionSymbols.insert(Sym);
795  AlreadyLiveBlocks.insert(&B);
796  }
797  }
798 
799  // Add anonymous symbols to preserve any not-already-preserved blocks.
800  for (auto *B : InitSection.blocks())
801  if (!AlreadyLiveBlocks.count(B))
802  InitSectionSymbols.insert(
803  &G.addAnonymousSymbol(*B, 0, B->getSize(), false, true));
804  }
805 
806  if (!InitSectionSymbols.empty()) {
807  std::lock_guard<std::mutex> Lock(PluginMutex);
808  InitSymbolDeps[&MR] = std::move(InitSectionSymbols);
809  }
810 
811  return Error::success();
812 }
813 
814 Error ELFNixPlatform::ELFNixPlatformPlugin::registerInitSections(
815  jitlink::LinkGraph &G, JITDylib &JD) {
816 
817  SmallVector<jitlink::Section *> InitSections;
818 
819  LLVM_DEBUG({ dbgs() << "ELFNixPlatform::registerInitSections\n"; });
820 
821  for (auto &Sec : G.sections()) {
822  if (isInitializerSection(Sec.getName())) {
823  InitSections.push_back(&Sec);
824  }
825  }
826 
827  // Dump the scraped inits.
828  LLVM_DEBUG({
829  dbgs() << "ELFNixPlatform: Scraped " << G.getName() << " init sections:\n";
830  for (auto *Sec : InitSections) {
831  jitlink::SectionRange R(*Sec);
832  dbgs() << " " << Sec->getName() << ": "
833  << formatv("[ {0:x} -- {1:x} ]", R.getStart(), R.getEnd()) << "\n";
834  }
835  });
836 
837  return MP.registerInitInfo(JD, InitSections);
838 }
839 
840 Error ELFNixPlatform::ELFNixPlatformPlugin::fixTLVSectionsAndEdges(
841  jitlink::LinkGraph &G, JITDylib &JD) {
842 
843  for (auto *Sym : G.external_symbols()) {
844  if (Sym->getName() == "__tls_get_addr") {
845  Sym->setName("___orc_rt_elfnix_tls_get_addr");
846  } else if (Sym->getName() == "__tlsdesc_resolver") {
847  Sym->setName("___orc_rt_elfnix_tlsdesc_resolver");
848  }
849  }
850 
851  auto *TLSInfoEntrySection = G.findSectionByName("$__TLSINFO");
852 
853  if (TLSInfoEntrySection) {
854  std::optional<uint64_t> Key;
855  {
856  std::lock_guard<std::mutex> Lock(MP.PlatformMutex);
857  auto I = MP.JITDylibToPThreadKey.find(&JD);
858  if (I != MP.JITDylibToPThreadKey.end())
859  Key = I->second;
860  }
861  if (!Key) {
862  if (auto KeyOrErr = MP.createPThreadKey())
863  Key = *KeyOrErr;
864  else
865  return KeyOrErr.takeError();
866  }
867 
868  uint64_t PlatformKeyBits =
869  support::endian::byte_swap(*Key, G.getEndianness());
870 
871  for (auto *B : TLSInfoEntrySection->blocks()) {
872  // FIXME: The TLS descriptor byte length may different with different
873  // ISA
874  assert(B->getSize() == (G.getPointerSize() * 2) &&
875  "TLS descriptor must be 2 words length");
876  auto TLSInfoEntryContent = B->getMutableContent(G);
877  memcpy(TLSInfoEntryContent.data(), &PlatformKeyBits, G.getPointerSize());
878  }
879  }
880 
881  return Error::success();
882 }
883 
884 } // End namespace orc.
885 } // End namespace llvm.
llvm::orc::ExecutorAddr
Represents an address in the executor process.
Definition: ExecutorAddress.h:31
llvm::orc::ObjectLinkingLayer::emit
void emit(std::unique_ptr< MaterializationResponsibility > R, std::unique_ptr< MemoryBuffer > O) override
Emit an object file.
Definition: ObjectLinkingLayer.cpp:657
llvm::orc::MaterializationResponsibility
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition: Core.h:519
getName
static StringRef getName(Value *V)
Definition: ProvenanceAnalysisEvaluator.cpp:20
llvm::orc::JITDylib::withLinkOrderDo
auto withLinkOrderDo(Func &&F) -> decltype(F(std::declval< const JITDylibSearchOrder & >()))
Do something with the link order (run under the session lock).
Definition: Core.h:1799
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::orc::JITDylib
Represents a JIT'd dynamic library.
Definition: Core.h:953
llvm::msgpack::Endianness
constexpr support::endianness Endianness
The endianness of all multi-byte encoded values in MessagePack.
Definition: MsgPack.h:24
llvm::AArch64CC::AL
@ AL
Definition: AArch64BaseInfo.h:269
llvm::orc::shared::SPSSequence
SPS tag type for sequences.
Definition: SimplePackedSerialization.h:205
llvm::orc::ELFNixPlatform::notifyRemoving
Error notifyRemoving(ResourceTracker &RT) override
This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
Definition: ELFNixPlatform.cpp:187
ELFNixPlatform.h
llvm::orc::ExecutionSession::getJITDylibByName
JITDylib * getJITDylibByName(StringRef Name)
Return a pointer to the "name" JITDylib.
Definition: Core.cpp:1931
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
BinaryByteStream.h
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
llvm::orc::SymbolLookupSet
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:175
llvm::orc::SymbolStringPtr
Pointer to a pooled string representing a symbol name.
Definition: SymbolStringPool.h:57
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::orc::ELFNixPlatform::requiredCXXAliases
static ArrayRef< std::pair< const char *, const char * > > requiredCXXAliases()
Returns the array of required CXX aliases.
Definition: ELFNixPlatform.cpp:252
Content
T Content
Definition: ELFObjHandler.cpp:89
llvm::StringRef::consume_front
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition: StringRef.h:627
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::orc::ELFNixPlatform::notifyAdding
Error notifyAdding(ResourceTracker &RT, const MaterializationUnit &MU) override
This method will be called under the ExecutionSession lock each time a MaterializationUnit is added t...
Definition: ELFNixPlatform.cpp:171
llvm::orc::ExecutorAddr::getValue
uint64_t getValue() const
Definition: ExecutorAddress.h:105
llvm::orc::shared
Definition: ELFNixPlatform.h:245
llvm::Triple::x86_64
@ x86_64
Definition: Triple.h:86
aarch64.h
llvm::orc::ResourceTracker
API to remove / transfer ownership of JIT resources.
Definition: Core.h:53
llvm::Optional
Definition: APInt.h:33
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:41
llvm::orc::Platform::lookupInitSymbolsAsync
static void lookupInitSymbolsAsync(unique_function< void(Error)> OnComplete, ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms)
Performs an async lookup for the given symbols in each of the given JITDylibs, calling the given hand...
Definition: Core.cpp:1833
llvm::orc::shared::SPSTuple
SPS tag type for tuples.
Definition: SimplePackedSerialization.h:195
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::count
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Definition: DenseSet.h:97
llvm::MachO::SymbolFlags
SymbolFlags
Symbol flags.
Definition: Symbol.h:24
llvm::orc::MaterializationUnit
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
Definition: Core.h:665
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
ExecutionUtils.h
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:265
DebugUtils.h
llvm::orc::MaterializationUnit::getName
virtual StringRef getName() const =0
Return the name of this materialization unit.
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
llvm::orc::ResourceTracker::getJITDylib
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
Definition: Core.h:68
llvm::formatv
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
Definition: FormatVariadic.h:251
llvm::orc::ExecutionSession::registerJITDispatchHandlers
Error registerJITDispatchHandlers(JITDylib &JD, JITDispatchHandlerAssociationMap WFs)
For each tag symbol name, associate the corresponding AsyncHandlerWrapperFunction with the address of...
Definition: Core.cpp:2185
ELF.h
llvm::orc::JITDylib::getDFSLinkOrder
static Expected< std::vector< JITDylibSP > > getDFSLinkOrder(ArrayRef< JITDylibSP > JDs)
Returns the given JITDylibs and all of their transitive dependencies in DFS order (based on linkage r...
Definition: Core.cpp:1996
llvm::support::little
@ little
Definition: Endian.h:27
llvm::orc::MemProt::Read
@ Read
llvm::orc
Definition: COFFPlatform.h:30
llvm::orc::NoDependenciesToRegister
RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
Definition: Core.cpp:35
llvm::ms_demangle::QualifierMangleMode::Result
@ Result
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::orc::ExecutionSession::intern
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition: Core.h:1416
llvm::orc::JITDylib::addGenerator
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Definition: Core.h:1789
llvm::orc::shared::SPSExecutorAddr
Definition: ExecutorAddress.h:228
llvm::orc::ExecutionSession::runSessionLocked
decltype(auto) runSessionLocked(Func &&F)
Run the given lambda with the session mutex locked.
Definition: Core.h:1426
llvm::ErrorAsOutParameter
Helper for Errors used as out-parameters.
Definition: Error.h:1096
llvm::orc::LookupKind::DLSym
@ DLSym
llvm::orc::MaterializationUnit::Interface
Definition: Core.h:672
llvm::orc::SymbolLookupSet::add
SymbolLookupSet & add(SymbolStringPtr Name, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Add an element to the set.
Definition: Core.h:236
llvm::orc::ELFPerObjectSectionsToRegister::ThreadDataSection
ExecutorAddrRange ThreadDataSection
Definition: ELFNixPlatform.h:31
llvm::orc::SymbolLookupFlags::WeaklyReferencedSymbol
@ WeaklyReferencedSymbol
llvm::orc::MaterializationResponsibility::getInitializerSymbol
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
Definition: Core.h:552
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::orc::ELFNixPlatform::isInitializerSection
static bool isInitializerSection(StringRef SecName)
Returns true if the given section name is an initializer section.
Definition: ELFNixPlatform.cpp:275
llvm::orc::ELFNixPlatform::standardPlatformAliases
static Expected< SymbolAliasMap > standardPlatformAliases(ExecutionSession &ES, JITDylib &PlatformJD)
Returns an AliasMap containing the default aliases for the ELFNixPlatform.
Definition: ELFNixPlatform.cpp:202
llvm::orc::MaterializationResponsibility::getTargetJITDylib
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
Definition: Core.h:538
uint64_t
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::orc::MaterializationUnit::getInitializerSymbol
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization symbol for this MaterializationUnit (if any).
Definition: Core.h:698
llvm::orc::ELFNixJITDylibDeinitializerSequence
std::vector< ELFNixJITDylibDeinitializers > ELFNixJITDylibDeinitializerSequence
Definition: ELFNixPlatform.h:52
llvm::ARM_AM::add
@ add
Definition: ARMAddressingModes.h:39
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::shared::SPSExpected
SPS tag type for expecteds, which are either a T or a string representing an error.
Definition: SimplePackedSerialization.h:548
llvm::DenseMap< SymbolStringPtr, JITSymbolFlags >
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::orc::ELFPerObjectSectionsToRegister
Definition: ELFNixPlatform.h:29
llvm::orc::ELFNixJITDylibInitializerSequence
std::vector< ELFNixJITDylibInitializers > ELFNixJITDylibInitializerSequence
Definition: ELFNixPlatform.h:49
llvm::orc::ELFNixPlatform::setupJITDylib
Error setupJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is created (unless it is cre...
Definition: ELFNixPlatform.cpp:162
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1861
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::orc::ExecutionSession::callSPSWrapper
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition: Core.h:1610
llvm::orc::JITDylibSearchOrder
std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder
A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.
Definition: Core.h:154
llvm::orc::ExecutorAddrRange::Start
ExecutorAddr Start
Definition: ExecutorAddress.h:214
llvm::orc::ExecutionSession::getExecutorProcessControl
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1408
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::empty
bool empty() const
Definition: DenseMap.h:98
_
#define _
Definition: HexagonMCCodeEmitter.cpp:47
llvm::orc::ELFNixJITDylibInitializers
Definition: ELFNixPlatform.h:34
ELF_x86_64.h
llvm::ArrayRef< char >
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::orc::ELFNixPlatform::standardRuntimeUtilityAliases
static ArrayRef< std::pair< const char *, const char * > > standardRuntimeUtilityAliases()
Returns the array of standard runtime utility aliases for ELF.
Definition: ELFNixPlatform.cpp:261
llvm::orc::SymbolState::Ready
@ Ready
Emitted to memory, but waiting on transitive dependencies.
llvm::orc::ELFNixPlatform
Mediates between ELFNix initialization and ExecutionSession state.
Definition: ELFNixPlatform.h:55
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
if
if(llvm_vc STREQUAL "") set(fake_version_inc "$
Definition: CMakeLists.txt:14
llvm::orc::ELFNixPlatform::getObjectLinkingLayer
ObjectLinkingLayer & getObjectLinkingLayer() const
Definition: ELFNixPlatform.h:101
llvm::orc::StaticLibraryDefinitionGenerator::Load
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Load(ObjectLayer &L, const char *FileName, GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibraryDefinitionGenerator from the given path.
Definition: ExecutionUtils.cpp:274
x86_64.h
llvm::orc::ObjectLinkingLayer
An ObjectLayer implementation built on JITLink.
Definition: ObjectLinkingLayer.h:50
llvm::AMDGPU::HSAMD::Kernel::Key::SymbolName
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
Definition: AMDGPUMetadata.h:386
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
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:79
llvm::orc::ObjectLinkingLayer::addPlugin
ObjectLinkingLayer & addPlugin(std::unique_ptr< Plugin > P)
Add a pass-config modifier.
Definition: ObjectLinkingLayer.h:126
llvm::orc::addAliases
static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases, ArrayRef< std::pair< const char *, const char * >> AL)
Definition: COFFPlatform.cpp:224
llvm::orc::ExecutorProcessControl::getTargetTriple
const Triple & getTargetTriple() const
Return the Triple for the target process.
Definition: ExecutorProcessControl.h:201
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1365
llvm::orc::JITDylibLookupFlags::MatchExportedSymbolsOnly
@ MatchExportedSymbolsOnly
llvm::support::endian::byte_swap
value_type byte_swap(value_type value, endianness endian)
Definition: Endian.h:49
llvm::orc::symbolAliases
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
Definition: Core.h:809
llvm::orc::absoluteSymbols
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
Definition: Core.h:763
llvm::orc::ELFNixPlatform::Create
static Expected< std::unique_ptr< ELFNixPlatform > > Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, const char *OrcRuntimePath, Optional< SymbolAliasMap > RuntimeAliases=std::nullopt)
Try to create a ELFNixPlatform instance, adding the ORC runtime to the given JITDylib.
Definition: ELFNixPlatform.cpp:111
llvm::orc::JITDylib::define
Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)
Define all symbols provided by the materialization unit to be part of this JITDylib.
Definition: Core.h:1806
llvm::orc::ExecutionSession::lookup
void lookup(LookupKind K, const JITDylibSearchOrder &SearchOrder, SymbolLookupSet Symbols, SymbolState RequiredState, SymbolsResolvedCallback NotifyComplete, RegisterDependenciesFunction RegisterDependencies)
Search the given JITDylibs for the given symbols.
Definition: Core.cpp:2076
llvm::support::endianness
endianness
Definition: Endian.h:27
llvm::reverse
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:485
llvm::orc::ELFNixPlatform::getExecutionSession
ExecutionSession & getExecutionSession() const
Definition: ELFNixPlatform.h:100
llvm::orc::ExecutionSession::wrapAsyncWithSPS
static JITDispatchHandlerFunction wrapAsyncWithSPS(HandlerT &&H)
Wrap a handler that takes concrete argument types (and a sender for a concrete return type) to produc...
Definition: Core.h:1624
llvm::orc::ELFPerObjectSectionsToRegister::EHFrameSection
ExecutorAddrRange EHFrameSection
Definition: ELFNixPlatform.h:30
llvm::orc::ELFNixJITDylibInitializers::InitSections
StringMap< SectionList > InitSections
Definition: ELFNixPlatform.h:43
llvm::orc::JITDylibLookupFlags::MatchAllSymbols
@ MatchAllSymbols
llvm::orc::ELFNixPlatform::teardownJITDylib
Error teardownJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is removed to allow the Plat...
Definition: ELFNixPlatform.cpp:167
Debug.h
llvm::orc::makeJITDylibSearchOrder
JITDylibSearchOrder makeJITDylibSearchOrder(ArrayRef< JITDylib * > JDs, JITDylibLookupFlags Flags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Convenience function for creating a search order from an ArrayRef of JITDylib*, all with the same fla...
Definition: Core.h:158
llvm::Triple::aarch64
@ aarch64
Definition: Triple.h:51
llvm::JITSymbolFlags::Exported
@ Exported
Definition: JITSymbol.h:85