Skip to content

Commit 1d0676b

Browse files
committed
[ORC] Break up OrcJIT library, add Orc-RPC based remote TargetProcessControl
implementation. This patch aims to improve support for out-of-process JITing using OrcV2. It introduces two new class templates, OrcRPCTargetProcessControlBase and OrcRPCTPCServer, which together implement the TargetProcessControl API by forwarding operations to an execution process via an Orc-RPC Endpoint. These utilities are used to implement out-of-process JITing from llvm-jitlink to a new llvm-jitlink-executor tool. This patch also breaks the OrcJIT library into three parts: -- OrcTargetProcess: Contains code needed by the JIT execution process. -- OrcShared: Contains code needed by the JIT execution and compiler processes -- OrcJIT: Everything else. This break-up allows JIT executor processes to link against OrcTargetProcess and OrcShared only, without having to link in all of OrcJIT. Clients executing JIT'd code in-process should start linking against OrcTargetProcess as well as OrcJIT. In the near future these changes will enable: -- Removal of the OrcRemoteTargetClient/OrcRemoteTargetServer class templates which provided similar functionality in OrcV1. -- Restoration of Chapter 5 of the Building-A-JIT tutorial series, which will serve as a simple usage example for these APIs. -- Implementation of lazy, cross-target compilation in lli's -jit-kind=orc-lazy mode.
1 parent 9606ef0 commit 1d0676b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2525
-320
lines changed

llvm/examples/OrcV2Examples/LLJITWithTargetProcessControl/LLJITWithTargetProcessControl.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ int main(int argc, char *argv[]) {
134134
ExitOnErr.setBanner(std::string(argv[0]) + ": ");
135135

136136
// (1) Create LLJIT instance.
137-
auto TPC = ExitOnErr(SelfTargetProcessControl::Create());
137+
auto SSP = std::make_shared<SymbolStringPool>();
138+
auto TPC = ExitOnErr(SelfTargetProcessControl::Create(std::move(SSP)));
138139
auto J = ExitOnErr(LLJITBuilder().setTargetProcessControl(*TPC).create());
139140

140141
// (2) Install transform to print modules as they are compiled:

llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h

-8
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@
2121
namespace llvm {
2222
namespace jitlink {
2323

24-
/// Registers all FDEs in the given eh-frame section with the current process.
25-
Error registerEHFrameSection(const void *EHFrameSectionAddr,
26-
size_t EHFrameSectionSize);
27-
28-
/// Deregisters all FDEs in the given eh-frame section with the current process.
29-
Error deregisterEHFrameSection(const void *EHFrameSectionAddr,
30-
size_t EHFrameSectionSize);
31-
3224
/// Supports registration/deregistration of EH-frames in a target process.
3325
class EHFrameRegistrar {
3426
public:

llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h

+11
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,17 @@ class LinkGraph {
801801
/// Returns the endianness of content in this graph.
802802
support::endianness getEndianness() const { return Endianness; }
803803

804+
/// Allocate a copy of the given String using the LinkGraph's allocator.
805+
/// This can be useful when renaming symbols or adding new content to the
806+
/// graph.
807+
StringRef allocateString(Twine Source) {
808+
SmallString<256> TmpBuffer;
809+
auto SourceStr = Source.toStringRef(TmpBuffer);
810+
auto *AllocatedBuffer = Allocator.Allocate<char>(SourceStr.size());
811+
llvm::copy(SourceStr, AllocatedBuffer);
812+
return StringRef(AllocatedBuffer, SourceStr.size());
813+
}
814+
804815
/// Create a section with the given name, protection flags, and alignment.
805816
Section &createSection(StringRef Name, sys::Memory::ProtectionFlags Prot) {
806817
std::unique_ptr<Section> Sec(new Section(Name, Prot, Sections.size()));

llvm/include/llvm/ExecutionEngine/Orc/ExecutionUtils.h

-11
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,6 @@ namespace orc {
4141

4242
class ObjectLayer;
4343

44-
/// Run a main function, returning the result.
45-
///
46-
/// If the optional ProgramName argument is given then it will be inserted
47-
/// before the strings in Args as the first argument to the called function.
48-
///
49-
/// It is legal to have an empty argument list and no program name, however
50-
/// many main functions will expect a name argument at least, and will fail
51-
/// if none is provided.
52-
int runAsMain(int (*Main)(int, char *[]), ArrayRef<std::string> Args,
53-
Optional<StringRef> ProgramName = None);
54-
5544
/// This iterator provides a convenient way to iterate over the elements
5645
/// of an llvm.global_ctors/llvm.global_dtors instance.
5746
///

0 commit comments

Comments
 (0)