clang: lib/Interpreter/Interpreter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

19#include "llvm/Support/VirtualFileSystem.h"

20#ifdef __EMSCRIPTEN__

22#include <dlfcn.h>

23#endif

24

49#include "llvm/ExecutionEngine/JITSymbol.h"

50#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"

51#include "llvm/ExecutionEngine/Orc/LLJIT.h"

52#include "llvm/IR/Module.h"

53#include "llvm/Support/Errc.h"

54#include "llvm/Support/ErrorHandling.h"

55#include "llvm/Support/raw_ostream.h"

56#include "llvm/TargetParser/Host.h"

57#include "llvm/Transforms/Utils/Cloning.h"

58

59#define DEBUG_TYPE "clang-repl"

60

61using namespace clang;

62

63

64namespace {

65

66

70

71

74 return llvm::createStringError(llvm::errc::not_supported,

75 "Driver initialization failed. "

76 "Unable to create a driver job");

77

78

81 return llvm::createStringError(llvm::errc::not_supported,

82 "Driver initialization failed");

83

85}

86

88CreateCI(const llvm::opt::ArgStringList &Argv) {

89 std::unique_ptr Clang(new CompilerInstance());

90

91

92

93 auto PCHOps = Clang->getPCHContainerOperations();

94 PCHOps->registerWriter(std::make_unique());

95 PCHOps->registerReader(std::make_unique());

96

97

98

103 Clang->getInvocation(), llvm::ArrayRef(Argv.begin(), Argv.size()), Diags);

104

105

106 if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&

107 Clang->getHeaderSearchOpts().ResourceDir.empty())

108 Clang->getHeaderSearchOpts().ResourceDir =

110

111 Clang->createVirtualFileSystem();

112

113

114 Clang->createDiagnostics();

115 if (!Clang->hasDiagnostics())

116 return llvm::createStringError(llvm::errc::not_supported,

117 "Initialization failed. "

118 "Unable to create diagnostics engine");

119

122 return llvm::createStringError(llvm::errc::not_supported,

123 "Initialization failed. "

124 "Unable to flush diagnostics");

125

126

127 llvm::MemoryBuffer *MB = llvm::MemoryBuffer::getMemBuffer("").release();

128 Clang->getPreprocessorOpts().addRemappedFile("<<< inputs >>>", MB);

129

131 Clang->getDiagnostics(), Clang->getInvocation().getTargetOpts()));

132 if (!Clang->hasTarget())

133 return llvm::createStringError(llvm::errc::not_supported,

134 "Initialization failed. "

135 "Target is missing");

136

137 Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts(),

138 Clang->getAuxTarget());

139

140

141

142 Clang->getCodeGenOpts().ClearASTBeforeBackend = false;

143

144 Clang->getFrontendOpts().DisableFree = false;

145 Clang->getCodeGenOpts().DisableFree = false;

146 return std::move(Clang);

147}

148

149}

150

152

154IncrementalCompilerBuilder::create(std::string TT,

155 std::vector<const char *> &ClangArgv) {

156

157

158

159 std::string MainExecutableName =

160 llvm::sys::fs::getMainExecutable(nullptr, nullptr);

161

162 ClangArgv.insert(ClangArgv.begin(), MainExecutableName.c_str());

163

164

165

166

167

168

169 ClangArgv.insert(ClangArgv.end(), "-Xclang");

170 ClangArgv.insert(ClangArgv.end(), "-fincremental-extensions");

171 ClangArgv.insert(ClangArgv.end(), "-c");

172

173

174

175 ClangArgv.push_back("<<< inputs >>>");

176

177

178

179 std::unique_ptr DiagOpts =

181 TextDiagnosticBuffer *DiagsBuffer = new TextDiagnosticBuffer;

183

184 driver::Driver Driver(ClangArgv[0], TT, Diags);

185 Driver.setCheckInputsExist(false);

186 llvm::ArrayRef<const char *> RF = llvm::ArrayRef(ClangArgv);

187 std::unique_ptrdriver::Compilation Compilation(Driver.BuildCompilation(RF));

188

189 if (Compilation->getArgs().hasArg(options::OPT_v))

190 Compilation->getJobs().Print(llvm::errs(), "\n", false);

191

192 auto ErrOrCC1Args = GetCC1Arguments(&Diags, Compilation.get());

193 if (auto Err = ErrOrCC1Args.takeError())

194 return std::move(Err);

195

196 return CreateCI(**ErrOrCC1Args);

197}

198

201 std::vector<const char *> Argv;

202 Argv.reserve(5 + 1 + UserArgs.size());

203 Argv.push_back("-xc++");

204#ifdef __EMSCRIPTEN__

205 Argv.push_back("-target");

206 Argv.push_back("wasm32-unknown-emscripten");

207 Argv.push_back("-fvisibility=default");

208#endif

209 llvm::append_range(Argv, UserArgs);

210

211 std::string TT = TargetTriple ? *TargetTriple : llvm::sys::getProcessTriple();

212 return IncrementalCompilerBuilder::create(TT, Argv);

213}

214

216IncrementalCompilerBuilder::createCuda(bool device) {

217 std::vector<const char *> Argv;

218 Argv.reserve(5 + 4 + UserArgs.size());

219

220 Argv.push_back("-xcuda");

221 if (device)

222 Argv.push_back("--cuda-device-only");

223 else

224 Argv.push_back("--cuda-host-only");

225

226 std::string SDKPathArg = "--cuda-path=";

227 if (!CudaSDKPath.empty()) {

228 SDKPathArg += CudaSDKPath;

229 Argv.push_back(SDKPathArg.c_str());

230 }

231

232 std::string ArchArg = "--offload-arch=";

235 Argv.push_back(ArchArg.c_str());

236 }

237

238 llvm::append_range(Argv, UserArgs);

239

240 std::string TT = TargetTriple ? *TargetTriple : llvm::sys::getProcessTriple();

241 return IncrementalCompilerBuilder::create(TT, Argv);

242}

243

246 return IncrementalCompilerBuilder::createCuda(true);

247}

248

251 return IncrementalCompilerBuilder::createCuda(false);

252}

253

255 llvm::Error &ErrOut,

256 std::unique_ptrllvm::orc::LLJITBuilder JITBuilder,

257 std::unique_ptrclang::ASTConsumer Consumer,

259 : JITBuilder(std::move(JITBuilder)) {

260 CI = std::move(Instance);

261 llvm::ErrorAsOutParameter EAO(&ErrOut);

262 auto LLVMCtx = std::make_uniquellvm::LLVMContext();

263 TSCtx = std::make_uniquellvm::orc::ThreadSafeContext(std::move(LLVMCtx));

264

265 Act = TSCtx->withContextDo([&](llvm::LLVMContext *Ctx) {

266 return std::make_unique(*CI, *Ctx, ErrOut, *this,

267 std::move(Consumer));

268 });

269

270 if (ErrOut)

271 return;

272 CI->ExecuteAction(*Act);

273

274 IncrParser =

275 std::make_unique(*CI, Act.get(), ErrOut, PTUs);

276

277 if (ErrOut)

278 return;

279

280 if (Act->getCodeGen()) {

281 Act->CacheCodeGenModule();

282

283

284 if (!CI->getPreprocessorOpts().Includes.empty() ||

285 !CI->getPreprocessorOpts().ImplicitPCHInclude.empty()) {

286

287

288

289 auto M = llvm::CloneModule(*Act->getCachedCodeGenModule());

291 IncrParser->RegisterPTU(C.getTranslationUnitDecl(), std::move(M));

292 }

294 ErrOut = joinErrors(std::move(ErrOut), std::move(Err));

295 return;

296 }

297 }

298

299

300 if (Act->getCodeGen()) {

301

302

304 if (llvm::Error Err = Execute(PTU)) {

305 ErrOut = joinErrors(std::move(ErrOut), std::move(Err));

306 return;

307 }

308 }

309}

310

312 IncrParser.reset();

313 Act->FinalizeAction();

314 if (DeviceParser)

315 DeviceParser.reset();

316 if (DeviceAct)

317 DeviceAct->FinalizeAction();

318 if (IncrExecutor) {

319 if (llvm::Error Err = IncrExecutor->cleanUp())

320 llvm::report_fatal_error(

321 llvm::Twine("Failed to clean up IncrementalExecutor: ") +

323 }

324}

325

326

327

328

330 #define __CLANG_REPL__ 1

331#ifdef __cplusplus

332 #define EXTERN_C extern "C"

333 struct __clang_Interpreter_NewTag{} __ci_newtag;

334 void* operator new(__SIZE_TYPE__, void* __p, __clang_Interpreter_NewTag) noexcept;

335 template <class T, class = T (*)() /*disable for arrays*/>

336 void __clang_Interpreter_SetValueCopyArr(const T* Src, void* Placement, unsigned long Size) {

337 for (auto Idx = 0; Idx < Size; ++Idx)

338 new ((void*)(((T*)Placement) + Idx), __ci_newtag) T(Src[Idx]);

339 }

340 template <class T, unsigned long N>

341 void __clang_Interpreter_SetValueCopyArr(const T (*Src)[N], void* Placement, unsigned long Size) {

342 __clang_Interpreter_SetValueCopyArr(Src[0], Placement, Size);

343 }

344#else

345 #define EXTERN_C extern

346 EXTERN_C void *memcpy(void *restrict dst, const void *restrict src, __SIZE_TYPE__ n);

347 EXTERN_C inline void __clang_Interpreter_SetValueCopyArr(const void* Src, void* Placement, unsigned long Size) {

348 memcpy(Placement, Src, Size);

349 }

350#endif // __cplusplus

351 EXTERN_C void *__clang_Interpreter_SetValueWithAlloc(void*, void*, void*);

352 EXTERN_C void __clang_Interpreter_SetValueNoAlloc(void *This, void *OutVal, void *OpaqueType, ...);

353)";

354

357 std::unique_ptrllvm::orc::ExecutorProcessControl EPC;

358 uint32_t childPid = -1;

360

364 if (!ResultOrErr)

365 return ResultOrErr.takeError();

366 childPid = ResultOrErr->second;

367 auto EPCOrErr = std::move(ResultOrErr->first);

368 EPC = std::move(EPCOrErr);

370#if LLVM_ON_UNIX && LLVM_ENABLE_THREADS

371 auto EPCOrErr = IncrementalExecutor::connectTCPSocket(

374 if (!EPCOrErr)

375 return EPCOrErr.takeError();

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

377#else

378 return llvm::make_errorllvm::StringError(

379 "Out-of-process JIT over TCP is not supported on this platform",

380 std::error_code());

381#endif

382 }

383

384 std::unique_ptrllvm::orc::LLJITBuilder JB;

385 if (EPC) {

388 if (!JBOrErr)

389 return JBOrErr.takeError();

390 JB = std::move(*JBOrErr);

391 }

392

393 return std::make_pair(std::move(JB), childPid);

394}

395

398 const std::array<const char *, 3> OrcRTLibNames = {

399 "liborc_rt.a", "liborc_rt_osx.a", "liborc_rt-x86_64.a"};

400

401 auto findInDir = [&](llvm::StringRef Base) -> std::optionalstd::string {

402 for (const char *LibName : OrcRTLibNames) {

404 llvm::sys::path::append(CandidatePath, LibName);

405 if (llvm::sys::fs::exists(CandidatePath))

406 return std::string(CandidatePath.str());

407 }

408 return std::nullopt;

409 };

410

411 std::string SearchedPaths;

412

413 if (std::optionalstd::string CompilerRTPath = TC.getCompilerRTPath()) {

414 if (auto Found = findInDir(*CompilerRTPath))

416 SearchedPaths += *CompilerRTPath;

417 } else {

418 return llvm::make_errorllvm::StringError("CompilerRT path not found",

419 std::error_code());

420 }

421

422 if (std::optionalstd::string ResourceDir = TC.getRuntimePath()) {

423 if (auto Found = findInDir(*ResourceDir))

425 if (!SearchedPaths.empty())

426 SearchedPaths += "; ";

427 SearchedPaths += *ResourceDir;

428 } else {

429 return llvm::make_errorllvm::StringError("ResourceDir path not found",

430 std::error_code());

431 }

432

433 return llvm::make_errorllvm::StringError(

434 llvm::Twine("OrcRuntime library not found in: ") + SearchedPaths,

435 std::error_code());

436}

437

440

442 const TargetInfo &TI = CI->getTarget();

443 const llvm::Triple &Triple = TI.getTriple();

444

446 std::string BinaryName = llvm::sys::fs::getMainExecutable(nullptr, nullptr);

447 driver::Driver Driver(BinaryName, Triple.str(), Diags);

448

449 std::vector<const char *> Args = {"clang", "--version"};

450 std::unique_ptrclang::driver::Compilation C(

451 Driver.BuildCompilation(Args));

452 if (C) {

453 return llvm::make_errorllvm::StringError(

454 "Failed to create driver compilation for out-of-process JIT",

455 std::error_code());

456 }

459

461 if (!OrcRuntimePathOrErr) {

462 return OrcRuntimePathOrErr.takeError();

463 }

464

466 }

467 }

468

469 llvm::Error Err = llvm::Error::success();

470 std::unique_ptrllvm::orc::LLJITBuilder JB;

471

472 auto Interp = std::unique_ptr(new Interpreter(

473 std::move(CI), Err, std::move(JB), nullptr, Config));

474 if (auto E = std::move(Err))

475 return std::move(E);

476

477

478

479 if (auto E = Interp->ParseAndExecute(Runtimes))

480 return std::move(E);

481

482 Interp->markUserCodeStart();

483

484 return std::move(Interp);

485}

486

489 std::unique_ptr DCI) {

490

492 std::make_uniquellvm::vfs::InMemoryFileSystem();

494 std::make_uniquellvm::vfs::OverlayFileSystem(

495 llvm::vfs::getRealFileSystem());

496 OverlayVFS->pushOverlay(IMVFS);

497 CI->createVirtualFileSystem(OverlayVFS);

498 CI->createFileManager();

499

502 if (!InterpOrErr)

503 return InterpOrErr;

504

505 std::unique_ptr Interp = std::move(*InterpOrErr);

506

507 llvm::Error Err = llvm::Error::success();

508

509 auto DeviceAct = Interp->TSCtx->withContextDo([&](llvm::LLVMContext *Ctx) {

510 return std::make_unique(*DCI, *Ctx, Err, *Interp);

511 });

512

513 if (Err)

514 return std::move(Err);

515

516 Interp->DeviceAct = std::move(DeviceAct);

517

518 DCI->ExecuteAction(*Interp->DeviceAct);

519

520 Interp->DeviceCI = std::move(DCI);

521

522 auto DeviceParser = std::make_unique(

523 *Interp->DeviceCI, *Interp->getCompilerInstance(),

524 Interp->DeviceAct.get(), IMVFS, Err, Interp->PTUs);

525

526 if (Err)

527 return std::move(Err);

528

529 Interp->DeviceParser = std::move(DeviceParser);

530 return std::move(Interp);

531}

532

537

539 if (!IncrExecutor) {

541 return std::move(Err);

542 }

543

544 return IncrExecutor->GetExecutionEngine();

545}

546

550

554

555void Interpreter::markUserCodeStart() {

556 assert(!InitPTUSize && "We only do this once");

557 InitPTUSize = PTUs.size();

558}

559

560size_t Interpreter::getEffectivePTUSize() const {

561 assert(PTUs.size() >= InitPTUSize && "empty PTU list?");

562 return PTUs.size() - InitPTUSize;

563}

564

566 if (IncrExecutor)

567 return IncrExecutor->getOutOfProcessChildPid();

568 return -1;

569}

570

573

574

575 if (DeviceParser) {

577 if (auto E = DeviceTU.takeError())

578 return std::move(E);

579

580 DeviceParser->RegisterPTU(*DeviceTU);

581

583 if (!PTX)

584 return PTX.takeError();

585

586 llvm::Error Err = DeviceParser->GenerateFatbinary();

587 if (Err)

588 return std::move(Err);

589 }

590

591

592

595

597 if (!TuOrErr)

598 return TuOrErr.takeError();

599

601

602 return LastPTU;

603}

604

607 if (TT == llvm::sys::getProcessTriple())

608

609 return llvm::orc::JITTargetMachineBuilder::detectHost();

610

611

612 return llvm::orc::JITTargetMachineBuilder(llvm::Triple(TT));

613}

614

617 std::unique_ptrllvm::orc::ExecutorProcessControl EPC,

618 llvm::StringRef OrcRuntimePath) {

619 const std::string &TT = EPC->getTargetTriple().getTriple();

621 if (!JTMB)

622 return JTMB.takeError();

624 if (!JB)

625 return JB.takeError();

626

627 (*JB)->setExecutorProcessControl(std::move(EPC));

628 (*JB)->setPlatformSetUp(

629 llvm::orc::ExecutorNativePlatform(OrcRuntimePath.str()));

630

631 return std::move(*JB);

632}

633

635 if (IncrExecutor)

636 return llvm::make_errorllvm::StringError("Operation failed. "

637 "Execution engine exists",

638 std::error_code());

639 if (!Act->getCodeGen())

640 return llvm::make_errorllvm::StringError("Operation failed. "

641 "No code generator available",

642 std::error_code());

643

645 llvm::Triple TargetTriple(TT);

646 bool IsWindowsTarget = TargetTriple.isOSWindows();

647

649 if (!JITBuilder) {

651 if (!ResOrErr)

652 return ResOrErr.takeError();

653 JITBuilder = std::move(ResOrErr->first);

655 }

656 if (!JITBuilder)

657 return llvm::make_errorllvm::StringError(

658 "Operation failed. No LLJITBuilder for out-of-process JIT",

659 std::error_code());

660 }

661

662 if (!JITBuilder) {

664 if (!JTMB)

665 return JTMB.takeError();

666 if (Config.CM)

667 JTMB->setCodeModel(Config.CM);

669 if (!JB)

670 return JB.takeError();

671 JITBuilder = std::move(*JB);

672 }

673

674 llvm::Error Err = llvm::Error::success();

675

676

677 std::unique_ptr Executor;

678

679#ifdef __EMSCRIPTEN__

680 Executor = std::make_unique(*TSCtx);

681#else

682 Executor =

683 std::make_unique(*TSCtx, *JITBuilder, Config, Err);

684#endif

685 if (!Err)

686 IncrExecutor = std::move(Executor);

687

688 return Err;

689}

690

692

694 assert(T.TheModule);

695 LLVM_DEBUG(

696 llvm::dbgs() << "execute-ptu "

697 << (llvm::is_contained(PTUs, T)

698 ? std::distance(PTUs.begin(), llvm::find(PTUs, T))

699 : -1)

700 << ": [TU=" << T.TUPart << ", M=" << T.TheModule.get()

701 << " (" << T.TheModule->getName() << ")]\n");

702 if (!IncrExecutor) {

704 if (Err)

705 return Err;

706 }

707

708 if (auto Err = IncrExecutor->addModule(T))

709 return Err;

710

711 if (auto Err = IncrExecutor->runCtors())

712 return Err;

713

714 return llvm::Error::success();

715}

716

718

719 auto PTU = Parse(Code);

720 if (!PTU)

721 return PTU.takeError();

722 if (PTU->TheModule)

723 if (llvm::Error Err = Execute(*PTU))

724 return Err;

725

726 if (LastValue.isValid()) {

727 if (V) {

728 LastValue.dump();

729 LastValue.clear();

730 } else

731 *V = std::move(LastValue);

732 }

733 return llvm::Error::success();

734}

735

738 if (!IncrExecutor)

739 return llvm::make_errorllvm::StringError("Operation failed. "

740 "No execution engine",

741 std::error_code());

742 llvm::StringRef MangledName = Act->getCodeGen()->GetMangledName(GD);

744}

745

748 if (!IncrExecutor)

749 return llvm::make_errorllvm::StringError("Operation failed. "

750 "No execution engine",

751 std::error_code());

752

754}

755

758 if (!IncrExecutor)

759 return llvm::make_errorllvm::StringError("Operation failed. "

760 "No execution engine",

761 std::error_code());

762

764}

765

767

768 if (getEffectivePTUSize() == 0) {

769 return llvm::make_errorllvm::StringError("Operation failed. "

770 "No input left to undo",

771 std::error_code());

772 } else if (N > getEffectivePTUSize()) {

773 return llvm::make_errorllvm::StringError(

774 llvm::formatv(

775 "Operation failed. Wanted to undo {0} inputs, only have {1}.", N,

776 getEffectivePTUSize()),

777 std::error_code());

778 }

779

780 for (unsigned I = 0; I < N; I++) {

781 if (IncrExecutor) {

782 if (llvm::Error Err = IncrExecutor->removeModule(PTUs.back()))

783 return Err;

784 }

785

786 IncrParser->CleanUpPTU(PTUs.back().TUPart);

787 PTUs.pop_back();

788 }

789 return llvm::Error::success();

790}

791

793#ifdef __EMSCRIPTEN__

794 void *handle = dlopen(name, RTLD_NOW | RTLD_GLOBAL);

795 if (!handle) {

796 llvm::errs() << dlerror() << '\n';

797 return llvm::make_errorllvm::StringError("Failed to load dynamic library",

798 llvm::inconvertibleErrorCode());

799 }

800#else

802 if (!EE)

803 return EE.takeError();

804

806 std::unique_ptrllvm::orc::EPCDynamicLibrarySearchGenerator>

807 DLSG = llvm::orc::EPCDynamicLibrarySearchGenerator::Load(

808 EE->getExecutionSession(), name))

809

810

811 EE->getProcessSymbolsJITDylib()->addGenerator(std::move(*DLSG));

812 else

813 return DLSG.takeError();

814#endif

815

816 return llvm::Error::success();

817}

818}

Defines the clang::ASTContext interface.

Defines the clang::FrontendAction interface and various convenience abstract classes (clang::ASTFront...

static std::string toString(const clang::SanitizerSet &Sanitizers)

Produce a string containing comma-separated names of sanitizers in Sanitizers set.

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

CompilerInstance - Helper class for managing a single instance of the Clang compiler.

DiagnosticsEngine & getDiagnostics() const

Get the current diagnostics engine.

ASTContext & getASTContext() const

TargetOptions & getTargetOpts()

static bool CreateFromArgs(CompilerInvocation &Res, ArrayRef< const char * > CommandLineArgs, DiagnosticsEngine &Diags, const char *Argv0=nullptr)

Create a compiler invocation from a list of input options.

static llvm::IntrusiveRefCntPtr< DiagnosticIDs > create()

Options for controlling the compiler diagnostics engine.

Concrete class used by the front-end to report problems and issues.

void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc)

This allows the client to specify that certain warnings are ignored.

GlobalDecl - represents a global declaration.

llvm::Expected< std::unique_ptr< CompilerInstance > > CreateCudaHost()

Definition Interpreter.cpp:250

llvm::Expected< std::unique_ptr< CompilerInstance > > CreateCudaDevice()

Definition Interpreter.cpp:245

llvm::Expected< std::unique_ptr< CompilerInstance > > CreateCpp()

Definition Interpreter.cpp:200

static llvm::Expected< std::pair< std::unique_ptr< llvm::orc::SimpleRemoteEPC >, uint32_t > > launchExecutor(llvm::StringRef ExecutablePath, bool UseSharedMemory, unsigned SlabAllocateSize, std::function< void()> CustomizeFork=nullptr)

static llvm::Expected< std::unique_ptr< llvm::orc::LLJITBuilder > > createDefaultJITBuilder(llvm::orc::JITTargetMachineBuilder JTMB)

llvm::Error ParseAndExecute(llvm::StringRef Code, Value *V=nullptr)

Definition Interpreter.cpp:717

uint32_t getOutOfProcessExecutorPID() const

Definition Interpreter.cpp:565

llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddress(GlobalDecl GD) const

Definition Interpreter.cpp:737

static llvm::Expected< std::pair< std::unique_ptr< llvm::orc::LLJITBuilder >, uint32_t > > outOfProcessJITBuilder(JITConfig Config)

Definition Interpreter.cpp:356

llvm::Error LoadDynamicLibrary(const char *name)

Link a dynamic library.

Definition Interpreter.cpp:792

static llvm::Expected< std::unique_ptr< Interpreter > > createWithCUDA(std::unique_ptr< CompilerInstance > CI, std::unique_ptr< CompilerInstance > DCI)

Definition Interpreter.cpp:488

llvm::Error CreateExecutor(JITConfig Config=JITConfig())

Definition Interpreter.cpp:634

virtual ~Interpreter()

Definition Interpreter.cpp:311

llvm::Expected< PartialTranslationUnit & > Parse(llvm::StringRef Code)

Definition Interpreter.cpp:572

llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddressFromLinkerName(llvm::StringRef LinkerName) const

Definition Interpreter.cpp:757

void ResetExecutor()

Definition Interpreter.cpp:691

llvm::Error Undo(unsigned N=1)

Undo N previous incremental inputs.

Definition Interpreter.cpp:766

const CompilerInstance * getCompilerInstance() const

Definition Interpreter.cpp:534

static llvm::Expected< std::unique_ptr< llvm::orc::LLJITBuilder > > createLLJITBuilder(std::unique_ptr< llvm::orc::ExecutorProcessControl > EPC, llvm::StringRef OrcRuntimePath)

Definition Interpreter.cpp:616

static llvm::Expected< std::string > getOrcRuntimePath(const driver::ToolChain &TC)

Definition Interpreter.cpp:397

const ASTContext & getASTContext() const

Definition Interpreter.cpp:551

llvm::Expected< llvm::orc::LLJIT & > getExecutionEngine()

Definition Interpreter.cpp:538

static llvm::Expected< std::unique_ptr< Interpreter > > create(std::unique_ptr< CompilerInstance > CI, JITConfig Config={})

Definition Interpreter.cpp:439

llvm::Error Execute(PartialTranslationUnit &T)

Definition Interpreter.cpp:693

Interpreter(std::unique_ptr< CompilerInstance > Instance, llvm::Error &Err, std::unique_ptr< llvm::orc::LLJITBuilder > JITBuilder=nullptr, std::unique_ptr< clang::ASTConsumer > Consumer=nullptr, JITConfig Config=JITConfig())

Definition Interpreter.cpp:254

Encodes a location in the source.

Exposes information about the current target.

static TargetInfo * CreateTargetInfo(DiagnosticsEngine &Diags, TargetOptions &Opts)

Construct a target for the given options.

const llvm::Triple & getTriple() const

Returns the target triple of the primary target.

std::string Triple

The name of the target triple to compile for.

void FlushDiagnostics(DiagnosticsEngine &Diags) const

FlushDiagnostics - Flush the buffered diagnostics to an given diagnostic engine.

Command - An executable path/name and argument vector to execute.

const Tool & getCreator() const

getCreator - Return the Tool which caused the creation of this job.

const llvm::opt::ArgStringList & getArguments() const

Compilation - A set of tasks to perform for a single driver invocation.

Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...

JobList - A sequence of jobs to perform.

Defines the clang::TargetInfo interface.

@ Ignored

Do not present this diagnostic, ignore it.

The JSON file list parser is used to communicate input to InstallAPI.

static llvm::Expected< llvm::orc::JITTargetMachineBuilder > createJITTargetMachineBuilder(const std::string &TT)

Definition Interpreter.cpp:606

bool isa(CodeGen::Address addr)

std::unique_ptr< DiagnosticOptions > CreateAndPopulateDiagOpts(ArrayRef< const char * > Argv)

@ Success

Annotation was successful.

@ Parse

Parse the block; this code is always used.

const char *const Runtimes

Definition Interpreter.cpp:329

const FunctionProtoType * T

std::string GetResourcesPath(StringRef BinaryPath)

Get the directory where the compiler headers reside, relative to the compiler binary path BinaryPath.

U cast(CodeGen::Address addr)

bool(*)(llvm::ArrayRef< const char * >, llvm::raw_ostream &, llvm::raw_ostream &, bool, bool) Driver

uint32_t ExecutorPID

PID of the out-of-process JIT executor.

std::function< void()> CustomizeFork

Custom lambda to be executed inside child process/executor.

bool IsOutOfProcess

Indicates whether out-of-process JIT execution is enabled.

std::string OrcRuntimePath

Path to the ORC runtime library.

std::optional< llvm::CodeModel::Model > CM

An optional code model to provide to the JITTargetMachineBuilder.

unsigned SlabAllocateSize

Representing the slab allocation size for memory management in kb.

bool UseSharedMemory

Indicates whether to use shared memory for communication.

std::string OOPExecutor

Path to the out-of-process JIT executor.

std::string OOPExecutorConnect

The class keeps track of various objects created as part of processing incremental inputs.