llvm-project/llvm/lib/ExecutionEngine/Orc
Lang Hames f9aef477eb [ORC][ORC-RT] Rewrite the MachO platform to use allocation actions.
This patch updates the MachO platform (both the ORC MachOPlatform class and the
ORC-Runtime macho_platform.* files) to use allocation actions, rather than EPC
calls, to transfer the initializer information scraped from each linked object.
Interactions between the ORC and ORC-Runtime sides of the platform are
substantially redesigned to accomodate the change.

The high-level changes in this patch are:

1. The MachOPlatform::setupJITDylib method now calls into the runtime to set up
   a dylib name <-> header mapping, and a dylib state object (JITDylibState).

2. The MachOPlatformPlugin builds an allocation action that calls the
   __orc_rt_macho_register_object_platform_sections and
   __orc_rt_macho_deregister_object_platform_sections functions in the runtime
   to register the address ranges for all "interesting" sections in the object
   being allocated (TLS data sections, initializers, language runtime metadata
   sections, etc.).

3. The MachOPlatform::rt_getInitializers method (the entry point in the
   controller for requests from the runtime for initializer information) is
   replaced by MachOPlatform::rt_pushInitializers. The former returned a data
   structure containing the "interesting" section address ranges, but these are
   now handled by __orc_rt_macho_register_object_platform_sections. The new
   rt_pushInitializers method first issues a lookup to trigger materialization
   of the "interesting" sections, then returns the dylib dependence tree rooted
   at the requested dylib for dlopen to consume. (The dylib dependence tree is
   returned by rt_pushInitializers, rather than being handled by some dedicated
   call, because rt_pushInitializers can alter the dependence tree).

The advantage of these changes (beyond the performance advantages of using
allocation actions) is that it moves more information about the materialized
portions of the JITDylib into the executor. This tends to make the runtime
easier to reason about, e.g. the implementation of dlopen in the runtime is now
recursive, rather than relying on recursive calls in the controller to build a
linear data structure for consumption by the runtime. This change can also make
some operations more efficient, e.g. JITDylibs can be dlclosed and then
re-dlopened without having to pull all initializers over from the controller
again.

In addition to the high-level changes, there are some low-level changes to ORC
and the runtime:

* In ORC, at ExecutionSession teardown time JITDylibs are now destroyed in
reverse creation order. This is on the assumption that the ORC runtime will be
loaded into an earlier dylib that will be used by later JITDylibs. This is a
short-term solution to crashes that arose during testing when the runtime was
torn down before its users. Longer term we will likely destroy dylibs in
dependence order.

* toSPSSerializable(Expected<T> E) is updated to explicitly initialize the T
value, allowing it to be used by Ts that have explicit constructors.

* The ORC runtime now (1) attempts to track ref-counts, and (2) distinguishes
not-yet-processed "interesting" sections from previously processed ones. (1)
is necessary for standard dlopen/dlclose emulation. (2) is intended as a step
towards better REPL support -- it should enable future runtime calls that
run only newly registered initializers ("dlopen_more", "dlopen_additions",
...?).
2022-02-08 17:28:13 +11:00
..
Shared [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
TargetProcess [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
CMakeLists.txt [ORC] Add MaterializationUnit::Interface parameter to ObjectLayer::add. 2021-12-15 12:03:55 +11:00
CompileOnDemandLayer.cpp [ORC] Add a MaterializationUnit::Interface struct. 2021-12-08 13:41:15 +11:00
CompileUtils.cpp [llvm] Add null-termination capability to SmallVectorMemoryBuffer 2021-12-09 11:32:13 +01:00
Core.cpp [ORC][ORC-RT] Rewrite the MachO platform to use allocation actions. 2022-02-08 17:28:13 +11:00
DebugObjectManagerPlugin.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
DebugUtils.cpp [llvm] Use llvm::drop_begin (NFC) 2021-02-22 20:17:16 -08:00
DebuggerSupportPlugin.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
ELFNixPlatform.cpp [ORC] Allow JITDylib::getDFSLinkOrder and friends to fail for defunct JITDylibs. 2022-01-20 17:45:32 +11:00
EPCDebugObjectRegistrar.cpp Re-apply e50aea58d5, "Major JITLinkMemoryManager refactor". with fixes. 2021-10-11 21:39:00 -07:00
EPCDynamicLibrarySearchGenerator.cpp [ORC] Require ExecutorProcessControl when constructing an ExecutionSession. 2021-07-27 16:53:49 +10:00
EPCEHFrameRegistrar.cpp [ORC][JITLink] Merge JITLink AllocActionCall and ORC WrapperFunctionCall. 2022-01-08 16:46:15 +11:00
EPCGenericDylibManager.cpp [ORC] Switch from JITTargetAddress to ExecutorAddr for EPC-call APIs. 2021-09-27 16:53:09 -07:00
EPCGenericJITLinkMemoryManager.cpp [ORC][JITLink] Merge JITLink AllocActionCall and ORC WrapperFunctionCall. 2022-01-08 16:46:15 +11:00
EPCGenericRTDyldMemoryManager.cpp [ORC][JITLink] Merge JITLink AllocActionCall and ORC WrapperFunctionCall. 2022-01-08 16:46:15 +11:00
EPCIndirectionUtils.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
ExecutionUtils.cpp [ORC] Add custom object interface support to StaticLibaryDefinitionGenerator. 2021-12-16 19:46:51 +11:00
ExecutorProcessControl.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
IRCompileLayer.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
IRTransformLayer.cpp
IndirectionUtils.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
JITTargetMachineBuilder.cpp Move TargetRegistry.(h|cpp) from Support to MC 2021-10-08 14:51:48 -07:00
LLJIT.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
Layer.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
LazyReexports.cpp [ORC] Add a MaterializationUnit::Interface struct. 2021-12-08 13:41:15 +11:00
LookupAndRecordAddrs.cpp [ORC] Rename ExecutorAddress to ExecutorAddr. 2021-09-23 20:35:17 -07:00
MachOPlatform.cpp [ORC][ORC-RT] Rewrite the MachO platform to use allocation actions. 2022-02-08 17:28:13 +11:00
Mangling.cpp [ORC] Add MaterializationUnit::Interface parameter to ObjectLayer::add. 2021-12-15 12:03:55 +11:00
ObjectFileInterface.cpp [ORC] Add MaterializationUnit::Interface parameter to ObjectLayer::add. 2021-12-15 12:03:55 +11:00
ObjectLinkingLayer.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
ObjectTransformLayer.cpp [Orc] Use extensible RTTI for the orc::ObjectLayer class hierarchy 2021-02-26 13:13:05 +01:00
OrcABISupport.cpp
OrcV2CBindings.cpp [llvm] Use nullptr instead of 0 (NFC) 2021-12-28 08:52:25 -08:00
RTDyldObjectLinkingLayer.cpp [Orc] Use extensible RTTI for the orc::ObjectLayer class hierarchy 2021-02-26 13:13:05 +01:00
SimpleRemoteEPC.cpp [ORC] Run incoming jit-dispatch calls via the TaskDispatcher in SimpleRemoteEPC. 2021-11-01 15:49:14 -07:00
SpeculateAnalyses.cpp [llvm] Use llvm::sort (NFC) 2021-01-17 10:39:45 -08:00
Speculation.cpp
TaskDispatch.cpp [llvm] Use = default (NFC) 2022-02-06 22:18:35 -08:00
ThreadSafeModule.cpp