aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Orc
AgeCommit message (Collapse)AuthorFilesLines
2023-01-12[ORC] Tidy up MachOPlatform's references to ORC runtime registration functions.Lang Hames1-28/+21
Use an private struct, RuntimeFunction, to to keep the name and address of each registration function together, and rename the member variables with their purpose rather than the full name of the function in the runtime.
2023-01-05Move from llvm::makeArrayRef to ArrayRef deduction guides - llvm/ partserge-sans-paille2-5/+5
Use deduction guides instead of helper functions. The only non-automatic changes have been: 1. ArrayRef(some_uint8_pointer, 0) needs to be changed into ArrayRef(some_uint8_pointer, (size_t)0) to avoid an ambiguous call with ArrayRef((uint8_t*), (uint8_t*)) 2. CVSymbol sym(makeArrayRef(symStorage)); needed to be rewritten as CVSymbol sym{ArrayRef(symStorage)}; otherwise the compiler is confused and thinks we have a (bad) function prototype. There was a few similar situation across the codebase. 3. ADL doesn't seem to work the same for deduction-guides and functions, so at some point the llvm namespace must be explicitly stated. 4. The "reference mode" of makeArrayRef(ArrayRef<T> &) that acts as no-op is not supported (a constructor cannot achieve that). Per reviewers' comment, some useless makeArrayRef have been removed in the process. This is a follow-up to https://reviews.llvm.org/D140896 that introduced the deduction guides. Differential Revision: https://reviews.llvm.org/D140955
2022-12-20[Support] Move TargetParsers to new componentArchibald Elliott2-0/+2
This is a fairly large changeset, but it can be broken into a few pieces: - `llvm/Support/*TargetParser*` are all moved from the LLVM Support component into a new LLVM Component called "TargetParser". This potentially enables using tablegen to maintain this information, as is shown in https://reviews.llvm.org/D137517. This cannot currently be done, as llvm-tblgen relies on LLVM's Support component. - This also moves two files from Support which use and depend on information in the TargetParser: - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting the current Host machine for info about it, primarily to support getting the host triple, but also for `-mcpu=native` support in e.g. Clang. This is fairly tightly intertwined with the information in `X86TargetParser.h`, so keeping them in the same component makes sense. - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains the target triple parser and representation. This is very intertwined with the Arm target parser, because the arm architecture version appears in canonical triples on arm platforms. - I moved the relevant unittests to their own directory. And so, we end up with a single component that has all the information about the following, which to me seems like a unified component: - Triples that LLVM Knows about - Architecture names and CPUs that LLVM knows about - CPU detection logic for LLVM Given this, I have also moved `RISCVISAInfo.h` into this component, as it seems to me to be part of that same set of functionality. If you get link errors in your components after this patch, you likely need to add TargetParser into LLVM_LINK_COMPONENTS in CMake. Differential Revision: https://reviews.llvm.org/D137838
2022-12-19[ORC] Add JITDylib argument to ResourceManager notify-removing/transferring ops.Lang Hames5-15/+23
In some cases it's helpful to group trackers by JITDylib. E.g. Platform classes may want to track initializer symbols with a `JITDylib -> Tracker -> [ Symbol ]` map. This makes it easy to collect all symbols for the JITDylib, while still allowing efficient removal of a single tracker. Passing the JITDylib as an argument to ResourceManager::notifyRemovingResources and ResourceManager::notifyTransferringResources supports such use-cases.
2022-12-17[C-API] LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacksLang Hames2-1/+111
Adds a LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks function that can be used to create an RTDyldObjectLinkingLayer using callbacks that are similar (but not identical) to those used in LLVMCreateSimpleMCJITMemoryManager. This is intended to ease the transition to ORC for MCJIT C-API clients. Differential Revision: https://reviews.llvm.org/D139393
2022-12-16[Alignment] Use Align in SectionRef::getAlignment()Guillaume Chatelet1-5/+5
Differential Revision: https://reviews.llvm.org/D139110
2022-12-14[NFC] Cleanup: Remove unnecessary use of Function::getBasicBlockList()Vasileios Porpodas1-1/+1
2022-12-14[ExecutionEngine] llvm::Optional => std::optionalFangrui Song7-12/+12
2022-12-13[NFC] Cleanup: Remove Function::getBasicBlockList() when not required.Vasileios Porpodas1-1/+1
This is part of a series of patches that aim at making Function::getBasicBlockList() private. Differential Revision: https://reviews.llvm.org/D139910
2022-12-12[ORC] Extract hasInitializerSection for testing (NFC)Keith Smiley2-24/+19
Based on the discussion in https://reviews.llvm.org/D130221 and https://reviews.llvm.org/D139223 Differential Revision: https://reviews.llvm.org/D139347
2022-12-05Remove unused #include "llvm/ADT/Optional.h"Fangrui Song1-1/+0
2022-12-02[llvm] Use std::nullopt instead of None (NFC)Kazu Hirata4-9/+9
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02Add void cast for preprocessor-conditionall-unused loop variableDavid Blaikie1-0/+4
Fixing -Wunused -Werror build on Android.
2022-11-26[Orc] Use std::optional in ObjectFileInterface.cpp (NFC)Kazu Hirata1-1/+2
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26[Orc] Use std::optional in MachOPlatform.cpp (NFC)Kazu Hirata1-2/+3
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26[Orc] Use std::optional in ELFNixPlatform.cpp (NFC)Kazu Hirata1-1/+2
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26[Orc] Use std::optional in Core.cpp (NFC)Kazu Hirata1-2/+3
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-11[ORC] Capture JD by value in MachOPlatform::pushInitializersLoop.Lang Hames1-1/+1
The lambda may run after pushInitializersLoop returns.
2022-10-29[ORC] Mark late-claimed weak symbols as live in ObjectLinkingLayer.Lang Hames1-2/+8
ObjectLinkingLayer attempts to claim responsibility for weak definitions that are present in LinkGraphs, but not present in the corresponding MaterializationResponsibility object. Where such a claim is successful, the symbol should be marked as live to prevent it from being dead stripped. (For the curious: Such "late-breaking" definitions are introduced somewhere in the materialization pipeline after the initial responsibility set is calculated. The usual source is the complier or assembler. Examples of common late-breaking definitions include personality pointers, e.g. "DW.ref.__gxx_personality_v0", and named constant pool entries, e.g. __realXX..XX.) The failure to mark these symbols live caused few problems in practice because late-breaking definitions are usually anchored by existing live definitions within the graph (e.g. DW.ref.__gxx_personality_v0 is transitively referenced by functions via eh-frame records), and so they usually survived dead-stripping anyway. This accidental persistence isn't a principled solution though, and it fails altogether if a late-breaking definition is not otherwise referenced by the graph, with the result that the now-claimed symbol is stripped triggering a "Failed to materialize symbols" error in ORC. Marking such symbols live is the correct solution. No testcase, as it's difficult to construct a situation where a late-breaking definition is inserted without being referenced outside the context of new backend bringup or plugin-specific shenanigans. See discussion in https://reviews.llvm.org/D133452 and https://reviews.llvm.org/D136877.
2022-10-25[ORC] Skip non-SHF_ALLOC sections in DebugObjectManagerPlugin.Lang Hames1-0/+3
We don't need to provide a load-address for non-alloc sections. Skipping them allows us to avoid some complications, like handling duplicate .group sections.
2022-10-25[ORC] Allow EPCDebugObjectRegistrar clients to specify registration fn dylib.Lang Hames1-5/+11
Similar to the EPCEHFrameRegistrar change in c977251ef6f, this allows clients who have sourced a dylib handle via a side-channel to search that dylib to find the registration functions. This patch defaults to the existing behavior in the case where the client does not specify a handle to use.
2022-10-25[ORC] Update SelfExecutorProcessControl to allow user-supplied handles.Lang Hames1-13/+5
SelfExecutorProcessControl no longer requires that handles passed to lookupSymbols be ones that were previously returned from loadDylib. This brings SelfExecutorPRocessControl into alignment with SimpleRemoteEPC, which was updated in 6613f4aff85.
2022-10-24[ORC] Allow EPCEHFrameRegistrar clients to specify registration function dylib.Lang Hames1-5/+11
Previously, EPCEHFrameRegistrar always used the ExecutorProcessControl::loadDylib(nullptr) method to obtain a handle for the process, but this doesn't work if the registration functions aren't visible in a standard search of the process (e.g. if the JIT is in a plugin that is loaded with RTLD_LOCAL). This patch retains the old behavior by default, but allows clients to supply their own handle for the library containing the registration functions if they need to (e.g. to work around limitations like RDLD_LOCAL above, which aren't expressible within the existing loadDylib / DynamicLibrary APIs).
2022-10-24[ORC] Use raw OS handle values, ExecutorAddr for EPC dylib handles.Lang Hames6-20/+14
Updates tpctypes::DylibHandle to be an ExecutorAddr (rather than a uint64_t), and SimpleExecutorDylibManager to hold and return raw OS handle values (as ExecutorAddrs) rather than index values into a map of DynamicLibrary instances. This will allow clients to use EPCGenericDylibManager in contexts where the existing DynamicLibrary interface is too limited to be used. (e.g. to look up JIT symbols in a dylib that was loaded with RTLD_LOCAL).
2022-10-23[ORC] Force linking of eh-frame registration functions from LLJIT.cpp.Lang Hames1-0/+8
Since aedeb8d5570, which switched to EPC-based eh-frame registrationin LLJIT, the eh-frame registration functions need to be forcibly linked into the target process. Failure to link the eh-frame registration functions triggered a test failure in https://green.lab.llvm.org/green/job/clang-stage1-RA/31497, which was fixed by forcibly linking the registration functions into that test case in saf2b2214b4 (rdar://101083784), however it has also caused some tests (e.g. the C API unit tests) that depend on successful construction of an LLJIT instance to be skipped. Moving the forcible registration into LLJIT.cpp fixes the general issue.
2022-10-22[ORC] Add more information to duplicate section error message.Lang Hames1-1/+3
Now includes the name of the graph and duplicate section.
2022-10-09[ORC] Relax assertions in SimpleRemoteEPCTransport.Lang Hames1-2/+2
Null source/destination pointers are ok for zero-sized messages.
2022-10-09[LLJIT] Default to EPCEHFrameRegistrar rather than InProcessEHFrameRegistrar.Lang Hames1-2/+7
Now that ExecutionSession objects alway have ExecutorProcessControl (EPC) objects attached we can use EPCEHFrameRegistrar by default, rather than InProcessEHFrameRegistrar. This allows LLJIT to work out-of-the-box with remote EPCs on platforms that use JITLink, without requiring a custom ObjectLinkingLayerCreator to override the eh-frame registrar.
2022-10-05[Orc] Fix the SharedMemoryMapper dtorAlexandre Ganea1-0/+1
As briefly discussed on https://reviews.llvm.org/rG1134d3a03facccd75efc5385ba46918bef94fcb6, fix the unintended copy while iterating on Reservations and add a mutex guard, to be symmetric with other usages of Reservations. Differential revision: https://reviews.llvm.org/D134212
2022-10-03[ORC] Don't unnecessarily copy collection element.Lang Hames1-1/+1
2022-10-03[ORC] Fix typo in 543790add86.Lang Hames1-1/+1
2022-10-03[ORC] More attempts to fix Windows bots after d3d9f7caf966.Lang Hames1-4/+4
Move getWindowsProtectionFlags inside namespace to make MemProt type accessible.
2022-10-03[ORC] Attempt to fix Windows bots after d3d9f7caf966.Lang Hames1-15/+10
That patch failed to include an update to the Windows side of ExecutorSharedMemoryMapperService.
2022-10-03[ORC][JITLink] Move MemoryFlags.h (MemProt, AllocGroup,...) from JITLink to ORC.Lang Hames10-44/+40
Moving these types to OrcShared eliminates the need for the separate WireProtectionFlags type.
2022-09-27[ORC][JITLink] Retain Weak flags in JITDylib interfaces, propagate to LinkGraph.Lang Hames3-15/+20
Previously we stripped Weak flags from JITDylib symbol table entries once they were resolved (there was no particularly good reason for this). Now we want to retain them and query them when setting the Linkage on external symbols in LinkGraphs during symbol resolution (this was the motivation for 75404e9ef88). Making weak linkage of external definitions discoverable in the LinkGraph will in turn allow future plugins to implement correct handling for them (by recording locations that depend on exported weak definitions and pointing all of these at one chosen definition at runtime).
2022-09-25[llvm] Use std::underlying_type_t (NFC)Kazu Hirata1-2/+2
2022-09-19[ORC] Fix macho section name typoKeith Smiley1-1/+1
I don't think __obj_selrefs is a thing, but __objc_selrefs definitely is. Differential Revision: https://reviews.llvm.org/D130221
2022-09-16[ORC][ORC-RT][MachO] Reset __data and __common sections on library close.Lang Hames2-2/+31
If we want to be able to close and then re-open a library then we need to reset the data section states when the library is closed. This commit updates MachOPlatform and the ORC runtime to track __data and __common sections, and reset the state in MachOPlatformRuntimeState::dlcloseDeinitialize. This is only a first step to full support -- there are other data sections that we're not capturing, and we'll probably want a more efficient representation for the sections (rather than passing their string name over IPC), but this is a reasonable first step. This commit also contains a fix to MapperJITLinkMemoryManager that prevents it from calling OnDeallocated twice in the case of an error.
2022-09-12[llvm] Use x.empty() instead of llvm::empty(x) (NFC)Kazu Hirata3-4/+4
I'm planning to deprecate and eventually remove llvm::empty. I thought about replacing llvm::empty(x) with std::empty(x), but it turns out that all uses can be converted to x.empty(). That is, no use requires the ability of std::empty to accept C arrays and std::initializer_list. Differential Revision: https://reviews.llvm.org/D133677
2022-09-10[ORC] Remove moves.sunho1-2/+2
2022-09-10[ORC][ORC_RT][COFF] Remove public bootstrap method.sunho2-13/+69
Removes public bootstrap method that is not really necessary and not consistent with other platform API. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D132780
2022-09-10[ORC][ORC_RT][COFF] Support dynamic VC runtime.sunho1-41/+98
Supports dynamic VC runtime. It implements atexits handling which is required to load msvcrt.lib successfully. (the object file containing atexit symbol somehow resolves to static vc runtim symbols) It also default to dynamic vc runtime which tends to be more robust. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D132525
2022-09-10[JITLink][COFF] Use DLLImportDefinitionGenerator for creating PLT stubs.sunho1-1/+5
Uses DLLImportDefinitionGenerator for creating PLT stubs. It removes previous approach for dllimport stub creation which can't deal with jump thunks. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D132524
2022-09-03Use llvm::lower_bound (NFC)Kazu Hirata1-2/+2
2022-08-30[ORC] Update mapper deinitialize functions to deinitialize in reverse order.Lang Hames2-2/+2
This updates the ExecutorSharedMemoryMapperService::deinitialize and InProcessMemoryMapper::deinitialize methods to deinitialize in reverse order, bringing them into alignment with the behavior of InProcessMemoryManager::deallocate and SimpleExecutorMemoryManager::deallocate. Reverse deinitialization is required because later allocations can depend on earlier ones. This fixes failures in the ORC runtime test suite.
2022-08-28[llvm] Qualify auto in range-based for loops (NFC)Kazu Hirata1-1/+1
2022-08-27[Orc] Take offset inside slab into account in SharedMemoryMapperAnubhab Ghosh1-8/+8
SharedMemoryMapper assumed each reservation will have its corresponding allocations starting from the beginning. However with the introduction of the slab allocator, there can be a possible offset from the start from where the initialization is being performed. This commit also simplifies the logic for finding the parent reservation and makes the assert messages consistent.
2022-08-21[Orc] Improve deintialize and shutdown logicAnubhab Ghosh1-14/+18
When deinitializing, the allocation needs to be removed from the allocation list of its associated reservation so that remaining allocations can be deinitialized when releasing the reservation. Differential Revision: https://reviews.llvm.org/D132313
2022-08-21[Orc] Provide correct Reservation address for slab allocationsAnubhab Ghosh1-4/+7
When slab allocator is used, the MappingBase is not necessarily the same as the original reservation base as the allocation could be a part of the whole reservation. In this case the original reservation address needs to be passed to ExecutorSharedMemoryMapperService to associate the new allocation with the original reservation. Differential Revision: https://reviews.llvm.org/D132313
2022-08-21[Orc] Only unmap shared memory in controller process destructorAnubhab Ghosh1-16/+12
By the time SharedMemoryMapper destructor is called, the RPC connection is no longer available causing the release() call to always fail. Instead at this point only shared memory regions can be unmapped safely. Deinitializers are called and mapped memory is released at the executor side by ExecutorSharedMemoryMapperService::shutdown() instead. Memory can also be released earlier by calling release() earlier before RPC connection is closed. Differential Revision: https://reviews.llvm.org/D132313