clang 22.0.0git
IncrementalExecutor.h
Go to the documentation of this file.
1//===--- IncrementalExecutor.h - 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 class which performs incremental code execution.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
14#define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
15
17#include "llvm/ADT/DenseMap.h"
18#include "llvm/ADT/StringRef.h"
19#include "llvm/ExecutionEngine/Orc/Core.h"
20#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
21#include "llvm/ExecutionEngine/Orc/Layer.h"
22#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
23#include "llvm/ExecutionEngine/Orc/SimpleRemoteEPC.h"
24#include "llvm/Support/Error.h"
25
26#include <cstdint>
27#include <memory>
28#include <string>
29
30namespace llvm {
31class Error;
32namespace orc {
33class JITTargetMachineBuilder;
34class LLJIT;
35class LLJITBuilder;
36class ThreadSafeContext;
37} // namespace orc
38} // namespace llvm
39
40namespace clang {
41
43class TargetInfo;
44
46 using CtorDtorIterator = llvm::orc::CtorDtorIterator;
47 std::unique_ptr<llvm::orc::LLJIT> Jit;
48 llvm::orc::ThreadSafeContext &TSCtx;
49 uint32_t OutOfProcessChildPid = -1;
50
51 llvm::DenseMap<const PartialTranslationUnit *, llvm::orc::ResourceTrackerSP>
52 ResourceTrackers;
53
54protected:
55 IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC);
56
57public:
59
60 IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
61 llvm::orc::LLJITBuilder &JITBuilder,
62 Interpreter::JITConfig Config, llvm::Error &Err);
63 virtual ~IncrementalExecutor();
64
65 virtual llvm::Error addModule(PartialTranslationUnit &PTU);
66 virtual llvm::Error removeModule(PartialTranslationUnit &PTU);
67 virtual llvm::Error runCtors() const;
68 virtual llvm::Error cleanUp();
70 getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
71
72 llvm::orc::LLJIT &GetExecutionEngine() { return *Jit; }
73
74 uint32_t getOutOfProcessChildPid() const { return OutOfProcessChildPid; }
75
77 createDefaultJITBuilder(llvm::orc::JITTargetMachineBuilder JTMB);
78
79 static llvm::Expected<
80 std::pair<std::unique_ptr<llvm::orc::SimpleRemoteEPC>, uint32_t>>
81 launchExecutor(llvm::StringRef ExecutablePath, bool UseSharedMemory,
82 unsigned SlabAllocateSize,
83 std::function<void()> CustomizeFork = nullptr);
84
85#if LLVM_ON_UNIX && LLVM_ENABLE_THREADS
87 connectTCPSocket(llvm::StringRef NetworkAddress, bool UseSharedMemory,
88 unsigned SlabAllocateSize);
89#endif
90};
91
92} // end namespace clang
93
94#endif // LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
llvm::orc::LLJIT & GetExecutionEngine()
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)
virtual llvm::Error runCtors() const
uint32_t getOutOfProcessChildPid() const
virtual llvm::Error addModule(PartialTranslationUnit &PTU)
virtual llvm::Expected< llvm::orc::ExecutorAddr > getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const
static llvm::Expected< std::unique_ptr< llvm::orc::LLJITBuilder > > createDefaultJITBuilder(llvm::orc::JITTargetMachineBuilder JTMB)
virtual llvm::Error removeModule(PartialTranslationUnit &PTU)
IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC)
Exposes information about the current target.
Definition TargetInfo.h:226
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.