clang 24.0.0git
IncrementalExecutor.h
Go to the documentation of this file.
1//===--- IncrementalExecutor.h - Base Incremental Execution -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the base class that performs incremental code execution.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
14#define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
15
16#include "llvm/Support/CodeGen.h"
17#include "llvm/Support/Error.h"
18
19namespace llvm {
20namespace orc {
21class ExecutorAddr;
22class LLJITBuilder;
23class ThreadSafeContext;
24} // namespace orc
25} // namespace llvm
26
27namespace clang {
28class IncrementalExecutor;
29class TargetInfo;
30namespace driver {
31class Compilation;
32} // namespace driver
33
35public:
36 /// Indicates whether out-of-process JIT execution is enabled.
37 bool IsOutOfProcess = false;
38 /// Path to the out-of-process JIT executor.
39 std::string OOPExecutor = "";
40 std::string OOPExecutorConnect = "";
41 /// Indicates whether to use shared memory for communication.
42 bool UseSharedMemory = false;
43 /// Representing the slab allocation size for memory management in kb.
44 unsigned SlabAllocateSize = 0;
45 /// Path to the ORC runtime library.
46 std::string OrcRuntimePath = "";
47 /// PID of the out-of-process JIT executor.
49 /// Custom lambda to be executed inside child process/executor
50 std::function<void()> CustomizeFork = nullptr;
51 /// An optional code model to provide to the JITTargetMachineBuilder
52 std::optional<llvm::CodeModel::Model> CM = std::nullopt;
53 /// An optional external IncrementalExecutor
54 std::unique_ptr<IncrementalExecutor> IE;
55 /// mllvm args from the frontend; on wasm these are re-applied after each
56 /// lldMain call because lld resets all cl options for test-isolation
57 /// purposes.
58 std::vector<std::string> LLVMArgs;
59#ifndef __EMSCRIPTEN__
60 /// An optional external orc jit builder
61 std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder;
62#endif
63 /// A default callback that can be used in the IncrementalCompilerBuilder to
64 /// retrieve the path to the orc runtime.
65 std::function<llvm::Error(const driver::Compilation &)>
67 return UpdateOrcRuntimePath(C);
68 };
69
71
73 create(llvm::orc::ThreadSafeContext &TSC, const clang::TargetInfo &TI);
74
75private:
76 llvm::Error UpdateOrcRuntimePath(const driver::Compilation &C);
77};
78
80
82public:
84
85 virtual ~IncrementalExecutor() = default;
86
87 virtual llvm::Error addModule(PartialTranslationUnit &PTU) = 0;
88 virtual llvm::Error removeModule(PartialTranslationUnit &PTU) = 0;
89 virtual llvm::Error runCtors() const = 0;
90 virtual llvm::Error cleanUp() = 0;
91
93 getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const = 0;
94 virtual llvm::Error LoadDynamicLibrary(const char *name) = 0;
95};
96
97} // namespace clang
98
99#endif // LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
std::optional< llvm::CodeModel::Model > CM
An optional code model to provide to the JITTargetMachineBuilder.
std::function< llvm::Error(const driver::Compilation &)> UpdateOrcRuntimePathCB
A default callback that can be used in the IncrementalCompilerBuilder to retrieve the path to the orc...
bool IsOutOfProcess
Indicates whether out-of-process JIT execution is enabled.
std::unique_ptr< IncrementalExecutor > IE
An optional external IncrementalExecutor.
std::function< void()> CustomizeFork
Custom lambda to be executed inside child process/executor.
std::string OOPExecutor
Path to the out-of-process JIT executor.
uint32_t ExecutorPID
PID of the out-of-process JIT executor.
bool UseSharedMemory
Indicates whether to use shared memory for communication.
llvm::Expected< std::unique_ptr< IncrementalExecutor > > create(llvm::orc::ThreadSafeContext &TSC, const clang::TargetInfo &TI)
std::string OrcRuntimePath
Path to the ORC runtime library.
std::unique_ptr< llvm::orc::LLJITBuilder > JITBuilder
An optional external orc jit builder.
unsigned SlabAllocateSize
Representing the slab allocation size for memory management in kb.
std::vector< std::string > LLVMArgs
mllvm args from the frontend; on wasm these are re-applied after each lldMain call because lld resets...
virtual llvm::Error LoadDynamicLibrary(const char *name)=0
virtual llvm::Error cleanUp()=0
virtual llvm::Error runCtors() const =0
virtual llvm::Error removeModule(PartialTranslationUnit &PTU)=0
virtual llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const =0
virtual ~IncrementalExecutor()=default
virtual llvm::Error addModule(PartialTranslationUnit &PTU)=0
Exposes information about the current target.
Definition TargetInfo.h:228
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:46
Top level wrappers for InstallAPI frontend operations.
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
int const char * function
Definition c++config.h:31
The class keeps track of various objects created as part of processing incremental inputs.