aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Orc
AgeCommit message (Collapse)AuthorFilesLines
2024-06-26[ORC] Fix block dependence calculation in ObjectLinkingLayer.Lang Hames1-2/+4
This fixes a bug in ObjectLinkingLayer::computeBlockNonLocalDeps: The worklist needs to be built *after* all immediate dependencies / dependants are recorded, rather than trying to populate it as part of the same loop. (Trying to do the latter causes us to miss some blocks that should have been included in the worklist). This fixes a bug discovered by @Sahil123 on discord during work on out-of-process execution support in the clang-repl. No testcase yet. This *might* be testable with a unit test and a custom JITLinkContext but I believe some aspects of the algorithm depend on memory layout. I'll need to investigate that. Alternatively we could add llvm-jitlink testcases that exercise concurrent linking (and should probably do that anyway). Either option will require some investment and I don't want to hold this fix up in the mean time.
2024-06-26[ORC] Remove redundant locking of session mutex, update method name.Lang Hames1-5/+4
JITDylib::removeTracker already runs with the session mutex locked (and must do so), so remove the redundant locking and add an 'IL_' ("inside lock") prefix to the method name.
2024-06-25Revert "[llvm] Use llvm::sort (NFC) (#96434)"Kazu Hirata2-4/+3
This reverts commit 05d167fc201b4f2e96108be0d682f6800a70c23d. Reverting the patch fixes the following under EXPENSIVE_CHECKS: LLVM :: CodeGen/AMDGPU/sched-group-barrier-pipeline-solver.mir LLVM :: CodeGen/AMDGPU/sched-group-barrier-pre-RA.mir LLVM :: CodeGen/PowerPC/aix-xcoff-used-with-stringpool.ll LLVM :: CodeGen/PowerPC/merge-string-used-by-metadata.mir LLVM :: CodeGen/PowerPC/mergeable-string-pool-large.ll LLVM :: CodeGen/PowerPC/mergeable-string-pool-pass-only.mir LLVM :: CodeGen/PowerPC/mergeable-string-pool.ll
2024-06-23[llvm] Use llvm::sort (NFC) (#96434)Kazu Hirata2-3/+4
2024-06-18Reland "[ORC] Preserve order of constructors with same priority (#95532)"David Spickett1-1/+1
This reverts commit edd6f0c544785d6f6276a24b94222e0064413cd1. The newly added test uncovered a pre-existing issue on Arm 32 bit, so as we did https://github.com/llvm/llvm-project/issues/94994, disable it while we find the problem.
2024-06-18Revert "[ORC] Preserve order of constructors with same priority (#95532)"Jonas Hahnfeld1-1/+1
The test fails on 32-bit ARMv8: https://lab.llvm.org/buildbot/#/builders/154/builds/170 This reverts commit e5d0627c5a78f8cf4ff79816547b528ec52d6590.
2024-06-18[ORC] Preserve order of constructors with same priority (#95532)Jonas Hahnfeld1-1/+1
Constructors with the same priority should keep their relative order that was specified. This is important for `clang-repl` with many `const` variables after commit 05137ecfca ("[clang-repl] Emit const variables only once").
2024-06-11[ORC][MachO] Register objc protolist, protorefs, nlclslist metadata sections ↵Ben Langmuir2-14/+21
(#95144) Add missing __DATA sections that the objc runtime expects to register. This fixes running objc code that makes use of `@protocol` references and `__attribute__((objc_nonlazy_class))` classes. rdar://129368761
2024-05-24[flang] [lldb] [llvm] Fix 'destory' comment typos [NFC] (#93260)Stephan T. Lavavej1-2/+2
2024-05-16[ORC] Support visionOS in LC_BUILD_VERSIONs for JITDylibs.Lang Hames1-0/+4
rdar://127846581
2024-05-14[ORC] Loosen __objc_imageinfo flag merging to match ld (#91767)Ben Langmuir1-2/+12
Allow mixing objects with/without signed class ro data and category class properties as long as it happens before we register the metadata. These combinations are a warning in ld, not a hard error. The only case that is ABI-breaking is if we already registered with the feature enabled but later try to load an object that doesn't support it. rdar://127336061
2024-05-10[ORC] Fix another error fall-through in EPCGenericDylibManager::lookupAsync.Lang Hames1-0/+1
The early return added in this commit should have been added in cbf1535cc81. No test-case: This would require a deliberately injected failure in a remote-JIT test and we don't have the infrastructure for that at the moment. rdar://126772381
2024-05-09[ORC] Fix fall-through in error case in EPCGenericDylibManager::lookupAsync.Lang Hames1-0/+1
In the event of a serialization error (e.g. due to a network dropout) we should only run the Complete handler once, passing the serialization error value. No test-case: This would require a deliberately injected failure in a remote-JIT test and we don't have the infrastructure for that at the moment. rdar://126772381
2024-04-30[ORC] Switch ObjectLinkingLayer::Plugins to shared ownership, copy pipeline.Lang Hames1-35/+38
Previously ObjectLinkingLayer held unique ownership of Plugins, and links always used the Layer's plugin list at each step. This can cause problems if plugins are added while links are in progress however, as the newly added plugin may receive only some of the callbacks for links that are already running. In this patch each link gets its own copy of the pipeline that remains consistent throughout the link's lifetime, and it is guaranteed that Plugin objects (now with shared ownership) will remain valid until the link completes. Coding my way home: 9.80469S, 139.03167W
2024-04-26Revert "[ORC] Implement basic reoptimization. (#67050)"Nikita Popov7-801/+279
This reverts commit 0d288e5b0ccf217e41944ad4fd8772d8ae45daa1. Breaks the build.
2024-04-25[ORC] Implement basic reoptimization. (#67050)Sunho Kim7-279/+801
2024-04-25[z/OS] Implement shared memory handling for JIT (#89933)Fanbo Meng2-0/+63
Fix 'use of undeclared identifier' build errors for shm_ functions on z/OS by implementing the functionality using shmget(), shmat(), and shmdt(). Use the BLAKE3 hash to map the name of the shared memory to a key. --------- Co-authored-by: Kai Nacke <kai.peter.nacke@ibm.com>
2024-04-24[ORC] Fix bot failure due to 7da63426ac5 (ORC task dispatch unification).Lang Hames1-1/+3
Fixes the failure at https://lab.llvm.org/buildbot/#/builders/131/builds/62928, and add comments about unused variable and update debugging output. Coding my way home: 6.44615S, 128.16704W
2024-04-24[ORC] Fix build failure (NFC)Jie Fu1-4/+2
2024-04-24[ORC] Fix -Wunused-variable in LLJIT.cpp (NFC)Jie Fu1-1/+4
llvm-project/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp:684:8: error: unused variable 'ConcurrentCompilationSettingDefaulted' [-Werror,-Wunused-variable] bool ConcurrentCompilationSettingDefaulted = !SupportConcurrentCompilation; ^ 1 error generated.
2024-04-23Re-apply "[ORC] Unify task dispatch across ExecutionSession..." with more fixes.Lang Hames3-35/+96
This re-applies 6094b3b7db7, which was reverted in e7efd37c229 (and before that in 1effa19de24) due to bot failures. The test failures were fixed by having SelfExecutorProcessControl use an InPlaceTaskDispatcher by default, rather than a DynamicThreadPoolTaskDispatcher. This shouldn't be necessary (and indicates a concurrency issue elsewhere), but InPlaceTaskDispatcher is a less surprising default, and better matches the existing behavior (compilation on current thread by default), so the change seems reasonable. I've filed https://github.com/llvm/llvm-project/issues/89870 to investigate the concurrency issue as a follow-up. Coding my way home: 6.25133S 127.94177W
2024-04-22Revert "Re-apply [ORC] Unify task dispatch across ExecutionSession and..."Lang Hames3-96/+30
This reverts commit 1effa19de24 while I investigate the test failure at https://lab.llvm.org/buildbot/#/builders/285/builds/888.
2024-04-22Re-apply "[ORC] Unify task dispatch across ExecutionSession and..." with fix.Lang Hames3-30/+96
This re-applies 6094b3b7db7, which was reverted in a28557aadd8 due to broken bots. As far as I can tell all failures were due to a missing #include <deque>, which has been adedd in this commit.
2024-04-22Revert "[ORC] Unify task dispatch across ExecutionSession and ↵Mehdi Amini3-96/+30
ExecutorProcessControl." This reverts commit 6094b3b7db7eab8318b9d30dec2691d231c7bdff. Multiple bots are broken.
2024-04-22[ORC] Unify task dispatch across ExecutionSession and ExecutorProcessControl.Lang Hames3-30/+96
Updates ExecutionSession to use the ExecutorProcessControl object's TaskDispatcher rather than having a separate dispatch function. This gives the TaskDispatcher a global view of all tasks to be executed, and provides a single point to wait on for tasks to complete when shutting down the JIT.
2024-04-13[ORC] Replace more KV loop variables with structured bindings.Lang Hames1-6/+6
Coding my way home: 4.42841S, 102.96190W
2024-04-09[orc] Reduce memory usage from empty materialization info DenseMaps (#88167)Ben Langmuir1-0/+23
Saves several MB of memory in larger applications after linking finishes by clearing DenseMap storage that is empty. This does not attempt to shrink partially full materialization infos. The assumption is that adding more after linking finishes is rare. rdar://126145336
2024-04-08[ORC] Replace some KV loop variables with structured bindings.Lang Hames1-4/+4
Same idea as 006aaf32258 -- reduce boilerplate and improve readability. This time updates will be piecemeal to make it easier to identify errors. Coding my way home: 2.18555S, 93.78063W
2024-04-08Revert "[ORC] Replace some KV loop variables with structured bindings."Lang Hames1-153/+162
This reverts commit 006aaf32258fc27656c936f6aad729e4c77e3847 while I investigate some bot failures (See e.g. https://lab.llvm.org/buildbot/#/builders/109/builds/86659).
2024-04-07[ORC] Replace some KV loop variables with structured bindings.Lang Hames1-162/+153
This allows us to remove a lot of boilerplate .first and .second references and improve readability. Coding my way home: 1.58814S, 91.93889W
2024-04-07[ORC] Add an ExecutionSession state verifier.Lang Hames1-2/+211
Add an ExecutionSession state verifier, enabled under EXPENSIVE_CHECKS, that can be used to identify inconsistent session state to assist in tracking down bugs. This initial version was motivated by investigation of the EDU-update bug that was fixed in a671ceec334. rdar://125376708
2024-04-05[ORC] Fix an EDU-update bug in ExecutionSession::IL_failSymbols.Lang Hames1-5/+10
We were catching a local variable, SymMI, by value instead of by reference during EDU cleanup and this was leaving the dependence graph in an inconsistent state that could lead to crashes on subsequent emits. Fixing this bug required us to also avoid aliasing between SymMI and MI (which would have caused cleanup to clear the MI.DependantEDUs set that we're iterating over). No testcase: the crash only triggered in very specific circumstances (including concurrent linking) in an out-of-tree ORC client. I'm working on a session state verifier that could be turned on when compiling with expensive-checks turned on and that should help us catch issues like this in the future. rdar://125164262 Coding my way home: 0.89527S, 89.61313W
2024-03-28[Object,ELFType] Rename TargetEndianness to Endianness (#86604)Fangrui Song1-2/+2
`TargetEndianness` is long and unwieldy. "Target" in the name is confusing. Rename it to "Endianness". I cannot find noticeable out-of-tree users of `TargetEndianness`, but keep `TargetEndianness` to make this patch safer. `TargetEndianness` will be removed by a subsequent change.
2024-03-25[ORC] Add some debug logging to EPCDynamicLibrarySearchGenerator.Lang Hames1-1/+18
Coding my way home: 8.98112N, 79.52094W
2024-03-22[ORC] Add default visibility to required JIT functions (#86322)Keith Smiley1-0/+2
If you build LLVM with `-DCMAKE_CXX_VISIBILITY_PRESET=hidden` to help reduce binary size, these symbols end up becoming local, and getting stripped. This forces default visibility to override the global setting in that case. Relevant: https://github.com/llvm/llvm-project/issues/62815#issuecomment-1560078260
2024-03-14[ORC][MachO] Make BuildVersionOpts::fromTriple result optional, add test.Lang Hames1-10/+9
Only platform specific darwin OS values (e.g. macosx, ios, watchos, ...) can be mapped to an LC_BUILD_VERSION platform. For all other values return an empty optional to indicate that the load command can't be constructed. Also fixes the simulator conditions to return the correct platform, and adds a testcase.
2024-03-14[ORC][MachO] Pluralize member name.Lang Hames1-1/+1
This member switched from an optional to a vector in 0f252e7bd83.
2024-03-14[ORC][MachO] Allow multiple LC_BUILD_VERSION commands.Lang Hames1-4/+2
No testcase: I'm still thinking about the best way to test this.
2024-03-13[NFC] Corrected data type (#84880)Chen Cheng1-1/+1
On windows, "&Method.first" is of type "unsigned long long *", and a type conversion error occurs.
2024-03-08[llvm][Support] Add and use errnoAsErrorCode (#84423)Michael Spencer2-12/+8
LLVM is inconsistent about how it converts `errno` to `std::error_code`. This can cause problems because values outside of `std::errc` compare differently if one is system and one is generic on POSIX systems. This is even more of a problem on Windows where use of the system category is just wrong, as that is for Windows errors, which have a completely different mapping than POSIX/generic errors. This patch fixes one instance of this mistake in `JSONTransport.cpp`. This patch adds `errnoAsErrorCode()` which makes it so people do not need to think about this issue in the future. It also cleans up a lot of usage of `errno` in LLVM and Clang.
2024-03-07[ORC] Deallocate FinalizedAllocs on error paths in notifyEmitted.Lang Hames1-2/+10
If notifyEmitted encounters a failure (either because some plugin returned one, or because the ResourceTracker was defunct) then we need to deallocate the FinalizedAlloc manually. No testcase yet: This requires a concurrent setup -- we'll need to build some infrastructure to coordinate links and deliberately injected failures in order to reliably test this.
2024-03-07[ORC] Propagate defineMaterializing failure when resource tracker is defunct.Lang Hames1-3/+4
Remove an overly aggressive cantFail: This call to defineMaterializing should never fail with a duplicate symbols error (since all new symbols shoul be weak), but may fail if the tracker has become defunct in the mean time. In that case we need to propagate the error.
2024-03-07[ORC][JITLink] Add Intel VTune support to JITLink (#83957)Hongyu Chen4-0/+419
[ORC] Re-land https://github.com/llvm/llvm-project/pull/81826 This patch adds two plugins: VTuneSupportPlugin.cpp and JITLoaderVTune.cpp. The testing is done in a manner similar to llvm-jitlistener. Currently, we only support the old version of Intel VTune API.
2024-03-05Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (#83702)Mehdi Amini1-2/+2
The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. This is a breaking change: clients who use to create a ThreadPool must now create a DefaultThreadPool instead.
2024-03-05[ORC][MachO] Simplify use of LC_BUILD_VERSION in JITDylib headers.Lang Hames1-0/+35
API clients can now set a MachO::HeaderOptions::BuildVersionOpts field to have MachOPlatform add an LC_BUILD_VERSION load command to the Mach header for each JITDylib. No testcase yet. In the future we'll try to add a MachO parser to the ORC runtime and extra test options to llvm-jitlink for this. This commit also incidentally fixes a bug in the MachOBuilder class that lead to a delegation cycle.
2024-03-04Revert "[ORC][JITLink] Add Intel VTune support to JITLink (#81826)"Jordan Rupprecht4-415/+0
This reverts commit 17efdad2296a2757813e4f11d0575ee6fb826e39. It introduces a layering violation: https://github.com/llvm/llvm-project/pull/81826#issuecomment-1977455140
2024-03-04[ORC][JITLink] Add Intel VTune support to JITLink (#81826)Hongyu Chen4-0/+415
This patch adds two plugins: VTuneSupportPlugin.cpp and JITLoaderVTune.cpp. The testing is done in a manner similar to llvm-jitlistener. Currently, we only support the old version of Intel VTune API. This pull request is stacked on top of https://github.com/llvm/llvm-project/pull/81825
2024-02-20[ORC] Add SectCreateMaterializationUnit, llvm-jitlink -sectcreate option.Lang Hames2-0/+53
The SectCreateMaterializationUnit creates a LinkGraph with a single named section containing a single named block whose content is given by a MemoryBuffer. It is intended to support emulation of ld64's -sectcreate option.
2024-02-12[ORC] Make EPCDynamicLibrarySearchGenerator asyncBen Langmuir4-61/+97
Switch the primary implementation of EPC lookupSymbols to be async, keeping a synchronous wrapper for compatibility. Use the new async implementation inside EPCDynamicLibrarySearchGenerator to work working towards a fully async search generator. Provide an asynchronous lookup API for EPCGenericDylibManager and adopt that from the SimpleRemoteEPC. This enables an end-to-end async EPCDynamicLibrarySearchGenerator. Note: currently we keep the current per-dlhandle lookup model, but a future improvement could do a single async call for a given lookup operation.
2024-01-31[ORC] Merge MaterializationResponsibility notifyEmitted and addDependencieslhames7-532/+903
Removes the MaterializationResponsibility::addDependencies and addDependenciesForAll methods, and transfers dependency registration to the notifyEmitted operation. The new dependency registration allows dependencies to be specified for arbitrary subsets of the MaterializationResponsibility's symbols (rather than just single symbols or all symbols) via an array of SymbolDependenceGroups (pairs of symbol sets and corresponding dependencies for that set). This patch aims to both improve emission performance and simplify dependence tracking. By eliminating some states (e.g. symbols having registered dependencies but not yet being resolved or emitted) we make some errors impossible by construction, and reduce the number of error cases that we need to check. NonOwningSymbolStringPtrs are used for dependence tracking under the session lock, which should reduce ref-counting operations, and intra-emit dependencies are resolved outside the session lock, which should provide better performance when JITing concurrently (since some dependence tracking can happen in parallel). The Orc C API is updated to account for this change, with the LLVMOrcMaterializationResponsibilityNotifyEmitted API being modified and the LLVMOrcMaterializationResponsibilityAddDependencies and LLVMOrcMaterializationResponsibilityAddDependenciesForAll operations being removed.