clang 23.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.
48 uint32_t ExecutorPID = 0;
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 /// An optional external orc jit builder
56 std::unique_ptr<llvm::orc::LLJITBuilder> JITBuilder;
57 /// A default callback that can be used in the IncrementalCompilerBuilder to
58 /// retrieve the path to the orc runtime.
59 std::function<llvm::Error(const driver::Compilation &)>
61 return UpdateOrcRuntimePath(C);
62 };
63
65
67 create(llvm::orc::ThreadSafeContext &TSC, const clang::TargetInfo &TI);
68
69private:
70 llvm::Error UpdateOrcRuntimePath(const driver::Compilation &C);
71};
72
74
76public:
78
79 virtual ~IncrementalExecutor() = default;
80
81 virtual llvm::Error addModule(PartialTranslationUnit &PTU) = 0;
82 virtual llvm::Error removeModule(PartialTranslationUnit &PTU) = 0;
83 virtual llvm::Error runCtors() const = 0;
84 virtual llvm::Error cleanUp() = 0;
85
87 getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const = 0;
88 virtual llvm::Error LoadDynamicLibrary(const char *name) = 0;
89};
90
91} // namespace clang
92
93#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.
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:226
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:45
The JSON file list parser is used to communicate input to InstallAPI.
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.