LLVM 24.0.0git
COFFPlatform.cpp
Go to the documentation of this file.
1//===------- COFFPlatform.cpp - Utilities for executing COFF 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
11
20#include "llvm/Object/COFF.h"
21
23
24#define DEBUG_TYPE "orc"
25
26using namespace llvm;
27using namespace llvm::orc;
28using namespace llvm::orc::shared;
29
30namespace llvm {
31namespace orc {
32namespace shared {
33
43
44} // namespace shared
45} // namespace orc
46} // namespace llvm
47// Controller-interface descriptors for the COFF platform runtime's
48// bootstrap-time SPS wrapper calls. Kept in the .cpp (the COFF platform's
49// private contract with its runtime; the SPS arg types live here too), and in
50// a named namespace so the constexpr Name members -- read only as constants by
51// ProxySpec -- don't trip -Wunused-const-variable.
54 static constexpr SymbolNameSpec Name =
55 SymbolNameSpec::verbatim("__orc_rt_coff_platform_bootstrap");
56 using SPSSig = void();
57};
59 static constexpr SymbolNameSpec Name =
60 SymbolNameSpec::verbatim("__orc_rt_coff_register_jitdylib");
62};
64 static constexpr SymbolNameSpec Name =
65 SymbolNameSpec::verbatim("__orc_rt_coff_register_object_sections");
67};
68} // namespace llvm::orc::coff_sps_ci
69
70namespace {
71
72class COFFHeaderMaterializationUnit : public MaterializationUnit {
73public:
74 COFFHeaderMaterializationUnit(COFFPlatform &CP,
75 const SymbolStringPtr &HeaderStartSymbol)
76 : MaterializationUnit(createHeaderInterface(CP, HeaderStartSymbol)),
77 CP(CP) {}
78
79 StringRef getName() const override { return "COFFHeaderMU"; }
80
81 void materialize(std::unique_ptr<MaterializationResponsibility> R) override {
82 auto G = std::make_unique<jitlink::LinkGraph>(
83 "<COFFHeaderMU>", CP.getExecutionSession().getSymbolStringPool(),
84 CP.getExecutionSession().getTargetTriple(), SubtargetFeatures(),
86 auto &HeaderSection = G->createSection("__header", MemProt::Read);
87 auto &HeaderBlock = createHeaderBlock(*G, HeaderSection);
88
89 // Init symbol is __ImageBase symbol.
90 auto &ImageBaseSymbol = G->addDefinedSymbol(
91 HeaderBlock, 0, *R->getInitializerSymbol(), HeaderBlock.getSize(),
93
94 addImageBaseRelocationEdge(HeaderBlock, ImageBaseSymbol);
95
96 CP.getObjectLinkingLayer().emit(std::move(R), std::move(G));
97 }
98
99 void discard(const JITDylib &JD, const SymbolStringPtr &Sym) override {}
100
101private:
102 struct HeaderSymbol {
103 const char *Name;
104 uint64_t Offset;
105 };
106
107 struct NTHeader {
108 support::ulittle32_t PEMagic;
109 object::coff_file_header FileHeader;
110 struct PEHeader {
111 object::pe32plus_header Header;
112 object::data_directory DataDirectory[COFF::NUM_DATA_DIRECTORIES + 1];
113 } OptionalHeader;
114 };
115
116 struct HeaderBlockContent {
117 object::dos_header DOSHeader;
118 COFFHeaderMaterializationUnit::NTHeader NTHeader;
119 };
120
121 static jitlink::Block &createHeaderBlock(jitlink::LinkGraph &G,
122 jitlink::Section &HeaderSection) {
123 HeaderBlockContent Hdr = {};
124
125 // Set up magic
126 Hdr.DOSHeader.Magic[0] = 'M';
127 Hdr.DOSHeader.Magic[1] = 'Z';
128 Hdr.DOSHeader.AddressOfNewExeHeader =
129 offsetof(HeaderBlockContent, NTHeader);
130 uint32_t PEMagic = *reinterpret_cast<const uint32_t *>(COFF::PEMagic);
131 Hdr.NTHeader.PEMagic = PEMagic;
132 Hdr.NTHeader.OptionalHeader.Header.Magic = COFF::PE32Header::PE32_PLUS;
133
134 switch (G.getTargetTriple().getArch()) {
135 case Triple::x86_64:
136 Hdr.NTHeader.FileHeader.Machine = COFF::IMAGE_FILE_MACHINE_AMD64;
137 break;
138 default:
139 llvm_unreachable("Unrecognized architecture");
140 }
141
142 auto HeaderContent = G.allocateContent(
143 ArrayRef<char>(reinterpret_cast<const char *>(&Hdr), sizeof(Hdr)));
144
145 return G.createContentBlock(HeaderSection, HeaderContent, ExecutorAddr(), 8,
146 0);
147 }
148
149 static void addImageBaseRelocationEdge(jitlink::Block &B,
150 jitlink::Symbol &ImageBase) {
151 auto ImageBaseOffset = offsetof(HeaderBlockContent, NTHeader) +
152 offsetof(NTHeader, OptionalHeader) +
153 offsetof(object::pe32plus_header, ImageBase);
154 B.addEdge(jitlink::x86_64::Pointer64, ImageBaseOffset, ImageBase, 0);
155 }
156
157 static MaterializationUnit::Interface
158 createHeaderInterface(COFFPlatform &MOP,
159 const SymbolStringPtr &HeaderStartSymbol) {
160 SymbolFlagsMap HeaderSymbolFlags;
161
162 HeaderSymbolFlags[HeaderStartSymbol] = JITSymbolFlags::Exported;
163
164 return MaterializationUnit::Interface(std::move(HeaderSymbolFlags),
165 HeaderStartSymbol);
166 }
167
168 COFFPlatform &CP;
169};
170
171} // end anonymous namespace
172
173namespace llvm {
174namespace orc {
175
176Expected<std::unique_ptr<COFFPlatform>>
178 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
179 LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
180 const char *VCRuntimePath,
181 std::optional<SymbolAliasMap> RuntimeAliases) {
182
183 auto &ES = ObjLinkingLayer.getExecutionSession();
184
185 // If the target is not supported then bail out immediately.
186 if (!supportedTarget(ES.getTargetTriple()))
187 return make_error<StringError>("Unsupported COFFPlatform triple: " +
188 ES.getTargetTriple().str(),
190
191 auto GeneratorArchive =
192 object::Archive::create(OrcRuntimeArchiveBuffer->getMemBufferRef());
193 if (!GeneratorArchive)
194 return GeneratorArchive.takeError();
195
196 std::set<std::string> DylibsToPreload;
197 auto OrcRuntimeArchiveGenerator = StaticLibraryDefinitionGenerator::Create(
198 ObjLinkingLayer, nullptr, std::move(*GeneratorArchive),
199 COFFImportFileScanner(DylibsToPreload));
200 if (!OrcRuntimeArchiveGenerator)
201 return OrcRuntimeArchiveGenerator.takeError();
202
203 // We need a second instance of the archive (for now) for the Platform. We
204 // can `cantFail` this call, since if it were going to fail it would have
205 // failed above.
206 auto RuntimeArchive = cantFail(
207 object::Archive::create(OrcRuntimeArchiveBuffer->getMemBufferRef()));
208
209 // Create default aliases if the caller didn't supply any.
210 if (!RuntimeAliases)
211 RuntimeAliases = standardPlatformAliases(ES);
212
213 // Define the aliases.
214 if (auto Err = PlatformJD.define(symbolAliases(std::move(*RuntimeAliases))))
215 return std::move(Err);
216
217 {
218 // Add JIT dispatch reexports from bootstrap JITDylib.
219 MangleAndInterner Mangle(ES);
220 auto Exports = buildSimpleReexportsAliasMap(
221 ES.getBootstrapJITDylib(),
222 {{Mangle(rt::DispatchName), Mangle(rt::DispatchCtxName)}});
223 if (!Exports)
224 return Exports.takeError();
225 if (auto Err =
226 PlatformJD.define(reexports(ES.getBootstrapJITDylib(), *Exports)))
227 return Err;
228 }
229
230 // Create the instance.
231 Error Err = Error::success();
232 auto P = std::unique_ptr<COFFPlatform>(new COFFPlatform(
233 ObjLinkingLayer, PlatformJD, std::move(*OrcRuntimeArchiveGenerator),
234 std::move(DylibsToPreload), std::move(OrcRuntimeArchiveBuffer),
235 std::move(RuntimeArchive), std::move(LoadDynLibrary), StaticVCRuntime,
236 VCRuntimePath, Err));
237 if (Err)
238 return std::move(Err);
239 return std::move(P);
240}
241
244 const char *OrcRuntimePath,
245 LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
246 const char *VCRuntimePath,
247 std::optional<SymbolAliasMap> RuntimeAliases) {
248
249 auto ArchiveBuffer = MemoryBuffer::getFile(OrcRuntimePath);
250 if (!ArchiveBuffer)
251 return createFileError(OrcRuntimePath, ArchiveBuffer.getError());
252
253 return Create(ObjLinkingLayer, PlatformJD, std::move(*ArchiveBuffer),
254 std::move(LoadDynLibrary), StaticVCRuntime, VCRuntimePath,
255 std::move(RuntimeAliases));
256}
257
258Expected<MemoryBufferRef> COFFPlatform::getPerJDObjectFile() {
259 auto PerJDObj = OrcRuntimeArchive->findSym("__orc_rt_coff_per_jd_marker");
260 if (!PerJDObj)
261 return PerJDObj.takeError();
262
263 if (!*PerJDObj)
264 return make_error<StringError>("Could not find per jd object file",
266
267 auto Buffer = (*PerJDObj)->getAsBinary();
268 if (!Buffer)
269 return Buffer.takeError();
270
271 return (*Buffer)->getMemoryBufferRef();
272}
273
275 ArrayRef<std::pair<const char *, const char *>> AL) {
276 for (auto &KV : AL) {
277 auto AliasName = ES.intern(KV.first);
278 assert(!Aliases.count(AliasName) && "Duplicate symbol name in alias map");
279 Aliases[std::move(AliasName)] = {ES.intern(KV.second),
281 }
282}
283
285 if (auto Err = JD.define(std::make_unique<COFFHeaderMaterializationUnit>(
286 *this, COFFHeaderStartSymbol)))
287 return Err;
288
289 if (auto Err = ES.lookup({&JD}, COFFHeaderStartSymbol).takeError())
290 return Err;
291
292 // Define the CXX aliases.
293 SymbolAliasMap CXXAliases;
294 addAliases(ES, CXXAliases, requiredCXXAliases());
295 if (auto Err = JD.define(symbolAliases(std::move(CXXAliases))))
296 return Err;
297
298 auto PerJDObj = getPerJDObjectFile();
299 if (!PerJDObj)
300 return PerJDObj.takeError();
301
302 auto I = getObjectFileInterface(ES, *PerJDObj);
303 if (!I)
304 return I.takeError();
305
306 if (auto Err = ObjLinkingLayer.add(
307 JD, MemoryBuffer::getMemBuffer(*PerJDObj, false), std::move(*I)))
308 return Err;
309
310 if (!Bootstrapping) {
311 auto ImportedLibs = StaticVCRuntime
312 ? VCRuntimeBootstrap->loadStaticVCRuntime(JD)
313 : VCRuntimeBootstrap->loadDynamicVCRuntime(JD);
314 if (!ImportedLibs)
315 return ImportedLibs.takeError();
316 for (auto &Lib : *ImportedLibs)
317 if (auto Err = LoadDynLibrary(JD, Lib))
318 return Err;
319 if (StaticVCRuntime)
320 if (auto Err = VCRuntimeBootstrap->initializeStaticVCRuntime(JD))
321 return Err;
322 }
323
324 JD.addGenerator(DLLImportDefinitionGenerator::Create(ES, ObjLinkingLayer));
325 return Error::success();
326}
327
329 std::lock_guard<std::mutex> Lock(PlatformMutex);
330 auto I = JITDylibToHeaderAddr.find(&JD);
331 if (I != JITDylibToHeaderAddr.end()) {
332 assert(HeaderAddrToJITDylib.count(I->second) &&
333 "HeaderAddrToJITDylib missing entry");
334 HeaderAddrToJITDylib.erase(I->second);
335 JITDylibToHeaderAddr.erase(I);
336 }
337 return Error::success();
338}
339
341 const MaterializationUnit &MU) {
342 auto &JD = RT.getJITDylib();
343 const auto &InitSym = MU.getInitializerSymbol();
344 if (!InitSym)
345 return Error::success();
346
347 RegisteredInitSymbols[&JD].add(InitSym,
349
350 LLVM_DEBUG({
351 dbgs() << "COFFPlatform: Registered init symbol " << *InitSym << " for MU "
352 << MU.getName() << "\n";
353 });
354 return Error::success();
355}
356
360
366
369 static const std::pair<const char *, const char *> RequiredCXXAliases[] = {
370 {"_CxxThrowException", "__orc_rt_coff_cxx_throw_exception"},
371 {"_onexit", "__orc_rt_coff_onexit_per_jd"},
372 {"atexit", "__orc_rt_coff_atexit_per_jd"}};
373
374 return ArrayRef<std::pair<const char *, const char *>>(RequiredCXXAliases);
375}
376
379 static const std::pair<const char *, const char *>
380 StandardRuntimeUtilityAliases[] = {
381 {"__orc_rt_run_program", "__orc_rt_coff_run_program"},
382 {"__orc_rt_jit_dlerror", "__orc_rt_coff_jit_dlerror"},
383 {"__orc_rt_jit_dlopen", "__orc_rt_coff_jit_dlopen"},
384 {"__orc_rt_jit_dlupdate", "__orc_rt_coff_jit_dlupdate"},
385 {"__orc_rt_jit_dlclose", "__orc_rt_coff_jit_dlclose"},
386 {"__orc_rt_jit_dlsym", "__orc_rt_coff_jit_dlsym"},
387 {"__orc_rt_log_error", "__orc_rt_log_error_to_stderr"}};
388
390 StandardRuntimeUtilityAliases);
391}
392
393bool COFFPlatform::supportedTarget(const Triple &TT) {
394 switch (TT.getArch()) {
395 case Triple::x86_64:
396 return true;
397 default:
398 return false;
399 }
400}
401
402COFFPlatform::COFFPlatform(
403 ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD,
404 std::unique_ptr<StaticLibraryDefinitionGenerator> OrcRuntimeGenerator,
405 std::set<std::string> DylibsToPreload,
406 std::unique_ptr<MemoryBuffer> OrcRuntimeArchiveBuffer,
407 std::unique_ptr<object::Archive> OrcRuntimeArchive,
408 LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime,
409 const char *VCRuntimePath, Error &Err)
410 : ES(ObjLinkingLayer.getExecutionSession()),
411 ObjLinkingLayer(ObjLinkingLayer),
412 LoadDynLibrary(std::move(LoadDynLibrary)),
413 OrcRuntimeArchiveBuffer(std::move(OrcRuntimeArchiveBuffer)),
414 OrcRuntimeArchive(std::move(OrcRuntimeArchive)),
415 StaticVCRuntime(StaticVCRuntime),
416 COFFHeaderStartSymbol(ES.intern("__ImageBase")) {
418
419 Bootstrapping.store(true);
420 ObjLinkingLayer.addPlugin(std::make_unique<COFFPlatformPlugin>(*this));
421
422 // Load vc runtime
423 auto VCRT =
424 COFFVCRuntimeBootstrapper::Create(ES, ObjLinkingLayer, VCRuntimePath);
425 if (!VCRT) {
426 Err = VCRT.takeError();
427 return;
428 }
429 VCRuntimeBootstrap = std::move(*VCRT);
430
431 auto ImportedLibs =
432 StaticVCRuntime ? VCRuntimeBootstrap->loadStaticVCRuntime(PlatformJD)
433 : VCRuntimeBootstrap->loadDynamicVCRuntime(PlatformJD);
434 if (!ImportedLibs) {
435 Err = ImportedLibs.takeError();
436 return;
437 }
438
439 for (auto &Lib : *ImportedLibs)
440 DylibsToPreload.insert(Lib);
441
442 PlatformJD.addGenerator(std::move(OrcRuntimeGenerator));
443
444 // PlatformJD hasn't been set up by the platform yet (since we're creating
445 // the platform now), so set it up.
446 if (auto E2 = setupJITDylib(PlatformJD)) {
447 Err = std::move(E2);
448 return;
449 }
450
451 for (auto& Lib : DylibsToPreload)
452 if (auto E2 = this->LoadDynLibrary(PlatformJD, Lib)) {
453 Err = std::move(E2);
454 return;
455 }
456
457 if (StaticVCRuntime)
458 if (auto E2 = VCRuntimeBootstrap->initializeStaticVCRuntime(PlatformJD)) {
459 Err = std::move(E2);
460 return;
461 }
462
463 // Associate wrapper function tags with JIT-side function implementations.
464 if (auto E2 = associateRuntimeSupportFunctions(PlatformJD)) {
465 Err = std::move(E2);
466 return;
467 }
468
469 // Lookup addresses of runtime functions callable by the platform,
470 // call the platform bootstrap function to initialize the platform-state
471 // object in the executor.
472 if (auto E2 = bootstrapCOFFRuntime(PlatformJD)) {
473 Err = std::move(E2);
474 return;
475 }
476
477 Bootstrapping.store(false);
478 JDBootstrapStates.clear();
479}
480
481Expected<COFFPlatform::JITDylibDepMap>
482COFFPlatform::buildJDDepMap(JITDylib &JD) {
483 return ES.runSessionLocked([&]() -> Expected<JITDylibDepMap> {
484 JITDylibDepMap JDDepMap;
485
486 SmallVector<JITDylib *, 16> Worklist({&JD});
487 while (!Worklist.empty()) {
488 auto CurJD = Worklist.back();
489 Worklist.pop_back();
490
491 auto &DM = JDDepMap[CurJD];
492 CurJD->withLinkOrderDo([&](const JITDylibSearchOrder &O) {
493 DM.reserve(O.size());
494 for (auto &KV : O) {
495 if (KV.first == CurJD)
496 continue;
497 {
498 // Bare jitdylibs not known to the platform
499 std::lock_guard<std::mutex> Lock(PlatformMutex);
500 if (!JITDylibToHeaderAddr.count(KV.first)) {
501 LLVM_DEBUG({
502 dbgs() << "JITDylib unregistered to COFFPlatform detected in "
503 "LinkOrder: "
504 << CurJD->getName() << "\n";
505 });
506 continue;
507 }
508 }
509 DM.push_back(KV.first);
510 // Push unvisited entry.
511 if (JDDepMap.try_emplace(KV.first).second)
512 Worklist.push_back(KV.first);
513 }
514 });
515 }
516 return std::move(JDDepMap);
517 });
518}
519
520void COFFPlatform::pushInitializersLoop(PushInitializersSendResultFn SendResult,
521 JITDylibSP JD,
522 JITDylibDepMap &JDDepMap) {
523 SmallVector<JITDylib *, 16> Worklist({JD.get()});
524 DenseSet<JITDylib *> Visited({JD.get()});
525 DenseMap<JITDylib *, SymbolLookupSet> NewInitSymbols;
526 ES.runSessionLocked([&]() {
527 while (!Worklist.empty()) {
528 auto CurJD = Worklist.back();
529 Worklist.pop_back();
530
531 auto RISItr = RegisteredInitSymbols.find(CurJD);
532 if (RISItr != RegisteredInitSymbols.end()) {
533 NewInitSymbols[CurJD] = std::move(RISItr->second);
534 RegisteredInitSymbols.erase(RISItr);
535 }
536
537 for (auto *DepJD : JDDepMap[CurJD])
538 if (Visited.insert(DepJD).second)
539 Worklist.push_back(DepJD);
540 }
541 });
542
543 // If there are no further init symbols to look up then send the link order
544 // (as a list of header addresses) to the caller.
545 if (NewInitSymbols.empty()) {
546 // Build the dep info map to return.
547 COFFJITDylibDepInfoMap DIM;
548 DIM.reserve(JDDepMap.size());
549 for (auto &KV : JDDepMap) {
550 std::lock_guard<std::mutex> Lock(PlatformMutex);
551 COFFJITDylibDepInfo DepInfo;
552 DepInfo.reserve(KV.second.size());
553 for (auto &Dep : KV.second) {
554 DepInfo.push_back(JITDylibToHeaderAddr[Dep]);
555 }
556 auto H = JITDylibToHeaderAddr[KV.first];
557 DIM.push_back(std::make_pair(H, std::move(DepInfo)));
558 }
559 SendResult(DIM);
560 return;
561 }
562
563 // Otherwise issue a lookup and re-run this phase when it completes.
565 [this, SendResult = std::move(SendResult), &JD,
566 JDDepMap = std::move(JDDepMap)](Error Err) mutable {
567 if (Err)
568 SendResult(std::move(Err));
569 else
570 pushInitializersLoop(std::move(SendResult), JD, JDDepMap);
571 },
572 ES, std::move(NewInitSymbols));
573}
574
575void COFFPlatform::rt_pushInitializers(PushInitializersSendResultFn SendResult,
576 ExecutorAddr JDHeaderAddr) {
577 JITDylibSP JD;
578 {
579 std::lock_guard<std::mutex> Lock(PlatformMutex);
580 auto I = HeaderAddrToJITDylib.find(JDHeaderAddr);
581 if (I != HeaderAddrToJITDylib.end())
582 JD = I->second;
583 }
584
585 LLVM_DEBUG({
586 dbgs() << "COFFPlatform::rt_pushInitializers(" << JDHeaderAddr << ") ";
587 if (JD)
588 dbgs() << "pushing initializers for " << JD->getName() << "\n";
589 else
590 dbgs() << "No JITDylib for header address.\n";
591 });
592
593 if (!JD) {
594 SendResult(make_error<StringError>("No JITDylib with header addr " +
595 formatv("{0:x}", JDHeaderAddr),
597 return;
598 }
599
600 auto JDDepMap = buildJDDepMap(*JD);
601 if (!JDDepMap) {
602 SendResult(JDDepMap.takeError());
603 return;
604 }
605
606 pushInitializersLoop(std::move(SendResult), JD, *JDDepMap);
607}
608
609void COFFPlatform::rt_lookupSymbol(SendSymbolAddressFn SendResult,
610 ExecutorAddr Handle, StringRef SymbolName) {
611 LLVM_DEBUG(dbgs() << "COFFPlatform::rt_lookupSymbol(\"" << Handle << "\")\n");
612
613 JITDylib *JD = nullptr;
614
615 {
616 std::lock_guard<std::mutex> Lock(PlatformMutex);
617 auto I = HeaderAddrToJITDylib.find(Handle);
618 if (I != HeaderAddrToJITDylib.end())
619 JD = I->second;
620 }
621
622 if (!JD) {
623 LLVM_DEBUG(dbgs() << " No JITDylib for handle " << Handle << "\n");
624 SendResult(make_error<StringError>("No JITDylib associated with handle " +
625 formatv("{0:x}", Handle),
627 return;
628 }
629
630 // Use functor class to work around XL build compiler issue on AIX.
631 class RtLookupNotifyComplete {
632 public:
633 RtLookupNotifyComplete(SendSymbolAddressFn &&SendResult)
634 : SendResult(std::move(SendResult)) {}
635 void operator()(Expected<SymbolMap> Result) {
636 if (Result) {
637 assert(Result->size() == 1 && "Unexpected result map count");
638 SendResult(Result->begin()->second.getAddress());
639 } else {
640 SendResult(Result.takeError());
641 }
642 }
643
644 private:
645 SendSymbolAddressFn SendResult;
646 };
647
648 ES.lookup(
650 SymbolLookupSet(ES.intern(SymbolName)), SymbolState::Ready,
651 RtLookupNotifyComplete(std::move(SendResult)), NoDependenciesToRegister);
652}
653
654Error COFFPlatform::associateRuntimeSupportFunctions(JITDylib &PlatformJD) {
656
657 using LookupSymbolSPSSig =
658 SPSExpected<SPSExecutorAddr>(SPSExecutorAddr, SPSString);
659 WFs[ES.intern("__orc_rt_coff_symbol_lookup_tag")] =
660 ES.wrapAsyncWithSPS<LookupSymbolSPSSig>(this,
661 &COFFPlatform::rt_lookupSymbol);
662 using PushInitializersSPSSig =
663 SPSExpected<SPSCOFFJITDylibDepInfoMap>(SPSExecutorAddr);
664 WFs[ES.intern("__orc_rt_coff_push_initializers_tag")] =
665 ES.wrapAsyncWithSPS<PushInitializersSPSSig>(
666 this, &COFFPlatform::rt_pushInitializers);
667
668 return ES.registerJITDispatchHandlers(PlatformJD, std::move(WFs));
669}
670
671Error COFFPlatform::runBootstrapInitializers(JDBootstrapState &BState) {
672 llvm::sort(BState.Initializers);
673 if (auto Err =
674 runBootstrapSubsectionInitializers(BState, ".CRT$XIA", ".CRT$XIZ"))
675 return Err;
676
677 if (auto Err = runSymbolIfExists(*BState.JD, "__run_after_c_init"))
678 return Err;
679
680 if (auto Err =
681 runBootstrapSubsectionInitializers(BState, ".CRT$XCA", ".CRT$XCZ"))
682 return Err;
683 return Error::success();
684}
685
686Error COFFPlatform::runBootstrapSubsectionInitializers(JDBootstrapState &BState,
687 StringRef Start,
688 StringRef End) {
689 CallInt32VoidProxy CallInitializer;
690 if (auto Err = lookupAndApply(
691 ES.getBootstrapJITDylib(),
692 {recordProxy<sps::CallInt32VoidProxySpec>(&CallInitializer)}))
693 return Err;
694 for (auto &Initializer : BState.Initializers)
695 if (Initializer.first >= Start && Initializer.first <= End &&
696 Initializer.second) {
697 auto Res = CallInitializer(ES, Initializer.second);
698 if (!Res)
699 return Res.takeError();
700 }
701 return Error::success();
702}
703
704Error COFFPlatform::bootstrapCOFFRuntime(JITDylib &PlatformJD) {
705 // Lookup of runtime symbols causes the collection of initializers if
706 // it's static linking setting.
707 if (auto Err = lookupAndApply(
708 PlatformJD,
709 {recordAddr(
710 SymbolNameSpec::verbatim("__orc_rt_coff_platform_bootstrap"),
711 &orc_rt_coff_platform_bootstrap),
713 SymbolNameSpec::verbatim("__orc_rt_coff_platform_shutdown"),
714 &orc_rt_coff_platform_shutdown),
716 SymbolNameSpec::verbatim("__orc_rt_coff_register_jitdylib"),
717 &orc_rt_coff_register_jitdylib),
719 SymbolNameSpec::verbatim("__orc_rt_coff_deregister_jitdylib"),
720 &orc_rt_coff_deregister_jitdylib),
722 "__orc_rt_coff_register_object_sections"),
723 &orc_rt_coff_register_object_sections),
725 "__orc_rt_coff_deregister_object_sections"),
726 &orc_rt_coff_deregister_object_sections)}))
727 return Err;
728
729 // These runtime entry points are held as addresses because their primary use
730 // is as alloc-action tags (see the register/deregister sites below). The
731 // direct dispatches here are a bootstrap-time artifact, so rather than
732 // holding proxies as members we build them over the resolved addresses.
733 // TODO: drop these dispatches once bootstrap no longer needs them.
734 using PlatformBootstrapProxy = Proxy<void()>;
735 using RegisterJITDylibProxy = Proxy<void(std::string, ExecutorAddr)>;
736 using RegisterObjectSectionsProxy =
737 Proxy<void(ExecutorAddr, COFFObjectSectionsMap, bool)>;
738 using sps::ProxySpec;
739
740 PlatformBootstrapProxy PlatformBootstrap(
741 ProxySpec<PlatformBootstrapProxy,
742 coff_sps_ci::PlatformBootstrap>::dispatch,
743 orc_rt_coff_platform_bootstrap);
744 RegisterJITDylibProxy RegisterJITDylib(
745 ProxySpec<RegisterJITDylibProxy, coff_sps_ci::RegisterJITDylib>::dispatch,
746 orc_rt_coff_register_jitdylib);
747 RegisterObjectSectionsProxy RegisterObjectSections(
748 ProxySpec<RegisterObjectSectionsProxy,
749 coff_sps_ci::RegisterObjectSections>::dispatch,
750 orc_rt_coff_register_object_sections);
751
752 // Call bootstrap functions
753 if (auto Err = PlatformBootstrap(ES))
754 return Err;
755
756 // Do the pending jitdylib registration actions that we couldn't do
757 // because orc runtime was not linked fully.
758 for (auto KV : JDBootstrapStates) {
759 auto &JDBState = KV.second;
760 if (auto Err = RegisterJITDylib(ES, JDBState.JDName, JDBState.HeaderAddr))
761 return Err;
762
763 for (auto &ObjSectionMap : JDBState.ObjectSectionsMaps)
764 if (auto Err = RegisterObjectSections(ES, JDBState.HeaderAddr,
765 ObjSectionMap, false))
766 return Err;
767 }
768
769 // Run static initializers collected in bootstrap stage.
770 for (auto KV : JDBootstrapStates) {
771 auto &JDBState = KV.second;
772 if (auto Err = runBootstrapInitializers(JDBState))
773 return Err;
774 }
775
776 return Error::success();
777}
778
779Error COFFPlatform::runSymbolIfExists(JITDylib &PlatformJD,
780 StringRef SymbolName) {
781 ExecutorAddr TargetFn;
782 if (auto Err = lookupAndApply(
783 PlatformJD,
784 {recordAddr(SymbolNameSpec::verbatim(SymbolName), &TargetFn,
786 return Err;
787 if (!TargetFn)
788 return Error::success(); // No target function.
789
790 CallInt32VoidProxy CallFn;
791 if (auto Err =
792 lookupAndApply(ES.getBootstrapJITDylib(),
793 {recordProxy<sps::CallInt32VoidProxySpec>(&CallFn)}))
794 return Err;
795
796 return CallFn(ES, TargetFn).takeError();
797}
798
799void COFFPlatform::COFFPlatformPlugin::modifyPassConfig(
800 MaterializationResponsibility &MR, jitlink::LinkGraph &LG,
801 jitlink::PassConfiguration &Config) {
802
803 bool IsBootstrapping = CP.Bootstrapping.load();
804
805 if (auto InitSymbol = MR.getInitializerSymbol()) {
806 if (InitSymbol == CP.COFFHeaderStartSymbol) {
807 Config.PostAllocationPasses.push_back(
808 [this, &MR, IsBootstrapping](jitlink::LinkGraph &G) {
809 return associateJITDylibHeaderSymbol(G, MR, IsBootstrapping);
810 });
811 return;
812 }
813 Config.PrePrunePasses.push_back([this, &MR](jitlink::LinkGraph &G) {
814 return preserveInitializerSections(G, MR);
815 });
816 }
817
818 if (!IsBootstrapping)
819 Config.PostFixupPasses.push_back(
820 [this, &JD = MR.getTargetJITDylib()](jitlink::LinkGraph &G) {
821 return registerObjectPlatformSections(G, JD);
822 });
823 else
824 Config.PostFixupPasses.push_back(
825 [this, &JD = MR.getTargetJITDylib()](jitlink::LinkGraph &G) {
826 return registerObjectPlatformSectionsInBootstrap(G, JD);
827 });
828}
829
830Error COFFPlatform::COFFPlatformPlugin::associateJITDylibHeaderSymbol(
831 jitlink::LinkGraph &G, MaterializationResponsibility &MR,
832 bool IsBootstraping) {
833 auto I = llvm::find_if(G.defined_symbols(), [this](jitlink::Symbol *Sym) {
834 return *Sym->getName() == *CP.COFFHeaderStartSymbol;
835 });
836 assert(I != G.defined_symbols().end() && "Missing COFF header start symbol");
837
838 auto &JD = MR.getTargetJITDylib();
839 std::lock_guard<std::mutex> Lock(CP.PlatformMutex);
840 auto HeaderAddr = (*I)->getAddress();
841 CP.JITDylibToHeaderAddr[&JD] = HeaderAddr;
842 CP.HeaderAddrToJITDylib[HeaderAddr] = &JD;
843 if (!IsBootstraping) {
844 G.allocActions().push_back(
846 SPSArgList<SPSString, SPSExecutorAddr>>(
847 CP.orc_rt_coff_register_jitdylib, JD.getName(), HeaderAddr)),
848 cantFail(WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddr>>(
849 CP.orc_rt_coff_deregister_jitdylib, HeaderAddr))});
850 } else {
851 G.allocActions().push_back(
852 {{},
853 cantFail(WrapperFunctionCall::Create<SPSArgList<SPSExecutorAddr>>(
854 CP.orc_rt_coff_deregister_jitdylib, HeaderAddr))});
855 JDBootstrapState BState;
856 BState.JD = &JD;
857 BState.JDName = JD.getName();
858 BState.HeaderAddr = HeaderAddr;
859 CP.JDBootstrapStates.emplace(&JD, BState);
860 }
861
862 return Error::success();
863}
864
865Error COFFPlatform::COFFPlatformPlugin::registerObjectPlatformSections(
866 jitlink::LinkGraph &G, JITDylib &JD) {
867 COFFObjectSectionsMap ObjSecs;
868 auto HeaderAddr = CP.JITDylibToHeaderAddr[&JD];
869 assert(HeaderAddr && "Must be registered jitdylib");
870 for (auto &S : G.sections()) {
871 jitlink::SectionRange Range(S);
872 if (Range.getSize())
873 ObjSecs.push_back(std::make_pair(S.getName().str(), Range.getRange()));
874 }
875
876 G.allocActions().push_back(
878 CP.orc_rt_coff_register_object_sections, HeaderAddr, ObjSecs, true)),
879 cantFail(
881 CP.orc_rt_coff_deregister_object_sections, HeaderAddr,
882 ObjSecs))});
883
884 return Error::success();
885}
886
887Error COFFPlatform::COFFPlatformPlugin::preserveInitializerSections(
888 jitlink::LinkGraph &G, MaterializationResponsibility &MR) {
889
890 if (const auto &InitSymName = MR.getInitializerSymbol()) {
891
892 jitlink::Symbol *InitSym = nullptr;
893
894 for (auto &InitSection : G.sections()) {
895 // Skip non-init sections.
896 if (!isCOFFInitializerSection(InitSection.getName()) ||
897 InitSection.empty())
898 continue;
899
900 // Create the init symbol if it has not been created already and attach it
901 // to the first block.
902 if (!InitSym) {
903 auto &B = **InitSection.blocks().begin();
904 InitSym = &G.addDefinedSymbol(
905 B, 0, *InitSymName, B.getSize(), jitlink::Linkage::Strong,
907 }
908
909 // Add keep-alive edges to anonymous symbols in all other init blocks.
910 for (auto *B : InitSection.blocks()) {
911 if (B == &InitSym->getBlock())
912 continue;
913
914 auto &S = G.addAnonymousSymbol(*B, 0, B->getSize(), false, true);
915 InitSym->getBlock().addEdge(jitlink::Edge::KeepAlive, 0, S, 0);
916 }
917 }
918 }
919
920 return Error::success();
921}
922
923Error COFFPlatform::COFFPlatformPlugin::
924 registerObjectPlatformSectionsInBootstrap(jitlink::LinkGraph &G,
925 JITDylib &JD) {
926 std::lock_guard<std::mutex> Lock(CP.PlatformMutex);
927 auto HeaderAddr = CP.JITDylibToHeaderAddr[&JD];
928 COFFObjectSectionsMap ObjSecs;
929 for (auto &S : G.sections()) {
930 jitlink::SectionRange Range(S);
931 if (Range.getSize())
932 ObjSecs.push_back(std::make_pair(S.getName().str(), Range.getRange()));
933 }
934
935 G.allocActions().push_back(
936 {{},
937 cantFail(
939 CP.orc_rt_coff_deregister_object_sections, HeaderAddr,
940 ObjSecs))});
941
942 auto &BState = CP.JDBootstrapStates[&JD];
943 BState.ObjectSectionsMaps.push_back(std::move(ObjSecs));
944
945 // Collect static initializers
946 for (auto &S : G.sections())
947 if (isCOFFInitializerSection(S.getName()))
948 for (auto *B : S.blocks()) {
949 if (B->edges_empty())
950 continue;
951 for (auto &E : B->edges())
952 BState.Initializers.push_back(std::make_pair(
953 S.getName().str(), E.getTarget().getAddress() + E.getAddend()));
954 }
955
956 return Error::success();
957}
958
959} // End namespace orc.
960} // End namespace llvm.
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static RegisterPass< DebugifyModulePass > DM("debugify", "Attach debug info to everything")
#define _
#define offsetof(TYPE, MEMBER)
#define I(x, y, z)
Definition MD5.cpp:57
#define G(x, y, z)
Definition MD5.cpp:55
#define H(x, y, z)
Definition MD5.cpp:56
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
#define P(N)
static StringRef getName(Value *V)
#define LLVM_DEBUG(...)
Definition Debug.h:119
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
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:254
Helper for Errors used as out-parameters.
Definition Error.h:1160
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Tagged union holding either a T or a Error.
Definition Error.h:485
Error takeError()
Take ownership of the stored error.
Definition Error.h:612
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, bool IsVolatile=false, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful,...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Manages the enabling and disabling of subtarget specific features.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
static Expected< std::unique_ptr< Archive > > create(MemoryBufferRef Source)
Definition Archive.cpp:785
Mediates between COFF initialization and ExecutionSession state.
Error setupJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is created (unless it is cre...
static Expected< std::unique_ptr< COFFPlatform > > Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr< MemoryBuffer > OrcRuntimeArchiveBuffer, LoadDynamicLibrary LoadDynLibrary, bool StaticVCRuntime=false, const char *VCRuntimePath=nullptr, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt)
Try to create a COFFPlatform instance, adding the ORC runtime to the given JITDylib.
unique_function< Error(JITDylib &JD, StringRef DLLFileName)> LoadDynamicLibrary
A function that will be called with the name of dll file that must be loaded.
static ArrayRef< std::pair< const char *, const char * > > standardRuntimeUtilityAliases()
Returns the array of standard runtime utility aliases for COFF.
Error teardownJITDylib(JITDylib &JD) override
This method will be called outside the session lock each time a JITDylib is removed to allow the Plat...
static SymbolAliasMap standardPlatformAliases(ExecutionSession &ES)
Returns an AliasMap containing the default aliases for the COFFPlatform.
Error notifyAdding(ResourceTracker &RT, const MaterializationUnit &MU) override
This method will be called under the ExecutionSession lock each time a MaterializationUnit is added t...
static ArrayRef< std::pair< const char *, const char * > > requiredCXXAliases()
Returns the array of required CXX aliases.
Error notifyRemoving(ResourceTracker &RT) override
This method will be called under the ExecutionSession lock when a ResourceTracker is removed.
static LLVM_ABI Expected< std::unique_ptr< COFFVCRuntimeBootstrapper > > Create(ExecutionSession &ES, ObjectLinkingLayer &ObjLinkingLayer, const char *RuntimePath=nullptr)
Try to create a COFFVCRuntimeBootstrapper instance.
static std::unique_ptr< DLLImportDefinitionGenerator > Create(ExecutionSession &ES, ObjectLinkingLayer &L)
Creates a DLLImportDefinitionGenerator instance.
An ExecutionSession represents a running JIT program.
Definition Core.h:1111
SymbolStringPtr intern(StringRef SymName)
Add a symbol name to the SymbolStringPool and return a pointer to it.
Definition Core.h:1170
DenseMap< SymbolStringPtr, JITDispatchHandlerFunction > JITDispatchHandlerAssociationMap
A map associating tag names with asynchronous wrapper function implementations in the JIT.
Definition Core.h:1134
Represents an address in the executor process.
Represents a JIT'd dynamic library.
Definition Core.h:675
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:1654
GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)
Adds a definition generator to this JITDylib and returns a referenece to it.
Definition Core.h:1637
LinkGraphLinkingLayer & addPlugin(std::shared_ptr< Plugin > P)
Add a plugin.
Mangles symbol names then uniques them in the context of an ExecutionSession.
Definition Mangling.h:28
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Definition Core.h:349
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization pseudo-symbol, if any.
Definition Core.h:388
JITDylib & getTargetJITDylib() const
Returns the target JITDylib that these symbols are being materialized into.
Definition Core.h:374
A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...
virtual StringRef getName() const =0
Return the name of this materialization unit.
const SymbolStringPtr & getInitializerSymbol() const
Returns the initialization symbol for this MaterializationUnit (if any).
An ObjectLayer implementation built on JITLink.
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:1489
API to remove / transfer ownership of JIT resources.
Definition Core.h:63
JITDylib & getJITDylib() const
Return the JITDylib targeted by this tracker.
Definition Core.h:78
static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Create(ObjectLayer &L, std::unique_ptr< MemoryBuffer > ArchiveBuffer, std::unique_ptr< object::Archive > Archive, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())
Try to create a StaticLibrarySearchGenerator from the given memory buffer and Archive object.
A symbol name together with the naming level (SymbolNameKind) it is expressed in, so that a Mangler /...
static constexpr SymbolNameSpec verbatim(StringRef Name)
Pointer to a pooled string representing a symbol name.
A utility class for serializing to a blob from a variadic list.
static Expected< WrapperFunctionCall > Create(ExecutorAddr FnAddr, const ArgTs &...Args)
Create a WrapperFunctionCall using the given SPS serializer to serialize the arguments.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ IMAGE_FILE_MACHINE_AMD64
Definition COFF.h:98
@ NUM_DATA_DIRECTORIES
Definition COFF.h:647
static const char PEMagic[]
Definition COFF.h:36
SPSSequence< SPSExecutorAddr > SPSCOFFJITDylibDepInfo
SPSSequence< char > SPSString
SPS tag type for strings, which are equivalent to sequences of chars.
SPSArgList< SPSExecutorAddr, SPSCOFFObjectSectionsMap, bool > SPSCOFFRegisterObjectSectionsArgs
SPSSequence< SPSTuple< SPSString, SPSExecutorAddrRange > > SPSCOFFObjectSectionsMap
SPSSequence< SPSTuple< SPSExecutorAddr, SPSCOFFJITDylibDepInfo > > SPSCOFFJITDylibDepInfoMap
SPSArgList< SPSExecutorAddr, SPSCOFFObjectSectionsMap > SPSCOFFDeregisterObjectSectionsArgs
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:148
IntrusiveRefCntPtr< JITDylib > JITDylibSP
Definition Core.h:58
Proxy< int32_t(ExecutorAddr)> CallInt32VoidProxy
Protocol-agnostic interface for running an int32_t() function in the executor.
Definition CallProxies.h:45
std::unique_ptr< ReExportsMaterializationUnit > symbolAliases(SymbolAliasMap Aliases)
Create a ReExportsMaterializationUnit with the given aliases.
Definition Core.h:523
LLVM_ABI void lookupAndApply(unique_function< void(Error)> OnApplied, LookupKind K, const JITDylibSearchOrder &SearchOrder, ArrayRef< LookupPrepareFn > PrepareFns)
Resolve the symbols contributed by every prepare function with a single lookup, then let each of thei...
std::unique_ptr< ReExportsMaterializationUnit > reexports(JITDylib &SourceJD, SymbolAliasMap Aliases, JITDylibLookupFlags SourceJDLookupFlags=JITDylibLookupFlags::MatchExportedSymbolsOnly)
Create a materialization unit for re-exporting symbols from another JITDylib with alternative names/f...
Definition Core.h:532
LookupPrepareFn recordAddr(SymbolNameSpec Name, ExecutorAddr *A, SymbolLookupFlags LF=SymbolLookupFlags::RequiredSymbol)
Records the address of the symbol with the given name.
static void addAliases(ExecutionSession &ES, SymbolAliasMap &Aliases, ArrayRef< std::pair< const char *, const char * > > AL)
LLVM_ABI Expected< MaterializationUnit::Interface > getObjectFileInterface(ExecutionSession &ES, MemoryBufferRef ObjBuffer)
Returns a MaterializationUnit::Interface for the object file contained in the given buffer,...
jitlink::Block & createHeaderBlock(MachOPlatform &MOP, const MachOPlatform::HeaderOptions &Opts, JITDylib &JD, jitlink::LinkGraph &G, jitlink::Section &HeaderSection)
LLVM_ABI RegisterDependenciesFunction NoDependenciesToRegister
This can be used as the value for a RegisterDependenciesFunction if there are no dependants to regist...
Definition Core.cpp:40
LLVM_ABI bool isCOFFInitializerSection(StringRef Name)
@ Ready
Emitted to memory, but waiting on transitive dependencies.
Definition Core.h:551
DenseMap< SymbolStringPtr, SymbolAliasMapEntry > SymbolAliasMap
A map of Symbols to (Symbol, Flags) pairs.
Definition Core.h:173
LLVM_ABI Expected< SymbolAliasMap > buildSimpleReexportsAliasMap(JITDylib &SourceJD, const SymbolNameSet &Symbols)
Build a SymbolAliasMap for the common case where you want to re-export symbols from another JITDylib ...
Definition Core.cpp:482
DenseMap< SymbolStringPtr, JITSymbolFlags > SymbolFlagsMap
A map from symbol names (as SymbolStringPtrs) to JITSymbolFlags.
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
Definition Endian.h:270
This is an optimization pass for GlobalISel generic memory operations.
Error createFileError(const Twine &F, Error E)
Concatenate a source file path and/or name with an Error.
Definition Error.h:1415
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void sort(IteratorTy Start, IteratorTy End)
Definition STLExtras.h:1652
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition Error.h:769
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:1933
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1788
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
static constexpr SymbolNameSpec Name
void(SPSString, SPSExecutorAddr) SPSSig
static constexpr SymbolNameSpec Name
void(SPSExecutorAddr, SPSCOFFObjectSectionsMap, bool) SPSSig