aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Orc
AgeCommit message (Collapse)AuthorFilesLines
2022-08-21[Orc] Actually save the callbackAnubhab Ghosh1-3/+2
The callback function was captured by reference but it lived on the stack and was in danger of being overwritten and could cause a crash. Differential Revision: https://reviews.llvm.org/D132313
2022-08-17[ORC][MachO] Fix MachOPlatform after 9189a26664b.Lang Hames1-16/+13
Commit 9189a26664b caused llvm-jitlink to create bare JITDylibs to wrap real dylibs loaded via -preload. This exposed a bug in MachOPlatform where we assumed that all JITDylibs had been registered with the platform through MachOPlatform::setupJITDylib (bare JITDylibs are _not_ run through this function), and errored out where this was not the case. This bug in MachOPlatform was causing test failures in compilert-rt: Failed Tests (2): ORC-x86_64-darwin :: TestCases/Darwin/x86-64/trivial-objc-methods.S ORC-x86_64-darwin :: TestCases/Darwin/x86-64/trivial-swift-types-section.S This commit fixes the issue by skipping JITDylibs that haven't been registered with the platform via MachOPlatform::setupJITDylib.
2022-08-15[ExecutionEngine] Fix warningsKazu Hirata1-2/+2
This patch fixes: llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp:512:12: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move] and: llvm/lib/ExecutionEngine/Orc/ExecutionUtils.cpp:515:12: error: moving a temporary object prevents copy elision [-Werror,-Wpessimizing-move]
2022-08-16[ORC][COFF] Introduce DLLImportDefinitionGenerator.Sunho Kim1-1/+117
This class will be used to properly solve the `__imp_` symbol and jump-thunk generation issues. It is assumed to be the last definition generator to be called, and as it's the last generator the only symbols remaining in the lookup set are the symbols that are supposed to be queried outside this jitdylib. Instead of just letting them through, we issue another lookup invocation and fetch the allocated addresses, and then create jitlink graph containing `__imp_` GOT symbols and jump-thunks targetting the fetched addresses. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D131833
2022-08-14[Orc] Use IntervalMap to store free memory regions in MapperJITLinkMemoryManagerAnubhab Ghosh1-18/+18
MapperJITLinkMemoryManager uses a free list to keep track of available memory regions. Using an IntervalMap instead of vector allow automatic coalescing of memory regions as they are freed. Differential Revision: https://reviews.llvm.org/D131831
2022-08-13[llvm] Qualify auto in range-based for loops (NFC)Kazu Hirata2-5/+5
Identified with readability-qualified-auto.
2022-08-13Reapply [Orc] Properly deallocate mapped memory in MapperJITLinkMemoryManagerAnubhab Ghosh2-8/+41
When memory is deallocated from MapperJITLinkMemoryManager deinitialize actions are run through mapper and in case of InProcessMapper, memory protections of the region are reset to read/write as they were previously changed and can be reused in future. Differential Revision: https://reviews.llvm.org/D131768
2022-08-13[ORC] Silence copy elision warning.Sunho Kim1-1/+1
2022-08-13[ORC] Specify the typename.Sunho Kim1-1/+1
2022-08-13Revert "[Orc] Properly deallocate mapped memory in MapperJITLinkMemoryManager"Anubhab Ghosh2-39/+8
This reverts commit 143555b2ed30746fbcc8ff84e9cef4267688f110.
2022-08-13[ORC_RT][COFF] Initial platform support for COFF/x86_64.Sunho Kim3-1/+851
Initial platform support for COFF/x86_64. Completed features: * Statically linked orc runtime. * Full linking/initialization of static/dynamic vc runtimes and microsoft stl libraries. * SEH exception handling. * Full static initializers support * dlfns * JIT side symbol lookup/dispatch Things to note: * It uses vc runtime libraries found in vc toolchain installations. * Bootstrapping state is separated because when statically linking orc runtime it needs microsoft stl functions to initialize the orc runtime, but static initializers need to be ran in order to fully initialize stl libraries. * Process symbols can't be used blidnly on msvc platform; otherwise duplicate definition error gets generated. If process symbols are used, it's destined to get out-of-reach error at some point. * Atexit currently not handled -- will be handled in the follow-up patches. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D130479
2022-08-13[Orc] Properly deallocate mapped memory in MapperJITLinkMemoryManagerAnubhab Ghosh2-8/+39
When memory is deallocated from MapperJITLinkMemoryManager deinitialize actions are run through mapper and in case of InProcessMapper, memory protections of the region are reset to read/write as they were previously changed and can be reused in future. Differential Revision: https://reviews.llvm.org/D131768
2022-08-11[Orc] Reorder operations in ExecutorSharedMemoryMapperService shutdownAnubhab Ghosh1-8/+11
Differential Revision: https://reviews.llvm.org/D131510
2022-08-11[ORC] Add missing std::move.Sunho Kim1-2/+2
2022-08-11[ORC][COFF] Introduce COFFVCRuntimeBootstrapper.Sunho Kim7-1/+251
Introduces COFFVCRuntimeBootstrapper that loads/initialize vc runtime libraries. In COFF, we *must* jit-link vc runtime libraries as COFF relocation types have no proper way to deal with out-of-reach data symbols ragardless of linking mode. (even dynamic version msvcrt.lib have tons of static data symbols that must be jit-linked) This class tries to load vc runtime library files from msvc installations with an option to override the path. There are some complications when dealing with static version of vc runtimes. First, they need static initializers to be ran that requires COFFPlatform support but orc runtime will not be usable before vc runtimes are fully initialized. (as orc runtime will use msvc stl libraries) COFFPlatform that will be introduced in a following up patch will collect static initializers and run them manually in host before boostrapping itself. So, the user will have to do the following. 1. Create COFFPlatform that addes static initializer collecting passes. 2. LoadVCRuntime 3. InitializeVCRuntime 4. COFFPlatform.bootstrap() Second, the internal crt initialization function had to be reimplemented in orc side. There are other ways of doing this, but this is the simplest implementation that makes platform fully responsible for static initializer. The complication comes from the fact that crt initialization functions (such as acrt_initialize or dllmain_crt_process_attach) actually run all static initializers by traversing from `__xi_a` symbol to `__xi_z`. This requires symbols to be contiguously allocated in sections alphabetically sorted in memory, which is not possible right now and not practical in jit setting. We might ignore emission of `__xi_a` and `__xi_z` symbol and allocate them ourselves, but we have to take extra care after orc runtime boostrap has been done -- as that point orc runtime should be the one running the static initializers. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D130456
2022-08-11[JITLink][COFF][x86_64] Implement SECTION/SECREL relocation.Sunho Kim1-1/+2
Implements SECTION/SECREL relocation. These are used by debug info (pdb) data. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D130275
2022-08-08[Orc][JITLink] Slab based memory allocator to reduce RPC callsAnubhab Ghosh1-43/+72
Calling reserve() used to require an RPC call. This commit allows large ranges of executor address space to be reserved. Subsequent calls to reserve() will return subranges of already reserved address space while there is still space available. Differential Revision: https://reviews.llvm.org/D130392
2022-08-07[llvm] Fix comment typos (NFC)Kazu Hirata1-1/+1
2022-08-05[ORC] Fix a memory leak in LLVMOrcIRTransformLayerSetTransform.Lang Hames1-1/+4
This function heap-allocates a ThreadSafeModule (the current C bindings assume that TSMs are always heap-allocated), but was failing to free it. Should fix http://llvm.org/PR56953.
2022-08-04[ORC] Actually propagate memory unmapping errors on WindowsMartin Storsjö1-2/+2
This fixes warnings like these: ../lib/ExecutionEngine/Orc/MemoryMapper.cpp:364:9: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result] joinErrors(std::move(Err), ^~~~~~~~~~ ~~~~~~~~~~~~~~~ Differential Revision: https://reviews.llvm.org/D131056
2022-08-04[ORC] Fix a warning about an unused variable on Windows. NFC.Martin Storsjö1-0/+1
Differential Revision: https://reviews.llvm.org/D131055
2022-08-01[Orc] Disable use of shared memory on AndroidAnubhab Ghosh2-7/+17
shm_open and shm_unlink are not available on Android. This commit disables SharedMemoryMapper on Android until a better solution is available. https://android.googlesource.com/platform/bionic/+/refs/heads/master/docs/status.md https://github.com/llvm/llvm-project/issues/56812 Differential Revision: https://reviews.llvm.org/D130814
2022-07-29[ORC][COFF] Handle COFF import files of static archive.Sunho Kim1-9/+36
Handles COFF import files of static archive. Changes static library genrator to build up object file map keyed by symbol name that excludes the symbols from dllimported symbols so that static generator will not be responsible for them. It exposes the list of dynamic libraries that need to be imported. Client should properly load the libraries in this list beforehand. Object file map is also an improvment from the past in terms of performance. Archive.findSym does a slow O(n) linear serach of symbol list to find the symbol. (we call findSym O(n) times, thus full time complexity is O(n^2); we were the only user of findSym function in fact) There is a room for improvements in how to load the libraries in the list. We currently just hand the responsibility over to the clinet. A better way would be let ORC read this list and hand them over to JITLink side that would also help validation (e.g. not trying to generate stub for non dllimported targets) Nevertheless, we will have to exclude the symbols from COFF import object file list and need a way to access this list, which this patch offers. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D129952
2022-07-28[ORC] Fix weak hidden symbols failure on PPC with runtimedyldSunho Kim2-0/+40
Fix "JIT session error: Symbols not found: [ DW.ref.__gxx_personality_v0 ] error" which happens when trying to use exceptions on ppc linux. To do this, it expands AutoClaimSymbols option in RTDyldObjectLinkingLayer to also claim weak symbols before they are tried to be resovled. In ppc linux, DW.ref symbols is emitted as weak hidden symbols in the later stage of MC pipeline. This means when using IRLayer (i.e. LLJIT), IRLayer will not claim responsibility for such symbols and RuntimeDyld will skip defining this symbol even though it couldn't resolve corresponding external symbol. Reviewed By: sgraenitz Differential Revision: https://reviews.llvm.org/D129175
2022-07-25[ORC][COFF] Properly set weak flag to COMDAT symbols.Sunho Kim1-7/+31
Properly set weak flag to COMDAT symbols so that no duplicate definition error will be generated. There is an inaccuracy in setting plain weak for largest selection type, which will be dealt with soon when largest type is properly implemented. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D129764
2022-07-23Revert "[Orc] Use default member initialization (NFC)"Kazu Hirata1-4/+4
This reverts commit d534967b6667c468b12e9ed5e3c482f590dde633. The patch causes build failures, such as: https://lab.llvm.org/buildbot/#/builders/121/builds/21760
2022-07-23[Orc] Use default member initialization (NFC)Kazu Hirata1-4/+4
Identified with modernize-use-default-member-init
2022-07-20[ORC] Add a new MemoryMapper-based JITLinkMemoryManager implementation.Anubhab Ghosh3-0/+160
MapperJITLinkMemoryManager supports executor memory management using any implementation of MemoryMapper to do the transfer such as InProcessMapper or SharedMemoryMapper. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D129495
2022-07-20[ORC] Don't try to copy from an empty segment in SimpleExecutorMemoryManager.Lang Hames1-1/+2
Since 67220c2ad72e empty SPSSequence<char>s deserialize to default-constructed ArrayRef<char>s, which have a null data field. We need to check for this to avoid memcpy'ing from a nullptr. This should fix the bot failure in https://lab.llvm.org/buildbot/#/builders/85/builds/9323
2022-07-19Re-re-apply 5acd47169884, Add a shared-memory based orc::MemoryMapper...Anubhab Ghosh5-0/+597
...with more fixes. The original patch was reverted in 3e9cc543f22 due to bot failures caused by a missing dependence on librt. That issue was fixed in 32d8d23cd0, but that commit also broke sanitizer bots due to a bug in SimplePackedSerialization: empty ArrayRef<char>s triggered a zero-byte memcpy from a null source. The ArrayRef<char> serialization issue was fixed in 67220c2ad7, and this patch has also been updated with a new custom SharedMemorySegFinalizeRequest message that should avoid serializing empty ArrayRefs in the first place. https://reviews.llvm.org/D128544
2022-07-15Revert "Re-apply 5acd47169884, Add a shared-memory based orc::MemoryMapper, ↵Mitch Phillips5-598/+0
with fixes." This reverts commit 32d8d23cd0b2d4d010eb112dfe5216f11b2681f9. Reason: Broke the UBSan buildbots. See more details on Phabricator: https://reviews.llvm.org/D128544
2022-07-15Re-apply 5acd47169884, Add a shared-memory based orc::MemoryMapper, with fixes.Anubhab Ghosh5-0/+598
The original commit was reverted in 3e9cc543f223 due to buildbot failures, which should be fixed by the addition of dependencies on librt. Differential Revision: https://reviews.llvm.org/D128544
2022-07-15[Orc] Honor hasJIT in JITTargetMachineBuilder::createTargetMachineRainer Orth1-0/+4
Even with D129349 <https://reviews.llvm.org/D129349>, various SPARC JIT tests still `FAIL`. They are guarded by `host-supports-jit`. This is set from `clang-repl --host-supports-jit` which still returns `true`. It turns out the `JITTargetMachineBuilder` doesn't consider `hasJIT` at all. This patch corrects this, turning the affected tests `UNSUPPORTED`. Tested on `sparcv9-sun-solaris2.11`. Differential Revision: https://reviews.llvm.org/D129350
2022-07-14Revert "[ORC] Add a shared-memory based orc::MemoryMapper."Cullen Rhodes4-588/+0
This reverts commit 5acd471698849d9e322a29e6ca08791e8d447b7b. Breaks shared library build with: ld.lld-12: error: undefined symbol: shm_open >>> referenced by ExecutorSharedMemoryMapperService.cpp:68 (/home/culrho01/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp:68) >>> lib/ExecutionEngine/Orc/TargetProcess/CMakeFiles/LLVMOrcTargetProcess.dir/ExecutorSharedMemoryMapperService.cpp.o:(llvm::orc::rt_bootstrap::ExecutorSharedMemoryMapperService::reserve[abi:cxx11](unsigned long)) >>> did you mean: sem_open >>> defined in: /usr/bin/../lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/libpthread.so
2022-07-14Revert "[ORC] Fix compilation on mingw"Cullen Rhodes2-3/+3
This reverts commit 46b1a7c5f9e6841016078d32728bb0d205336df5. Parent commit breaks shared library build, reverting both commits.
2022-07-14[ORC] Fix compilation on mingwMartin Storsjö2-3/+3
Explicitly call the -W suffixed API functions when passing wchar based strings.
2022-07-13[ORC] Add a shared-memory based orc::MemoryMapper.Anubhab Ghosh4-0/+588
This is an implementation of orc::MemoryMapper that maps shared memory pages in both executor and controller process and writes directly to them avoiding transferring content over EPC. All allocations are properly deinitialized automatically on the executor side at shutdown by the ExecutorSharedMemoryMapperService. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D128544
2022-07-13[JITLink][COFF] Initial COFF support.Sunho Kim1-0/+52
Adds initial COFF support in JITLink. This is able to run a hello world c program in x86 windows successfully. Implemented - COFF object loader - Static local symbols - Absolute symbols - External symbols - Weak external symbols - Common symbols - COFF jitlink-check support - All COMDAT selection type execpt largest - Implicit symobl size calculation - Rel32 relocation with PLT stub. - IMAGE_REL_AMD64_ADDR32NB relocation Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D128968
2022-07-10ManagedStatic: Remove from JITLoaderGDBNicolai Hähnle1-5/+3
This change originally landed as part of e6f1f062457c928c18a88c612f39d9e168f65a85 (D129120), which caused a Fuchsia buildbot regression in ExecutionEngine tests. I am resubmitting the backed out parts in smaller pieces after a careful review.
2022-07-10ManagedStatic: remove many straightforward uses in llvmNicolai Hähnle1-4/+6
(Reapply after revert in e9ce1a588030d8d4004f5d7e443afe46245e9a92 due to Fuchsia test failures. Removed changes in lib/ExecutionEngine/ other than error categories, to be checked in more detail and reapplied separately.) Bulk remove many of the more trivial uses of ManagedStatic in the llvm directory, either by defining a new getter function or, in many cases, moving the static variable directly into the only function that uses it. Differential Revision: https://reviews.llvm.org/D129120
2022-07-10Revert "ManagedStatic: remove many straightforward uses in llvm"Nicolai Hähnle2-9/+9
This reverts commit e6f1f062457c928c18a88c612f39d9e168f65a85. Reverting due to a failure on the fuchsia-x86_64-linux buildbot.
2022-07-10ManagedStatic: remove many straightforward uses in llvmNicolai Hähnle2-9/+9
Bulk remove many of the more trivial uses of ManagedStatic in the llvm directory, either by defining a new getter function or, in many cases, moving the static variable directly into the only function that uses it. Differential Revision: https://reviews.llvm.org/D129120
2022-07-07[ORC][MIPS} Correct template parameter for stubAndPointerRangesOk function ↵Xiaodong Liu1-2/+2
on Mips It might be an oversight that pass OrcAArch64 as template parameter to stubAndPointerRangesOk on MIps. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D129076
2022-07-06[ORC][ORC_RT][AArch64] Implement TLS descriptor in ELFNixPlatform.Sunho Kim1-2/+4
Implements TLS descriptor relocations in JITLink ELF/AARCH64 backend and support the relevant runtime functions in ELFNixPlatform. Unlike traditional TLS model, TLS descriptor model requires linker to return the "offset" from thread pointer via relocaiton not the actual pointer to thread local variable. There is no public libc api for adding new allocations to TLS block dynamically which thread pointer points to. So, we support this by taking delta from thread base pointer to the actual thread local variable in our allocated section. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D128601
2022-07-04[Orc][LLJIT] Use JITLink on RISC-VJonas Hahnfeld1-2/+3
RuntimeDyld does not support RISC-V, so it makes sense to enable JITLink by default. This also makes relocations work without support for a large code model. Differential Revision: https://reviews.llvm.org/D129092
2022-06-26[ORC][LLJIT] Define atexit symbol in GenericLLVMIRPlatformSupport.Sunho Kim1-7/+27
Define atexit symbol in GenericLLVMIRPlatformSupport so that it doesn't need to be defined by user. On windows, llvm codegen emits atexit runtime calls to support global deinitializers as there is no lower function like cxa_atexit as in Itanium C++ ABI. ORC JIT user had to define custom atexit symbol manually. This was a hassle as it has to deal with dso_handle and cxa_atexit internals of LLJIT. If client didn't provide atexit definition, the default behaviour is just linking with host atexit function which is destined to fail as it calls dtors when the host program exits. This is after jit instances and buffers are freed, so users would see weird access violation exception from the uknown location. (in console application, the debugger thinks exception happened in scrt_common_main_seh) This is a hack that has some caveats. (e.g. memory address is not identical) But, it's better than the situation described in the above. Ultimately, we will move on to ORC runtime that is able to solve the memory address issue properly. Reviewed By: sgraenitz Differential Revision: https://reviews.llvm.org/D128037
2022-06-21Re-apply "[JITLink][Orc] Add MemoryMapper interface with InProcess ↵Anubhab Ghosh2-0/+153
implementation" [JITLink][Orc] Add MemoryMapper interface with InProcess implementation MemoryMapper class takes care of cross-process and in-process address space reservation, mapping, transferring content and applying protections. Implementations of this class can support different ways to do this such as using shared memory, transferring memory contents over EPC or just mapping memory in the same process (InProcessMemoryMapper). The original patch landed with commit 6ede65205073d3cf6b1ed4d101e66eae3e0fc8e6 It was reverted temporarily in commit 6a4056ab2ada0046ff97a55a5fb34c2c59504fd1 Reviewed By: sgraenitz, lhames Differential Revision: https://reviews.llvm.org/D127491
2022-06-21Revert "[JITLink][Orc] Add MemoryMapper interface with InProcess implementation"Nico Weber2-153/+0
This reverts commit 6ede65205073d3cf6b1ed4d101e66eae3e0fc8e6. Doesn't build on Windows, see https://reviews.llvm.org/D127491#3598773
2022-06-21[JITLink][Orc] Add MemoryMapper interface with InProcess implementationAnubhab Ghosh2-0/+153
MemoryMapper class takes care of cross-process and in-process address space reservation, mapping, transferring content and applying protections. Implementations of this class can support different ways to do this such as using shared memory, transferring memory contents over EPC or just mapping memory in the same process (InProcessMemoryMapper). Reviewed By: sgraenitz, lhames Differential Revision: https://reviews.llvm.org/D127491
2022-06-20[llvm] Don't use Optional::getValue (NFC)Kazu Hirata1-1/+1