aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine
AgeCommit message (Collapse)AuthorFilesLines
2026-01-12[JITLink] Add GOT indirection optimization for SystemZ (#171919)anoopkg62-2/+38
Optimize the GOT and Stub relocations if the edge target address is in range from call site - Indirect jump by plt stub can be replaced with direct jump to target in post-allocation optimization.
2026-01-12[JITLink] Set correct triple instead of hard-code the value to linux (#175404)aokblast1-4/+5
2026-01-12[ORC] Simplify zero initializer. NFCI. (#175482)Lang Hames1-1/+1
Based on suggestion from @macdice on https://github.com/llvm/llvm-project/pull/175204. Thanks @macdice!
2026-01-12[ORC][JITLink] Fix unitialised JIT dump header (#175204)Anthonin Bonnefoy1-1/+1
When trying to perf inject JIT dump generatd through the perf plugin, perf fails with the following error: ``` jitdump file contains invalid or unsupported flags 0xf5880666c26c 0x2b750 [0xa8]: failed to process type: 10 [Operation not permitted] ``` It turns out that Header's Flags field was never initialized, so the value could be random. This patch fixes the issue by initialising all Header's fields. Co-authored-by: Lang Hames <lhames@gmail.com>
2026-01-12[RuntimeDyld][MIPS] Use AT for stub function instead of T9 (#174354)Icenowy Zheng1-28/+28
The stub function is generated for R_MIPS_26 relocation, which could be used for local jumping inside a function, and do not expect any temporary register to be clobbered. Use AT instead of T9 for the stub function, otherwise functions using T9 will be messed up. Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
2026-01-12Reapply "[ORC] Add utilities for limited symbolication of JIT backtra… ↵Lang Hames2-0/+151
(#175469) …ces" This reapplies 906b48616c03948a4df62a5a144f7108f3c455e8, which was reverted in c11df52f9b847170b766fb71defd2a9222d95a8d due to bot failures. The testcase has been dropped from this recommit as it failed on several bots (possbly due to differing backtrace formats or failure modes). I'll re-introduce the testcase in a follow-up commit so that it cane be iterated on (and re-reverted if necessary) without affecting the options introduced by this commit. (Since these options are best-effort debugging tools it's ok if they live in-tree without a test for now).
2026-01-12[ORC] Fixed incorrect additional header dirs (#175193)Vedran Miletić2-2/+3
The CMake ADDITIONAL_HEADER_DIRS directive for two Orc libraries, specifically Shared and TargetProcess, used incorrect values that pointed to its parent library include directory instead of its own. This is now fixed.
2026-01-10[JITLink][LoongArch][NFC] Move applyFixup implementation from header to ↵WANG Rui1-1/+231
source file
2026-01-09Revert "[ORC] Add utilities for limited symbolication of JIT backtraces ↵Aiden Grossman2-148/+0
(#175099)" This reverts commit 906b48616c03948a4df62a5a144f7108f3c455e8. The forward fix for this got reverted in 25976e83606f1a7615e3725e6038bb53ee96c3d5, so reverting the original commit given it is still broken and the forward fix that mitigated most of the issues is no longer in tree.
2026-01-09[CommandLine] Use DenseMap instead of StringMap (NFC) (#174988)Nikita Popov1-0/+1
StringMap duplicates the option name to a new allocation for every option, which is not necessary. Instead we can use the same StringRef that the Option already uses inside a DenseMap. This reduces the amount of allocations when loading libLLVM.
2026-01-09[ORC] Add utilities for limited symbolication of JIT backtraces (#175099)Lang Hames2-0/+148
This patch adds tools for capturing symbol information from JIT'd code and using it to symbolicate backtraces. This is useful for debugging crashes in JIT-compiled code where traditional symbolication tools may not have access to the JIT symbol table. These tools are not a general solution to the JIT symbolication problem (that will require further integration with system components like libunwind, the dynamic linker, and/or crash tracing tools), but will aid in JIT debugging and development until a general solution is available. APIs Added: 1. SymbolTableDumpPlugin - A LinkGraphLinkingLayer::Plugin that captures symbol information as code is JIT'd and writes it to a file. - Create(StringRef Path) -> Expected<std::shared_ptr<SymbolTableDumpPlugin>> Creates a plugin that appends symbol information to the specified file. - Symbol table format: "<link graph name>" <address> <symbol name> <address> <symbol name> ... The plugin uses a PostAllocationPass to write symbols after addresses have been assigned but before the code is finalized. 2. DumpedSymbolTable - A class for symbolicating backtraces using a previously dumped symbol table. - Create(StringRef Path) -> Expected<DumpedSymbolTable> Loads and parses a symbol table from a file. - symbolicate(StringRef Backtrace) -> std::string Given text of a backtrace, for rows ending with a hex address, adds the symbol name, offset, and defining graph name. New `llvm-jitlink` Command Line Options: 1. -write-symtab=<path> Enables the SymbolTableDumpPlugin to write symbol information to the specified file as objects are JIT'd. The symbol table can then be used to symbolicate backtraces from crashes or signal handlers. 2. -symbolicate-with=<path> Runs llvm-jitlink in symbolication mode. Reads the symbol table from <path> and symbolicates backtraces read from stdin or input files. Usage Examples: $ llvm-jitlink -write-symtab=symbols.txt mycode.o $ llvm-jitlink -symbolicate-with=symbols.txt - < backtrace.txt
2026-01-09[ORC] Add JITDylibDefunct Error. (#174923)Lang Hames1-0/+10
This Error can be returned from operations on JITDylibs that cannot proceed as the target JITDylib has been closed. This patch uses the new error to replace an unsafe assertion in JITDylib::define: If a JITDylib::define operation is run by an in-flight task after the target JITDylib is closed it should error out rather than asserting. See also https://github.com/llvm/llvm-project/issues/174922
2026-01-06[ORC][C API] Replace 'bool' with 'LLVMBool'. (#174525)Lang Hames1-1/+1
The LLVM C APIs use LLVMBool rather than bool. This should fix the failure in https://lab.llvm.org/buildbot/#/builders/29/builds/19955 and similar builds.
2026-01-06[C-API] Allow SectionMemoryManager's ReserveAlloc flag to be enabled (#174307)Thomas Munro1-0/+10
Allow C programs to pass a ReserveAlloc flag to the constructor of llvm::SessionMemoryManager, using a new variant of LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager that has ...ReserveAlloc() appended to its name.
2026-01-04[Orc][LibResolver] Refactor resolver internals and simplify symbol ↵SahilPatidar2-372/+398
resolution. (#169161) - Replace getLibraries() with cursor-based iteration. - Simplify search logic and handle new libraries during scanning. - Make symbol resolution faster with single enumeration and early exit.
2026-01-02[LLVM][ADT] Migrate users of `make_scope_exit` to CTAD (#174030)Victor Chernyakin3-3/+3
This is a followup to #173131, which introduced the CTAD functionality.
2025-12-24[ORC] Fix ReOptimizeLayer buggy jit-dispatch signature in fa7f7a4cab4. (#173457)Lang Hames1-3/+4
fa7f7a4cab4 changed the jit-dispatch function signature used in the orc_rt_lite_reoptimize_helper function, but jit-dispatch still takes a raw data pointer and size argument. Should fix the bug in https://lab.llvm.org/buildbot/#/builders/169/builds/18319 and similar builds.
2025-12-24[ORC] Pass JITDispatchHandler argument buffers as WrapperFunctionBuffer. ↵Lang Hames6-21/+23
(#173334) Updates ExecutionSession::runJITDispatchHandler to take the argument buffer for the function as a WrapperFunctionBuffer, rather than an ArrayRef<char>. This is a first step towards more efficient jit-dispatch handler calls: 1. Handlers can now be run as tasks, since they own their argument buffer (so there's no risk of it being deallocated before they're run) 2. In in-process JIT setups, this will allow argument buffers to be passed in directly from the ORC runtime, rather than having to copy the buffer.
2025-12-23[ORC] Add, and call through, reoptimize function in ReOptimizeLayer. (#173204)Lang Hames1-46/+111
ReOptimizeLayer was building LLVM IR to define a precomputed, SPS-serialized argument buffer, then inserting calls directly to __orc_rt_jit_dispatch, passing the address of the precomputed buffer and an __orc_rt_reoptimize_tag defined by the ORC runtime. This design is non-canonical, requiring the ORC runtime to be loaded (or an extra definition for __orc_rt_reoptimize_tag to be inserted) while not using the runtime to perform the serialization. This commit updates ReOptimizeLayer to instead insert calls to an __orc_rt_reoptimize function implemented in the ORC runtime. This function will perform serialization and call __orc_rt_jit_dispatch, similar to other functions in the ORC runtime. To maintain support for in-process JITs that don't use the ORC runtime, this commit adds a ReOptimizeLayer::addOrcRTLiteSupport method which injects IR to define __orc_rt_reoptimize (calling through to an orc_rt_lite_reoptimize_helper function defined in LLVM) and __orc_rt_reoptimize_tag. The ReOptimizeLayerTest is updated to use addOrcRTLiteSupport.
2025-12-20[ORC] Fix unchecked Expected<T> in ELFDebugObjectPlugin::FinalizePromise ↵Stefan Gränitz1-8/+29
(#172904) If `Alloc.finalize()` fails in the post-allocation pass, we store the error in `FinalizePromise`. If we don't reach the post-fixup pass afterwards the error will leak. This patch adds another case in the DebugObject destructor that will check the `Expected<T>` and report the error.
2025-12-18[ORC] Fix typo in method name. NFCI. (#172787)Lang Hames1-1/+1
"reigsterRuntimeFunctions" should be "registerRuntimeFunctions".
2025-12-18Implement reserveAllocationSpace for SectionMemoryManager (#71968)Michael Smith1-2/+95
Implements `reserveAllocationSpace` and provides an option to enable `needsToReserveAllocationSpace` for large-memory environments with AArch64. The [AArch64 ABI](https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst#7code-models) has restrictions on the distance between TEXT and GOT sections as the instructions to reference them are limited to 2 or 4GB. Allocating sections in multiple blocks can result in distances greater than that on systems with lots of memory. In those environments several projects using SectionMemoryManager with MCJIT have run across assertion failures for the R_AARCH64_ADR_PREL_PG_HI21 instruction as it attempts to address across distances greater than 2GB (an int32). Fixes #71963 by allocating all sections in a single contiguous memory allocation, limiting the distance required for instruction offsets similar to how pre-compiled binaries would be loaded into memory. Co-authored-by: Lang Hames <lhames@gmail.com>
2025-12-18[ORC] Rewrite loop to use structured bindings. NFCI. (#172631)Lang Hames1-7/+7
2025-12-18[ORC] Rename WrapperFunctionResult to WrapperFunctionBuffer. NFCI. (#172633)Lang Hames13-60/+60
Also renames CWrapperFunctionResult to CWrapperFunctionBuffer. These types are used as argument buffers, as well as result buffers. The new name better reflects their purpose, and is consistent with naming in the new ORC runtime (llvm-project/orc-rt).
2025-12-17[ELFDebugObjectPlugin] Gracefully handle missing section (#172622)Nikita Popov1-4/+10
On ppc64le some sections like .toc get merged into other sections by JITLink. As such, some sections in the object file may not be present in the link graph. Skip those sections.
2025-12-17[ORC] Make WrapperFunctionResult constructor explicit. (#172602)Lang Hames1-1/+2
The WrapperFunctionBuffer(CWrapperFunctionBuffer) constructor takes ownership of the underlying buffer (if one exists). Making the constructor explicit makes this clearer at the call site.
2025-12-16Reland: [ORC] Tailor ELF debugger support plugin to load-address patching ↵Stefan Gränitz1-382/+223
only (#169482) In 4 years the ELF debugger support plugin wasn't adapted to other object formats or debugging approaches. After the renaming NFC in https://github.com/llvm/llvm-project/pull/168343, this patch tailors the plugin to ELF and section load-address patching. It allows removal of abstractions and consolidate processing steps with the newly enabled AllocActions from https://github.com/llvm/llvm-project/pull/168343. The key change is to process debug sections in one place in a post-allocation pass. Since we can handle the endianness of the ELF file the single `visitSectionLoadAddresses()` visitor function now, we don't need to track debug objects and sections in template classes anymore. We keep using the `DebugObject` class and drop `DebugObjectSection`, `ELFDebugObjectSection<ELFT>` and `ELFDebugObject`. Furthermore, we now use the allocation's working memory for load-address fixups directly. We can drop the `WritableMemoryBuffer` from the debug object and most of the `finalizeWorkingMemory()` step, which saves one copy of the entire debug object buffer. Inlining `finalizeAsync()` into the pre-fixup pass simplifies quite some logic. The original patch broke compiler-rt checks: https://github.com/llvm/llvm-project/commit/db5eeddbd3f1d5cdb86e365a2a80b036bd66de7f Reverted with: https://github.com/llvm/llvm-project/commit/0182a76970e4e7a9faa3be049ea371128a28ee39
2025-12-11[JITLink] Add TLS support for SystemZ (#171559)anoopkg63-1/+72
This patch adds TLS support for SystemZ on top of orc-runtime support. A separate orc-runtime support #171062 has been created from earlier TLS support #[170706](https://github.com/llvm/llvm-project/pull/170706). See conversations in [#170706](https://github.com/llvm/llvm-project/pull/170706) --------- Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-12-09 [JITLink] Add orc-runtime support for SystemZ (#171062)anoopkg61-0/+5
Add orc-runtime support and tests for SystemZ. Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-12-04[C-API] LLVMOrcCreateObjectLinkingLayerWithInProcessMemoryManager (#169862)Thomas Munro1-0/+13
Allow C programs to use JITLink with trivial new C-API wrapper. Modeled on `LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager` except that it has to deal with failure of `jitlink::InProcessMemoryManager::Create()`. Function name suggested by @lhames in https://github.com/llvm/llvm-project/issues/106203. I suppose failure of underlying platform-specific things like `sysconf(_SC_PAGESIZE)` shouldn't really happen. An alternative error reporting style might be to follow `LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess` and return `LLVMErrorRef` with an output parameter for the `LLVMOrcObjectLayerRef`, but then it wouldn't be a drop-in replacement for `LLVMOrcCreateRTDyldObjectLinkingLayerWithSectionMemoryManager`. Thoughts? This is wanted by PostgreSQL (branch using this API: https://github.com/macdice/postgres/tree/llvm-22-proposed-c-api). (We're also using `LLVMCreatePerfJITEventListener`, `LLVMCreatePerfJITEventListener`, `LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener`, so it looks like we'll need to research `PerfSupportPlugin`, `DebuggerSupportPlugin`, `ObjectLinkingLayer::addPlugin()`...)
2025-11-23[Orc] Use a range-based for loop (NFC) (#169240)Kazu Hirata1-6/+1
Identified with modernize-loop-convert.
2025-11-21Revert "[ORC] Tailor ELF debugger support plugin to load-address patching ↵Stefan Gränitz1-215/+383
only" (#169073) Reverts llvm/llvm-project#168518
2025-11-21[ORC] Tailor ELF debugger support plugin to load-address patching only (#168518)Stefan Gränitz1-383/+215
In 4 years the ELF debugger support plugin wasn't adapted to other object formats or debugging approaches. After the renaming NFC in https://github.com/llvm/llvm-project/pull/168343, this patch tailors the plugin to ELF and section load-address patching. It allows removal of abstractions and consolidate processing steps with the newly enabled AllocActions from https://github.com/llvm/llvm-project/pull/168343. The key change is to process debug sections in one place in a post-allocation pass. Since we can handle the endianness of the ELF file the single `visitSectionLoadAddresses()` visitor function now, we don't need to track debug objects and sections in template classes anymore. We keep using the `DebugObject` class and drop `DebugObjectSection`, `ELFDebugObjectSection<ELFT>` and `ELFDebugObject`. Furthermore, we now use the allocation's working memory for load-address fixups directly. We can drop the `WritableMemoryBuffer` from the debug object and most of the `finalizeWorkingMemory()` step, which saves one copy of the entire debug object buffer. Inlining `finalizeAsync()` into the pre-fixup pass simplifies quite some logic. We still track `RegisteredObjs` here, because we want to free memory once the corresponding code is freed. There will be a follow-up patch that turns it into a dealloc action.
2025-11-19[ORC] Remove now unused EPCDebugObjectRegistrar (NFC) (#167868)Stefan Gränitz3-78/+0
EPCDebugObjectRegistrar is unused now that the ELF debugger support plugin uses AllocActions https://github.com/llvm/llvm-project/pull/167866
2025-11-18[ORC] Fix shlibs build: add Object to libLLVMOrcDebugging (#168343)Stefan Gränitz2-1/+2
2025-11-18[ORC] Move DebugObjectManagerPlugin into Debugging/ELFDebugObjectPlugin ↵Stefan Gränitz4-22/+20
(NFC) (#168343) In 4 years the plugin wasn't adapted to other object formats. This patch makes it specific for ELF, which will allow to remove some abstractions down the line. It also moves the plugin from LLVMOrcJIT into LLVMOrcDebugging, which didn't exist back then.
2025-11-18[ORC] Remove unnecessary LLVM_ABI on function def. NFCI. (#168478)Lang Hames1-1/+1
2025-11-18[ORC] Support scanning "fallback" slices for interfaces. (#168472)Lang Hames1-41/+105
When scanning an interface source (dylib or TBD file), consider "fallback" architectures (CPUType / CPUSubType pairs) in addition to the process's CPUType / CPUSubType. Background: When dyld loads a dylib into a process it may load dylib or slice whose CPU type / subtype isn't an exact match for the process's CPU type / subtype. E.g. arm64 processes can load arm64e dylibs / slices. When building an interface we need to follow the same logic, otherwise we risk generating a spurious "does not contain a compatible slice" error. E.g. If we're running an arm64 JIT'd program and loading an interface from a TBD file, and if no arm64 slice is present in that file, then we should fall back to looking for an arm64e slice. rdar://164510783
2025-11-18[ORC] Merge GetDylibInterface.h APIs into MachO.h. (#168462)Lang Hames3-129/+110
These APIs are MachO specific, and the interfaces are about to be extended to support more MachO-specific behavior. For now it makes sense to group them with other MachO specific APIs in MachO.h.
2025-11-17[ORC] Update ELF debugger support plugin to use AllocActions (#167866)Stefan Gränitz5-66/+92
The `DebugObjectManagerPlugin` implements debugger support for ELF platforms with the GDB JIT Interface. It emits a separate debug object allocation in addition to the LinkGraph's own allocation. This used to happen in the plugin's `notifyEmitted()` callback, i.e. after the LinkGraph's allocation was finalized. In the meantime, it had to block finalization of the corresponding materialization unit to make sure that the debugger can register the object before the code runs. This patch switches the plugin to use an allocation action instead. We can remove the `notifyEmitted()` hook and implement all steps as JITLink passes.
2025-11-11 JITLink: Add initial SystemZ Support. (#144528)anoopkg65-0/+551
Set up initial infrastructure for SystemZ architecture support in JITLink. It includes features like GOT and PLT handling. Relaxation of GOT/PLT and support for TLS were intentionally left out for the moment. Support for TLS might require info regarding moduleID. This could further mean changes to target independent part of JITLink and library support. --------- Co-authored-by: anoopkg6 <anoopkg6@github.com>
2025-11-11Remove unused <utility> inclusionserge-sans-paille1-1/+0
Per https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible this improves compilation time, while not being too intrusive on the codebase.
2025-11-09Remove unused <array> and <list> inclusion (#167116)serge-sans-paille2-4/+0
2025-11-08[llvm] Remove unused local variables (NFC) (#167185)Kazu Hirata1-2/+0
Identified with bugprone-unused-local-non-trivial-variable.
2025-11-08[ExecutionEngine] Use StringRef::starts_with (NFC) (#167152)Kazu Hirata1-2/+2
Identified with modernize-use-starts-ends-with.
2025-11-06[ORC][LibraryResolver] Fix ensureFilterBuilt assertion failure and ↵SahilPatidar2-19/+16
concurrency issue. (#166510) - Fixed architecture compatibility check. Previously, we used `sys::getDefaultTriple()`, which caused issues on build bots using cross-compilation. We now ensure that the target architecture where the shared library (.so) is run or loaded matches the architecture it was built for. - Fixed ensureFilterBuilt assertion failure. - Replaced use of FilteredView with a safer alternative for concurrent environments. The old FilteredView approach iterated over shared state without sufficient synchronization, which could lead to invalid accesses when libraries were being added or removed concurrently.
2025-11-02[llvm] Use "= default" (NFC) (#166088)Kazu Hirata1-1/+1
Identified with modernize-use-equals-default.
2025-11-01REAPPLY [ORC] Add automatic shared library resolver for unresolved symbols. ↵SahilPatidar3-0/+1535
(attempt 2) (#165360) This PR reapplies the changes previously introduced in https://github.com/llvm/llvm-project/pull/148410. It introduces a redesigned and rebuilt Cling-based auto-loading workaround that enables scanning libraries and resolving unresolved symbols within those libraries. Fix build failures in LibraryResolverTest and silence symlink warning This commit resolves issues observed in the build bots: 1. Silences the -Wunused-result warning by handling the return value of ::symlink in LibraryResolverTest.cpp. Previously, ignoring the return value triggered compiler warnings. 2. Fixes a linker error in OrcJITTests caused by an undefined symbol: llvm::yaml::convertYAML. The test setup in LibraryResolverTest.cpp now correctly links against the required LLVM YAML library symbols. 3. Fixes persistent build bot failure caused by a path difference issue. This resolves the build failures for PR https://github.com/llvm/llvm-project/pull/148410 on the affected bots.
2025-10-28[llvm] Use nullptr instead of 0 or NULL (NFC) (#165396)Kazu Hirata1-1/+1
Identified with modernize-use-nullptr.
2025-10-25[ORC] Fix race when checking isComplete (#165063)Jordan Rupprecht1-4/+13
After #164340 there is a tsan race on `OutstandingSymbolsCount` when decrementing it in `notifySymbolMetRequiredState` vs reading it in `isComplete()`. Fix this by having `IL_emit` filter out non-completed queries when it has the lock to do so, and that way we avoid needing to call `isComplete()` later.