LLVM: lib/ExecutionEngine/Orc/LLJIT.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

10

12#include "llvm/Config/llvm-config.h"

31

32#define DEBUG_TYPE "orc"

33

34using namespace llvm;

36

37namespace {

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

58 std::vector<Type *> HelperArgTypes;

59 for (auto *Arg : HelperPrefixArgs)

60 HelperArgTypes.push_back(Arg->getType());

62 auto *HelperFnType =

63 FunctionType::get(WrapperFnType->getReturnType(), HelperArgTypes, false);

65 HelperName, M);

66

69 WrapperFn->setVisibility(WrapperVisibility);

70

71 auto *EntryBlock = BasicBlock::Create(M.getContext(), "entry", WrapperFn);

73

74 std::vector<Value *> HelperArgs;

76 for (auto &Arg : WrapperFn->args())

77 HelperArgs.push_back(&Arg);

78 auto *HelperResult = IB.CreateCall(HelperFn, HelperArgs);

79 if (HelperFn->getReturnType()->isVoidTy())

80 IB.CreateRetVoid();

81 else

82 IB.CreateRet(HelperResult);

83

84 return WrapperFn;

85}

86

87class GenericLLVMIRPlatformSupport;

88

89

90

91class GenericLLVMIRPlatform : public Platform {

92public:

93 GenericLLVMIRPlatform(GenericLLVMIRPlatformSupport &S) : S(S) {}

99

101 }

102

103private:

104 GenericLLVMIRPlatformSupport &S;

105};

106

107

108

109

110class GlobalCtorDtorScraper {

111public:

112 GlobalCtorDtorScraper(GenericLLVMIRPlatformSupport &PS,

115 : PS(PS), InitFunctionPrefix(InitFunctionPrefix),

116 DeInitFunctionPrefix(DeInitFunctionPrefix) {}

119

120private:

121 GenericLLVMIRPlatformSupport &PS;

124};

125

126

127

128

129

130

132public:

133 GenericLLVMIRPlatformSupport(LLJIT &J, JITDylib &PlatformJD)

134 : J(J), InitFunctionPrefix(J.mangle("__orc_init_func.")),

135 DeInitFunctionPrefix(J.mangle("__orc_deinit_func.")) {

136

137 getExecutionSession().setPlatform(

138 std::make_unique(*this));

139

140 setInitTransform(J, GlobalCtorDtorScraper(*this, InitFunctionPrefix,

141 DeInitFunctionPrefix));

142

144

145 StdInterposes[J.mangleAndIntern("__lljit.platform_support_instance")] = {

147 StdInterposes[J.mangleAndIntern("__lljit.cxa_atexit_helper")] = {

149

151 cantFail(setupJITDylib(PlatformJD));

153 }

154

156

157

159

160

162 PerJDInterposes[J.mangleAndIntern("__lljit.run_atexits_helper")] = {

164 PerJDInterposes[J.mangleAndIntern("__lljit.atexit_helper")] = {

167

168 auto Ctx = std::make_unique();

169 auto M = std::make_unique("__standard_lib", *Ctx);

171

175 ConstantInt::get(Int64Ty, reinterpret_cast<uintptr_t>(&JD)),

176 "__dso_handle");

178 DSOHandle->setInitializer(

180

181 auto *GenericIRPlatformSupportTy =

183

186 nullptr, "__lljit.platform_support_instance");

187

189 addHelperAndWrapper(

192 {PlatformInstanceDecl, DSOHandle});

193

194 auto *IntTy = Type::getIntNTy(*Ctx, sizeof(int) * CHAR_BIT);

196 auto *AtExit = addHelperAndWrapper(

197 *M, "atexit", FunctionType::get(IntTy, {AtExitCallbackPtrTy}, false),

199 {PlatformInstanceDecl, DSOHandle});

201 TargetLibraryInfo::getExtAttrForI32Return(J.getTargetTriple());

203 AtExit->addRetAttr(AtExitExtAttr);

204

206 }

207

212 else {

213

214

215

216

217

219 if ((*KV.first).starts_with(InitFunctionPrefix)) {

220 InitSymbols[&JD].add(KV.first,

222 InitFunctions[&JD].add(KV.first);

223 } else if ((*KV.first).starts_with(DeInitFunctionPrefix)) {

224 DeInitFunctions[&JD].add(KV.first);

225 }

226 }

228 }

229

232 dbgs() << "GenericLLVMIRPlatformSupport getting initializers to run\n";

233 });

234 if (auto Initializers = getInitializers(JD)) {

236 { dbgs() << "GenericLLVMIRPlatformSupport running initializers\n"; });

237 for (auto InitFnAddr : *Initializers) {

239 dbgs() << " Running init " << formatv("{0:x16}", InitFnAddr)

240 << "...\n";

241 });

242 auto *InitFn = InitFnAddr.toPtr<void (*)()>();

243 InitFn();

244 }

245 } else

246 return Initializers.takeError();

248 }

249

252 dbgs() << "GenericLLVMIRPlatformSupport getting deinitializers to run\n";

253 });

254 if (auto Deinitializers = getDeinitializers(JD)) {

256 dbgs() << "GenericLLVMIRPlatformSupport running deinitializers\n";

257 });

258 for (auto DeinitFnAddr : *Deinitializers) {

260 dbgs() << " Running deinit " << formatv("{0:x16}", DeinitFnAddr)

261 << "...\n";

262 });

263 auto *DeinitFn = DeinitFnAddr.toPtr<void (*)()>();

264 DeinitFn();

265 }

266 } else

267 return Deinitializers.takeError();

268

270 }

271

273 getExecutionSession().runSessionLocked(

274 [&]() { InitFunctions[&JD].add(InitName); });

275 }

276

278 getExecutionSession().runSessionLocked(

279 [&]() { DeInitFunctions[&JD].add(DeInitName); });

280 }

281

282private:

284 if (auto Err = issueInitLookups(JD))

285 return std::move(Err);

286

288 std::vector DFSLinkOrder;

289

290 if (auto Err = getExecutionSession().runSessionLocked([&]() -> Error {

292 DFSLinkOrder = std::move(*DFSLinkOrderOrErr);

293 else

294 return DFSLinkOrderOrErr.takeError();

295

296 for (auto &NextJD : DFSLinkOrder) {

297 auto IFItr = InitFunctions.find(NextJD.get());

298 if (IFItr != InitFunctions.end()) {

299 LookupSymbols[NextJD.get()] = std::move(IFItr->second);

300 InitFunctions.erase(IFItr);

301 }

302 }

304 }))

305 return std::move(Err);

306

308 dbgs() << "JITDylib init order is [ ";

310 dbgs() << "\"" << JD->getName() << "\" ";

311 dbgs() << "]\n";

312 dbgs() << "Looking up init functions:\n";

313 for (auto &KV : LookupSymbols)

314 dbgs() << " \"" << KV.first->getName() << "\": " << KV.second << "\n";

315 });

316

317 auto &ES = getExecutionSession();

319

320 if (!LookupResult)

321 return LookupResult.takeError();

322

323 std::vector Initializers;

324 while (!DFSLinkOrder.empty()) {

325 auto &NextJD = *DFSLinkOrder.back();

326 DFSLinkOrder.pop_back();

327 auto InitsItr = LookupResult->find(&NextJD);

328 if (InitsItr == LookupResult->end())

329 continue;

330 for (auto &KV : InitsItr->second)

331 Initializers.push_back(KV.second.getAddress());

332 }

333

334 return Initializers;

335 }

336

338 auto &ES = getExecutionSession();

339

340 auto LLJITRunAtExits = J.mangleAndIntern("__lljit_run_atexits");

341

343 std::vector DFSLinkOrder;

344

345 if (auto Err = ES.runSessionLocked([&]() -> Error {

346 if (auto DFSLinkOrderOrErr = JD.getDFSLinkOrder())

347 DFSLinkOrder = std::move(*DFSLinkOrderOrErr);

348 else

349 return DFSLinkOrderOrErr.takeError();

350

351 for (auto &NextJD : DFSLinkOrder) {

352 auto &JDLookupSymbols = LookupSymbols[NextJD.get()];

353 auto DIFItr = DeInitFunctions.find(NextJD.get());

354 if (DIFItr != DeInitFunctions.end()) {

355 LookupSymbols[NextJD.get()] = std::move(DIFItr->second);

356 DeInitFunctions.erase(DIFItr);

357 }

358 JDLookupSymbols.add(LLJITRunAtExits,

359 SymbolLookupFlags::WeaklyReferencedSymbol);

360 }

362 }))

363 return std::move(Err);

364

366 dbgs() << "JITDylib deinit order is [ ";

367 for (auto &JD : DFSLinkOrder)

368 dbgs() << "\"" << JD->getName() << "\" ";

369 dbgs() << "]\n";

370 dbgs() << "Looking up deinit functions:\n";

371 for (auto &KV : LookupSymbols)

372 dbgs() << " \"" << KV.first->getName() << "\": " << KV.second << "\n";

373 });

374

376

377 if (!LookupResult)

378 return LookupResult.takeError();

379

380 std::vector DeInitializers;

381 for (auto &NextJD : DFSLinkOrder) {

382 auto DeInitsItr = LookupResult->find(NextJD.get());

383 assert(DeInitsItr != LookupResult->end() &&

384 "Every JD should have at least __lljit_run_atexits");

385

386 auto RunAtExitsItr = DeInitsItr->second.find(LLJITRunAtExits);

387 if (RunAtExitsItr != DeInitsItr->second.end())

388 DeInitializers.push_back(RunAtExitsItr->second.getAddress());

389

390 for (auto &KV : DeInitsItr->second)

391 if (KV.first != LLJITRunAtExits)

392 DeInitializers.push_back(KV.second.getAddress());

393 }

394

395 return DeInitializers;

396 }

397

398

399

402 std::vector DFSLinkOrder;

403

404 if (auto Err = getExecutionSession().runSessionLocked([&]() -> Error {

406 DFSLinkOrder = std::move(*DFSLinkOrderOrErr);

407 else

408 return DFSLinkOrderOrErr.takeError();

409

410 for (auto &NextJD : DFSLinkOrder) {

411 auto ISItr = InitSymbols.find(NextJD.get());

412 if (ISItr != InitSymbols.end()) {

413 RequiredInitSymbols[NextJD.get()] = std::move(ISItr->second);

414 InitSymbols.erase(ISItr);

415 }

416 }

418 }))

419 return Err;

420

422 RequiredInitSymbols)

423 .takeError();

424 }

425

426 static void registerCxaAtExitHelper(void *Self, void (*F)(void *), void *Ctx,

427 void *DSOHandle) {

429 dbgs() << "Registering cxa atexit function " << (void *)F << " for JD "

430 << (*static_cast<JITDylib **>(DSOHandle))->getName() << "\n";

431 });

432 static_cast<GenericLLVMIRPlatformSupport *>(Self)->AtExitMgr.registerAtExit(

433 F, Ctx, DSOHandle);

434 }

435

436 static void registerAtExitHelper(void *Self, void *DSOHandle, void (*F)()) {

438 dbgs() << "Registering atexit function " << (void *)F << " for JD "

439 << (*static_cast<JITDylib **>(DSOHandle))->getName() << "\n";

440 });

441 static_cast<GenericLLVMIRPlatformSupport *>(Self)->AtExitMgr.registerAtExit(

442 reinterpret_cast<void (*)(void *)>(F), nullptr, DSOHandle);

443 }

444

445 static void runAtExitsHelper(void *Self, void *DSOHandle) {

447 dbgs() << "Running atexit functions for JD "

448 << (*static_cast<JITDylib **>(DSOHandle))->getName() << "\n";

449 });

450 static_cast<GenericLLVMIRPlatformSupport *>(Self)->AtExitMgr.runAtExits(

451 DSOHandle);

452 }

453

454

455

457 auto Ctx = std::make_unique();

458 auto M = std::make_unique("__standard_lib", *Ctx);

459 M->setDataLayout(J.getDataLayout());

460

461 auto *GenericIRPlatformSupportTy =

463

466 nullptr, "__lljit.platform_support_instance");

467

468 auto *IntTy = Type::getIntNTy(*Ctx, sizeof(int) * CHAR_BIT);

471

472 auto *CxaAtExit = addHelperAndWrapper(

473 *M, "__cxa_atexit",

474 FunctionType::get(IntTy, {CxaAtExitCallbackPtrTy, BytePtrTy, BytePtrTy},

475 false),

477 {PlatformInstanceDecl});

479 TargetLibraryInfo::getExtAttrForI32Return(J.getTargetTriple());

481 CxaAtExit->addRetAttr(CxaAtExitExtAttr);

482

484 }

485

487 std::string InitFunctionPrefix;

488 std::string DeInitFunctionPrefix;

493};

494

495Error GenericLLVMIRPlatform::setupJITDylib(JITDylib &JD) {

496 return S.setupJITDylib(JD);

497}

498

499Error GenericLLVMIRPlatform::teardownJITDylib(JITDylib &JD) {

501}

502

503Error GenericLLVMIRPlatform::notifyAdding(ResourceTracker &RT,

504 const MaterializationUnit &MU) {

505 return S.notifyAdding(RT, MU);

506}

507

508Expected

509GlobalCtorDtorScraper::operator()(ThreadSafeModule TSM,

510 MaterializationResponsibility &R) {

512 auto &Ctx = M.getContext();

513 auto *GlobalCtors = M.getNamedGlobal("llvm.global_ctors");

514 auto *GlobalDtors = M.getNamedGlobal("llvm.global_dtors");

515

516 auto RegisterCOrDtors = [&](GlobalVariable *GlobalCOrDtors,

517 bool isCtor) -> Error {

518

519 if (!GlobalCOrDtors || GlobalCOrDtors->isDeclaration())

521 std::string InitOrDeInitFunctionName;

522 if (isCtor)

523 raw_string_ostream(InitOrDeInitFunctionName)

524 << InitFunctionPrefix << M.getModuleIdentifier();

525 else

526 raw_string_ostream(InitOrDeInitFunctionName)

527 << DeInitFunctionPrefix << M.getModuleIdentifier();

528

529 MangleAndInterner Mangle(PS.getExecutionSession(), M.getDataLayout());

530 auto InternedInitOrDeInitName = Mangle(InitOrDeInitFunctionName);

531 if (auto Err = R.defineMaterializing(

532 {{InternedInitOrDeInitName, JITSymbolFlags::Callable}}))

533 return Err;

534

536 FunctionType::get(Type::getVoidTy(Ctx), {}, false),

539 std::vector<std::pair<Function *, unsigned>> InitsOrDeInits;

541

542 for (auto E : COrDtors)

543 InitsOrDeInits.push_back(std::make_pair(E.Func, E.Priority));

545

546 auto *InitOrDeInitFuncEntryBlock =

549 for (auto &KV : InitsOrDeInits)

550 IB.CreateCall(KV.first);

551 IB.CreateRetVoid();

552

553 if (isCtor)

554 PS.registerInitFunc(R.getTargetJITDylib(), InternedInitOrDeInitName);

555 else

556 PS.registerDeInitFunc(R.getTargetJITDylib(), InternedInitOrDeInitName);

557

560 };

561

562 if (auto Err = RegisterCOrDtors(GlobalCtors, true))

563 return Err;

564 if (auto Err = RegisterCOrDtors(GlobalDtors, false))

565 return Err;

566

568 });

569

570 if (Err)

571 return std::move(Err);

572

573 return std::move(TSM);

574}

575

576

577

578

579

580class InactivePlatformSupport : public LLJIT::PlatformSupport {

581public:

582 InactivePlatformSupport() = default;

583

585 LLVM_DEBUG(dbgs() << "InactivePlatformSupport: no initializers running for "

586 << JD.getName() << "\n");

588 }

589

590 Error deinitialize(JITDylib &JD) override {

592 dbgs() << "InactivePlatformSupport: no deinitializers running for "

593 << JD.getName() << "\n");

595 }

596};

597

598}

599

600namespace llvm {

601namespace orc {

602

606 using SPSDLOpenSig = SPSExecutorAddr(SPSString, int32_t);

607 using SPSDLUpdateSig = int32_t(SPSExecutorAddr);

608 enum dlopen_mode : int32_t {

609 ORC_RT_RTLD_LAZY = 0x1,

610 ORC_RT_RTLD_NOW = 0x2,

611 ORC_RT_RTLD_LOCAL = 0x4,

612 ORC_RT_RTLD_GLOBAL = 0x8

613 };

614

615 auto &ES = J.getExecutionSession();

616 auto MainSearchOrder = J.getMainJITDylib().withLinkOrderDo(

618 StringRef WrapperToCall = "__orc_rt_jit_dlopen_wrapper";

619 bool dlupdate = false;

620 if (InitializedDylib.contains(&JD)) {

621 WrapperToCall = "__orc_rt_jit_dlupdate_wrapper";

622 dlupdate = true;

623 } else

624 InitializedDylib.insert(&JD);

625

626 if (auto WrapperAddr =

627 ES.lookup(MainSearchOrder, J.mangleAndIntern(WrapperToCall))) {

628 if (dlupdate) {

629 int32_t result;

630 auto E = ES.callSPSWrapper(WrapperAddr->getAddress(),

631 result, DSOHandles[&JD]);

632 if (E)

633 return E;

634 else if (result)

637 } else

638 return ES.callSPSWrapper(WrapperAddr->getAddress(),

639 DSOHandles[&JD], JD.getName(),

640 int32_t(ORC_RT_RTLD_LAZY));

641 } else

642 return WrapperAddr.takeError();

643

645}

646

649 using SPSDLCloseSig = int32_t(SPSExecutorAddr);

650

651 auto &ES = J.getExecutionSession();

652 auto MainSearchOrder = J.getMainJITDylib().withLinkOrderDo(

654

655 if (auto WrapperAddr = ES.lookup(

656 MainSearchOrder, J.mangleAndIntern("__orc_rt_jit_dlclose_wrapper"))) {

657 int32_t result;

658 auto E = J.getExecutionSession().callSPSWrapper(

659 WrapperAddr->getAddress(), result, DSOHandles[&JD]);

660 if (E)

661 return E;

662 else if (result)

665 DSOHandles.erase(&JD);

666 InitializedDylib.erase(&JD);

667 } else

668 return WrapperAddr.takeError();

670}

671

676

678

680

681 LLVM_DEBUG(dbgs() << "Preparing to create LLJIT instance...\n");

682

685 dbgs() << " No explicitly set JITTargetMachineBuilder. "

686 "Detecting host...\n";

687 });

689 JTMB = std::move(*JTMBOrErr);

690 else

691 return JTMBOrErr.takeError();

692 }

693

696 "NumCompileThreads cannot be used with a custom ExecutionSession or "

697 "ExecutorProcessControl",

699

700#if !LLVM_ENABLE_THREADS

704 " but LLVM was compiled with LLVM_ENABLE_THREADS=Off",

706#endif

707

708

709 [[maybe_unused]] bool ConcurrentCompilationSettingDefaulted =

711

713#if LLVM_ENABLE_THREADS

715#else

717#endif

718 } else {

719#if !LLVM_ENABLE_THREADS

722 "LLJIT concurrent compilation support requested, but LLVM was built "

723 "with LLVM_ENABLE_THREADS=Off",

725#endif

726 }

727

729 dbgs() << " JITTargetMachineBuilder is "

731 << " Pre-constructed ExecutionSession: " << (ES ? "Yes" : "No")

732 << "\n"

733 << " DataLayout: ";

734 if (DL)

735 dbgs() << DL->getStringRepresentation() << "\n";

736 else

737 dbgs() << "None (will be created by JITTargetMachineBuilder)\n";

738

739 dbgs() << " Custom object-linking-layer creator: "

741 << " Custom compile-function creator: "

743 << " Custom platform-setup function: "

745 << " Support concurrent compilation: "

747 if (ConcurrentCompilationSettingDefaulted)

748 dbgs() << " (defaulted based on ES / EPC / NumCompileThreads)\n";

749 else

750 dbgs() << "\n";

752 });

753

754

755 if (DL) {

756 if (auto DLOrErr = JTMB->getDefaultDataLayoutForTarget())

757 DL = std::move(*DLOrErr);

758 else

759 return DLOrErr.takeError();

760 }

761

762

763 if (ES && EPC) {

765 dbgs() << "ExecutorProcessControl not specified, "

766 "Creating SelfExecutorProcessControl instance\n";

767 });

768

769 std::unique_ptr D = nullptr;

770#if LLVM_ENABLE_THREADS

772 std::optional<size_t> NumThreads = std ::nullopt;

775 D = std::make_unique(NumThreads);

776 } else

777 D = std::make_unique();

778#endif

779 if (auto EPCOrErr =

781 EPC = std::move(*EPCOrErr);

782 else

783 return EPCOrErr.takeError();

784 } else if (EPC) {

786 dbgs() << "Using explicitly specified ExecutorProcessControl instance "

787 << EPC.get() << "\n";

788 });

789 } else {

791 dbgs() << "Using explicitly specified ExecutionSession instance "

792 << ES.get() << "\n";

793 });

794 }

795

796

797

799 auto &TT = JTMB->getTargetTriple();

800 bool UseJITLink = false;

801 switch (TT.getArch()) {

804 UseJITLink = true;

805 break;

807 UseJITLink = !TT.isOSBinFormatCOFF();

808 break;

813 UseJITLink = TT.isOSBinFormatELF();

814 break;

816 UseJITLink = !TT.isOSBinFormatCOFF();

817 break;

819 UseJITLink = TT.isPPC64ELFv2ABI();

820 break;

822 UseJITLink = TT.isOSBinFormatELF();

823 break;

824 default:

825 break;

826 }

827 if (UseJITLink) {

828 if (JTMB->getCodeModel())

833 return std::make_unique(ES);

834 };

835 }

836 }

837

838

839

841 LLVM_DEBUG(dbgs() << "Creating default Process JD setup function\n");

843 auto &JD =

846 J.getExecutionSession());

847 if (G)

848 return G.takeError();

850 return &JD;

851 };

852 }

853

855}

856

858 if (auto Err = ES->endSession())

859 ES->reportError(std::move(Err));

860}

861

863

865

867 auto JD = ES->createJITDylib(std::move(Name));

868 if (!JD)

869 return JD.takeError();

870

872 return JD;

873}

874

877 if (G)

878 return G.takeError();

879

880 if (auto *ExistingJD = ES->getJITDylibByName(Path))

881 return *ExistingJD;

882

883 auto &JD = ES->createBareJITDylib(Path);

885 return JD;

886}

887

889 std::unique_ptr LibBuffer) {

891 std::move(LibBuffer));

892 if (G)

893 return G.takeError();

894

896

898}

899

902 if (G)

903 return G.takeError();

904

906

908}

909

911 assert(TSM && "Can not add null module");

912

913 if (auto Err =

915 return Err;

916

918}

919

923

925 std::unique_ptr Obj) {

926 assert(Obj && "Can not add null object");

927

929}

930

934

937 if (auto Sym = ES->lookup(

939 Name))

940 return Sym->getAddress();

941 else

943}

944

947

948

951

952

953

955 return std::make_unique();

956 };

957 auto Layer =

958 std::make_unique(ES, std::move(GetMemMgr));

959

960 if (S.JTMB->getTargetTriple().isOSBinFormatCOFF()) {

961 Layer->setOverrideObjectFlagsWithResponsibilityFlags(true);

962 Layer->setAutoClaimResponsibilityForObjectSymbols(true);

963 }

964

965 if (S.JTMB->getTargetTriple().isOSBinFormatELF() &&

968 Layer->setAutoClaimResponsibilityForObjectSymbols(true);

969

970

971

972

973 return std::unique_ptr(std::move(Layer));

974}

975

979

980

983

984

986 return std::make_unique(std::move(JTMB));

987

989 if (!TM)

990 return TM.takeError();

991

992 return std::make_unique(std::move(*TM));

993}

994

997

999

1000 assert(!(S.EPC && S.ES) && "EPC and ES should not both be set");

1001

1002 if (S.EPC) {

1003 ES = std::make_unique(std::move(S.EPC));

1004 } else if (S.ES)

1005 ES = std::move(S.ES);

1006 else {

1008 ES = std::make_unique(std::move(*EPC));

1009 } else {

1010 Err = EPC.takeError();

1011 return;

1012 }

1013 }

1014

1016 if (!ObjLayer) {

1017 Err = ObjLayer.takeError();

1018 return;

1019 }

1023

1024 {

1026 if (!CompileFunction) {

1027 Err = CompileFunction.takeError();

1028 return;

1029 }

1030 CompileLayer = std::make_unique(

1035 }

1036

1039

1043 } else {

1044 Err = ProcSymsJD.takeError();

1045 return;

1046 }

1047 }

1048

1051 return;

1052

1055

1056 if (auto PlatformJDOrErr = S.SetUpPlatform(*this)) {

1057 Platform = PlatformJDOrErr->get();

1061 } else {

1062 Err = PlatformJDOrErr.takeError();

1063 return;

1064 }

1065

1069

1071 Main = &*MainOrErr;

1072 else {

1073 Err = MainOrErr.takeError();

1074 return;

1075 }

1076}

1077

1079 std::string MangledName;

1080 {

1083 }

1084 return MangledName;

1085}

1086

1088 if (M.getDataLayout().isDefault())

1089 M.setDataLayout(DL);

1090

1091 if (M.getDataLayout() != DL)

1093 "Added modules have incompatible data layouts: " +

1094 M.getDataLayout().getStringRepresentation() + " (module) vs " +

1095 DL.getStringRepresentation() + " (jit)",

1097

1099}

1100

1102 LLVM_DEBUG({ dbgs() << "Setting up orc platform support for LLJIT\n"; });

1105}

1106

1108public:

1114 auto DLLNameStr = DLLName.str();

1115 auto DLLJD = J.loadPlatformDynamicLibrary(DLLNameStr.c_str());

1116 if (!DLLJD)

1117 return DLLJD.takeError();

1120 }

1121

1122private:

1124};

1125

1128 if (!ProcessSymbolsJD)

1130 "Native platforms require a process symbols JITDylib",

1132

1136

1137 if (!ObjLinkingLayer)

1139 "ExecutorNativePlatform requires ObjectLinkingLayer",

1141

1142 std::unique_ptr RuntimeArchiveBuffer;

1143 if (OrcRuntime.index() == 0) {

1145 if (A)

1146 return A.takeError();

1147 RuntimeArchiveBuffer = std::move(*A);

1148 } else

1149 RuntimeArchiveBuffer = std::move(std::get<1>(OrcRuntime));

1150

1154

1156

1157 switch (TT.getObjectFormat()) {

1159 const char *VCRuntimePath = nullptr;

1160 bool StaticVCRuntime = false;

1161 if (VCRuntime) {

1162 VCRuntimePath = VCRuntime->first.c_str();

1163 StaticVCRuntime = VCRuntime->second;

1164 }

1166 *ObjLinkingLayer, PlatformJD, std::move(RuntimeArchiveBuffer),

1169 else

1170 return P.takeError();

1171 break;

1172 }

1175 *ObjLinkingLayer, std::move(RuntimeArchiveBuffer));

1176 if (G)

1177 return G.takeError();

1178

1179 if (auto P =

1182 else

1183 return P.takeError();

1184 break;

1185 }

1188 *ObjLinkingLayer, std::move(RuntimeArchiveBuffer));

1189 if (G)

1190 return G.takeError();

1191

1192 if (auto P =

1194 ES.setPlatform(std::move(*P));

1195 else

1196 return P.takeError();

1197 break;

1198 }

1199 default:

1201 TT.str(),

1203 }

1204

1205 return &PlatformJD;

1206}

1207

1210 { dbgs() << "Setting up GenericLLVMIRPlatform support for LLJIT\n"; });

1212 if (!ProcessSymbolsJD)

1214 "Native platforms require a process symbols JITDylib",

1216

1219

1221

1222 bool UseEHFrames = true;

1223

1224

1227

1228

1229

1230

1231 std::optional ForceEHFrames;

1233 "darwin-use-ehframes-only", ForceEHFrames))

1234 return Err;

1235 if (ForceEHFrames.has_value())

1236 UseEHFrames = *ForceEHFrames;

1237 else

1238 UseEHFrames = false;

1239

1240

1241 if (!UseEHFrames) {

1242 if (auto UIRP =

1244 OLL->addPlugin(std::move(*UIRP));

1245 LLVM_DEBUG(dbgs() << "Enabled compact-unwind support.\n");

1246 } else

1247 return UIRP.takeError();

1248 }

1249 }

1250

1251

1252 if (UseEHFrames) {

1255 OLL->addPlugin(std::move(*EHFP));

1256 LLVM_DEBUG(dbgs() << "Enabled eh-frame support.\n");

1257 } else

1258 return EHFP.takeError();

1259 }

1260 }

1261

1263 std::make_unique(J, PlatformJD));

1264

1265 return &PlatformJD;

1266}

1267

1270 { dbgs() << "Explicitly deactivated platform support for LLJIT\n"; });

1272 return nullptr;

1273}

1274

1277 return Err;

1278 TT = JTMB->getTargetTriple();

1280}

1281

1283 assert(TSM && "Can not add null module");

1284

1286 [&](Module &M) -> Error { return applyDataLayout(M); }))

1287 return Err;

1288

1289 return CODLayer->add(JD, std::move(TSM));

1290}

1291

1293

1294

1295 if (Err)

1296 return;

1297

1299

1300

1302 LCTMgr = std::move(S.LCTMgr);

1303 else {

1306 LCTMgr = std::move(*LCTMgrOrErr);

1307 else {

1308 Err = LCTMgrOrErr.takeError();

1309 return;

1310 }

1311 }

1312

1313

1314 auto ISMBuilder = std::move(S.ISMBuilder);

1315

1316

1317 if (!ISMBuilder)

1319

1320

1321 if (!ISMBuilder) {

1323 "IndirectStubsManagerBuilder for target " +

1326 return;

1327 }

1328

1329

1331

1332

1333 CODLayer = std::make_unique(*ES, *IPLayer, *LCTMgr,

1334 std::move(ISMBuilder));

1335

1337 CODLayer->setCloneToNewContextOnEmit(true);

1338}

1339

1340

1341

1346

1347}

1348}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")

static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")

#define LLVM_ATTRIBUTE_USED

Module.h This file contains the declarations for the Module class.

Machine Check Debug Module

static StringRef getName(Value *V)

LLVM_ABI llvm::orc::shared::CWrapperFunctionResult llvm_orc_deregisterEHFrameSectionAllocAction(const char *ArgData, size_t ArgSize)

LLVM_ABI llvm::orc::shared::CWrapperFunctionResult llvm_orc_registerEHFrameSectionAllocAction(const char *ArgData, size_t ArgSize)

static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, const llvm::StringTable &StandardNames, VectorLibrary VecLib)

Initialize the set of available library functions based on the specified target triple.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

AttrKind

This enumeration lists the attributes that can be associated with parameters, function results,...

@ None

No attributes have been set.

static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)

Creates a new BasicBlock.

Helper for Errors used as out-parameters.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)

This static method is the primary way of constructing a FunctionType.

static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)

LLVM_ABI bool isDeclaration() const

Return true if the primary definition of this global value is outside of the current translation unit...

VisibilityTypes

An enumeration for the kinds of visibility of global values.

@ DefaultVisibility

The GV is visible.

@ HiddenVisibility

The GV is hidden.

void setVisibility(VisibilityTypes V)

@ ExternalLinkage

Externally visible function.

LLVM_ABI void eraseFromParent()

eraseFromParent - This method unlinks 'this' from the containing module and deletes it.

This provides a uniform API for creating instructions and inserting them into a basic block: either a...

Flags for symbols in the JIT.

LLVM_ABI void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const

Print the appropriate prefix and the specified global variable's name.

This interface provides simple read-only access to a block of memory, and provides simple methods for...

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,...

A Module instance is used to store all the information related to an LLVM module.

static PointerType * getUnqual(Type *ElementType)

This constructs a pointer to an object of the specified type in the default address space (address sp...

StringRef - Represent a constant reference to a string, i.e.

std::string str() const

str - Get the contents as an std::string.

LLVM_ABI bool ends_with_insensitive(StringRef Suffix) const

Check if this string ends with the given Suffix, ignoring case.

static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)

This creates an identified struct.

Triple - Helper class for working with autoconf configuration names.

bool isOSBinFormatMachO() const

Tests whether the environment is MachO.

const std::string & str() const

bool isOSDarwin() const

Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, DriverKit, XROS, or bridgeOS).

Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...

static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)

static LLVM_ABI Type * getVoidTy(LLVMContext &C)

static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)

const std::string & getName() const

Get the name for this JITLinkDylib.

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.

static Expected< std::unique_ptr< EHFrameRegistrationPlugin > > Create(ExecutionSession &ES)

static Expected< std::unique_ptr< ELFNixPlatform > > Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr< DefinitionGenerator > OrcRuntime, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt)

Try to create a ELFNixPlatform instance, adding the ORC runtime to the given JITDylib.

static Expected< std::unique_ptr< EPCDynamicLibrarySearchGenerator > > Load(ExecutionSession &ES, const char *LibraryPath, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)

Permanently loads the library at the given path and, on success, returns an EPCDynamicLibrarySearchGe...

static Expected< std::unique_ptr< EPCDynamicLibrarySearchGenerator > > GetForTargetProcess(ExecutionSession &ES, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)

Creates a EPCDynamicLibrarySearchGenerator that searches for symbols in the target process.

An ExecutionSession represents a running JIT program.

void setPlatform(std::unique_ptr< Platform > P)

Set the Platform for this ExecutionSession.

LLVM_ABI JITDylib & createBareJITDylib(std::string Name)

Add a new bare JITDylib to this ExecutionSession.

Error getBootstrapMapValue(StringRef Key, std::optional< T > &Val) const

Look up and SPS-deserialize a bootstrap map value.

static ExecutorAddr fromPtr(T *Ptr, UnwrapFn &&Unwrap=UnwrapFn())

Create an ExecutorAddr from the given pointer.

LLVM_ABI Expected< JITDylibSP > operator()(LLJIT &J)

Definition LLJIT.cpp:1126

unique_function< Expected< ThreadSafeModule >( ThreadSafeModule, MaterializationResponsibility &R)> TransformFunction

An interface for Itanium __cxa_atexit interposer implementations.

Represents a JIT'd dynamic library.

Error define(std::unique_ptr< MaterializationUnitType > &&MU, ResourceTrackerSP RT=nullptr)

Define all symbols provided by the materialization unit to be part of this JITDylib.

ExecutionSession & getExecutionSession() const

Get a reference to the ExecutionSession for this JITDylib.

LLVM_ABI void addToLinkOrder(const JITDylibSearchOrder &NewLinks)

Append the given JITDylibSearchOrder to the link order for this JITDylib (discarding any elements alr...

static LLVM_ABI 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...

LLVM_ABI ResourceTrackerSP getDefaultResourceTracker()

Get the default resource tracker for this JITDylib.

GeneratorT & addGenerator(std::unique_ptr< GeneratorT > DefGenerator)

Adds a definition generator to this JITDylib and returns a referenece to it.

A utility class for building TargetMachines for JITs.

static LLVM_ABI Expected< JITTargetMachineBuilder > detectHost()

Create a JITTargetMachineBuilder for the host system.

LLVM_ABI Expected< std::unique_ptr< TargetMachine > > createTargetMachine()

Create a TargetMachine.

LLVM_ABI Error prepareForConstruction()

Called prior to JIT class construcion to fix up defaults.

Definition LLJIT.cpp:679

ProcessSymbolsJITDylibSetupFunction SetupProcessSymbolsJITDylib

ObjectLinkingLayerCreator CreateObjectLinkingLayer

unsigned NumCompileThreads

std::unique_ptr< ExecutionSession > ES

unique_function< Error(LLJIT &)> PrePlatformSetup

CompileFunctionCreator CreateCompileFunction

std::optional< bool > SupportConcurrentCompilation

bool LinkProcessSymbolsByDefault

std::unique_ptr< ExecutorProcessControl > EPC

std::optional< DataLayout > DL

std::optional< JITTargetMachineBuilder > JTMB

PlatformSetupFunction SetUpPlatform

Initializer support for LLJIT.

virtual ~PlatformSupport()

static void setInitTransform(LLJIT &J, IRTransformLayer::TransformFunction T)

Definition LLJIT.cpp:672

A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.

static Expected< std::unique_ptr< ObjectLayer > > createObjectLinkingLayer(LLJITBuilderState &S, ExecutionSession &ES)

Definition LLJIT.cpp:946

void setPlatformSupport(std::unique_ptr< PlatformSupport > PS)

Set the PlatformSupport instance.

std::unique_ptr< ExecutionSession > ES

LLJIT(LLJITBuilderState &S, Error &Err)

Create an LLJIT instance with a single compile thread.

Definition LLJIT.cpp:995

Error addObjectFile(ResourceTrackerSP RT, std::unique_ptr< MemoryBuffer > Obj)

Adds an object file to the given JITDylib.

Definition LLJIT.cpp:924

Expected< JITDylib & > createJITDylib(std::string Name)

Create a new JITDylib with the given name and return a reference to it.

Definition LLJIT.cpp:866

JITDylibSearchOrder DefaultLinks

const DataLayout & getDataLayout() const

Returns a reference to the DataLayout for this instance.

ObjectLayer & getObjLinkingLayer()

Returns a reference to the ObjLinkingLayer.

std::unique_ptr< ObjectTransformLayer > ObjTransformLayer

virtual ~LLJIT()

Destruct this instance.

Definition LLJIT.cpp:857

std::string mangle(StringRef UnmangledName) const

Returns a linker-mangled version of UnmangledName.

Definition LLJIT.cpp:1078

JITDylibSP getPlatformJITDylib()

Returns the Platform JITDylib, which will contain the ORC runtime (if given) and any platform symbols...

Definition LLJIT.cpp:864

Expected< JITDylib & > loadPlatformDynamicLibrary(const char *Path)

Load a (real) dynamic library and make its symbols available through a new JITDylib with the same nam...

Definition LLJIT.cpp:875

std::unique_ptr< IRTransformLayer > InitHelperTransformLayer

std::unique_ptr< IRCompileLayer > CompileLayer

const Triple & getTargetTriple() const

Returns a reference to the triple for this instance.

JITDylibSP getProcessSymbolsJITDylib()

Returns the ProcessSymbols JITDylib, which by default reflects non-JIT'd symbols in the host process.

Definition LLJIT.cpp:862

Expected< ExecutorAddr > lookupLinkerMangled(JITDylib &JD, SymbolStringPtr Name)

Look up a symbol in JITDylib JD by the symbol's linker-mangled name (to look up symbols based on thei...

Definition LLJIT.cpp:935

static Expected< std::unique_ptr< IRCompileLayer::IRCompiler > > createCompileFunction(LLJITBuilderState &S, JITTargetMachineBuilder JTMB)

Definition LLJIT.cpp:977

JITDylib * ProcessSymbols

ExecutionSession & getExecutionSession()

Returns the ExecutionSession for this instance.

std::unique_ptr< IRTransformLayer > TransformLayer

SymbolStringPtr mangleAndIntern(StringRef UnmangledName) const

Returns an interned, linker-mangled version of UnmangledName.

Error linkStaticLibraryInto(JITDylib &JD, std::unique_ptr< MemoryBuffer > LibBuffer)

Link a static library into the given JITDylib.

Definition LLJIT.cpp:888

Error applyDataLayout(Module &M)

Definition LLJIT.cpp:1087

std::unique_ptr< ObjectLayer > ObjLinkingLayer

LLVM_ABI friend Expected< JITDylibSP > setUpGenericLLVMIRPlatform(LLJIT &J)

Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...

Definition LLJIT.cpp:1208

Error addIRModule(ResourceTrackerSP RT, ThreadSafeModule TSM)

Adds an IR module with the given ResourceTracker.

Definition LLJIT.cpp:910

ExecutorAddr LazyCompileFailureAddr

std::unique_ptr< LazyCallThroughManager > LCTMgr

LLVM_ABI Error prepareForConstruction()

Definition LLJIT.cpp:1275

IndirectStubsManagerBuilderFunction ISMBuilder

LLVM_ABI Error addLazyIRModule(JITDylib &JD, ThreadSafeModule M)

Add a module to be lazily compiled to JITDylib JD.

Definition LLJIT.cpp:1282

Definition LLJIT.cpp:1107

LoadAndLinkDynLibrary(LLJIT &J)

Definition LLJIT.cpp:1109

Error operator()(JITDylib &JD, StringRef DLLName)

Definition LLJIT.cpp:1110

static Expected< std::unique_ptr< MachOPlatform > > Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &PlatformJD, std::unique_ptr< DefinitionGenerator > OrcRuntime, HeaderOptions PlatformJDOpts={}, MachOHeaderMUBuilder BuildMachOHeaderMU=buildSimpleMachOHeaderMU, std::optional< SymbolAliasMap > RuntimeAliases=std::nullopt)

Try to create a MachOPlatform instance, adding the ORC runtime to the given JITDylib.

Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...

A MaterializationUnit represents a set of symbol definitions that can be materialized as a group,...

const SymbolFlagsMap & getSymbols() const

Return the set of symbols that this source provides.

const SymbolStringPtr & getInitializerSymbol() const

Returns the initialization symbol for this MaterializationUnit (if any).

Error deinitialize(orc::JITDylib &JD) override

Definition LLJIT.cpp:647

Error initialize(orc::JITDylib &JD) override

Definition LLJIT.cpp:603

An ObjectLayer implementation built on JITLink.

Platforms set up standard symbols and mediate interactions between dynamic initializers (e....

static Expected< DenseMap< JITDylib *, SymbolMap > > lookupInitSymbols(ExecutionSession &ES, const DenseMap< JITDylib *, SymbolLookupSet > &InitSyms)

A utility function for looking up initializer symbols.

API to remove / transfer ownership of JIT resources.

JITDylib & getJITDylib() const

Return the JITDylib targeted by this tracker.

static Expected< std::unique_ptr< SelfExecutorProcessControl > > Create(std::shared_ptr< SymbolStringPool > SSP=nullptr, std::unique_ptr< TaskDispatcher > D=nullptr, std::unique_ptr< jitlink::JITLinkMemoryManager > MemMgr=nullptr)

Create a SelfExecutorProcessControl with the given symbol string pool and memory manager.

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.

static Expected< std::unique_ptr< StaticLibraryDefinitionGenerator > > Load(ObjectLayer &L, const char *FileName, VisitMembersFunction VisitMembers=VisitMembersFunction(), GetObjectFileInterface GetObjFileInterface=GetObjectFileInterface())

Try to create a StaticLibraryDefinitionGenerator from the given path.

Pointer to a pooled string representing a symbol name.

An LLVM Module together with a shared ThreadSafeContext.

decltype(auto) withModuleDo(Func &&F)

Locks the associated ThreadSafeContext and calls the given function on the contained Module.

static Expected< std::shared_ptr< UnwindInfoRegistrationPlugin > > Create(ExecutionSession &ES, ExecutorAddr Register, ExecutorAddr Deregister)

A raw_ostream that writes to an std::string.

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...

std::vector< std::pair< JITDylib *, JITDylibLookupFlags > > JITDylibSearchOrder

A list of (JITDylib*, JITDylibLookupFlags) pairs to be used as a search order during symbol lookup.

IntrusiveRefCntPtr< JITDylib > JITDylibSP

LLVM_ABI iterator_range< CtorDtorIterator > getDestructors(const Module &M)

Create an iterator range over the entries of the llvm.global_ctors array.

IntrusiveRefCntPtr< ResourceTracker > ResourceTrackerSP

std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)

Create an AbsoluteSymbolsMaterializationUnit with the given symbols.

LLVM_ABI iterator_range< CtorDtorIterator > getConstructors(const Module &M)

Create an iterator range over the entries of the llvm.global_ctors array.

@ MatchExportedSymbolsOnly

DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap

A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).

LLVM_ABI Expected< JITDylibSP > setUpInactivePlatform(LLJIT &J)

Configure the LLJIT instance to disable platform support explicitly.

Definition LLJIT.cpp:1268

LLVM_ATTRIBUTE_USED void linkComponents()

Definition LLJIT.cpp:1342

LLVM_ABI std::function< std::unique_ptr< IndirectStubsManager >()> createLocalIndirectStubsManagerBuilder(const Triple &T)

Create a local indirect stubs manager builder.

LLVM_ABI Expected< std::unique_ptr< LazyCallThroughManager > > createLocalLazyCallThroughManager(const Triple &T, ExecutionSession &ES, ExecutorAddr ErrorHandlerAddr)

Create a LocalLazyCallThroughManager from the given triple and execution session.

LLVM_ABI Expected< JITDylibSP > setUpGenericLLVMIRPlatform(LLJIT &J)

Configure the LLJIT instance to scrape modules for llvm.global_ctors and llvm.global_dtors variables ...

Definition LLJIT.cpp:1208

LLVM_ABI Error setUpOrcPlatformManually(LLJIT &J)

Configure the LLJIT instance to use orc runtime support.

Definition LLJIT.cpp:1101

This is an optimization pass for GlobalISel generic memory operations.

void stable_sort(R &&Range)

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

LLVM_ABI std::error_code inconvertibleErrorCode()

The value returned by this function can be returned from convertToErrorCode for Error values where no...

void append_range(Container &C, Range &&R)

Wrapper function to append range R to container C.

auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)

auto reverse(ContainerTy &&C)

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.

LLVM_ABI raw_fd_ostream & errs()

This returns a reference to a raw_ostream for standard error.

void cantFail(Error Err, const char *Msg=nullptr)

Report a fatal error if Err is a failure value.

IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >

Expected< T > errorOrToExpected(ErrorOr< T > &&EO)

Convert an ErrorOr to an Expected.

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

Implement std::hash so that hash_code can be used in STL containers.