aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Orc
AgeCommit message (Collapse)AuthorFilesLines
2025-03-06[IR] Store Triple in Module (NFC) (#129868)Nikita Popov1-1/+1
The module currently stores the target triple as a string. This means that any code that wants to actually use the triple first has to instantiate a Triple, which is somewhat expensive. The change in #121652 caused a moderate compile-time regression due to this. While it would be easy enough to work around, I think that architecturally, it makes more sense to store the parsed Triple in the module, so that it can always be directly queried. For this change, I've opted not to add any magic conversions between std::string and Triple for backwards-compatibilty purses, and instead write out needed Triple()s or str()s explicitly. This is because I think a decent number of them should be changed to work on Triple as well, to avoid unnecessary conversions back and forth. The only interesting part in this patch is that the default triple is Triple("") instead of Triple() to preserve existing behavior. The former defaults to using the ELF object format instead of unknown object format. We should fix that as well.
2025-03-06Re-apply "[ORC] Remove the Triple argument from LLJITBuilder::..." with fixes.Lang Hames2-9/+7
This re-applies f905bf3e1ef860c4d6fe67fb64901b6bbe698a91, which was reverted in c861c1a046eb8c1e546a8767e0010904a3c8c385 due to compiler errors, with a fix for MLIR.
2025-03-06Revert "[ORC] Remove the Triple argument from LLJITBuilder::ObjectLinking..."Lang Hames2-7/+9
This reverts commit f905bf3e1ef860c4d6fe67fb64901b6bbe698a91 while I fix some compile errors reported on the buildbots (see e.g. https://lab.llvm.org/buildbot/#/builders/53/builds/13369).
2025-03-06[ORC] Remove the Triple argument from LLJITBuilder::ObjectLinkingLayerCreator.Lang Hames2-9/+7
ExecutionSession can provide the Triple, so this argument has been redundant for a while, and no in-tree clients use it.
2025-03-01[ExecutionEngine] Avoid repeated hash lookups (NFC) (#129356)Kazu Hirata1-2/+3
2025-02-28[ExecutionEngine] Avoid repeated hash lookups (NFC) (#129191)Kazu Hirata1-3/+3
2025-02-27[ExecutionEngine] Avoid repeated hash lookups (NFC) (#128997)Kazu Hirata1-2/+3
2025-02-27[ORC] Sink include into implementation file.Lang Hames1-0/+1
TapiUniversal.h is only needed as an implementation detail.
2025-02-27[ORC] Support adding LC_LOAD_WEAK_DYLIB commands to MachO JITDylib headers.Lang Hames1-3/+16
MachOPlatform synthesizes Mach headers for JITDylibs (see ef314d39b92). This commit adds support for adding LC_LOAD_WEAK_DYLIB commands to these synthesized headers (LC_LOAD_DYLIB was already supported previously).
2025-02-26[ExecutionEngine] Avoid repeated hash lookups (NFC) (#128827)Kazu Hirata1-3/+1
2025-02-25[ORC][llvm-jitlink] Extend weak-linking emulation to real dylibs.Lang Hames3-40/+128
Commit 253e11695ba added support for emulating weak-linking against dylibs that are (under the emulation) absent at runtime. This commit extends emulated weak linking support to allow a real dylib to supply the interface (i.e. -weak-lx / -weak_library can be pointed at a dylib, in which case they should be read as "weak-link against this dylib, behavining as if it weren't actually present at runtime").
2025-02-25[ORC] Add dependence on TextAPI to reflect changes in 253e11695ba.Lang Hames1-0/+1
2025-02-25[ORC][llvm-jitlink] Add support for emulating ld64 -weak-lx / -weak_library.Lang Hames3-4/+60
Linking libraries in ld64 with -weak-lx / -weak_library causes all references to symbols in those libraries to be made weak, allowing the librarie to be missing at runtime. This patch extends EPCDynamicLibrarySearchGenerator with support for emulating this behavior: If an instance is constructed with an Allow predicate but no dylib handle then all symbols matching the predicate are immediately resolved to null. The llvm-jitlink tool is updated with -weak-lx / -weak_library options for testing. Unlike their ld64 counterparts these options take a TBD file as input, and always resolve all exports in the TBD file to null.
2025-02-18[ExecutionEngine] Avoid repeated hash lookups (NFC) (#127577)Kazu Hirata1-2/+3
2025-02-18[ORC] Propagate weak & hidden flags when creating lazy reexports, redirectables.Lang Hames2-2/+5
Updates JITLinkRedirectableSymbolManager to take alias flags into account when setting the scope and linkage of the created stubs (weak aliases get now get weak linkage, hidden stubs get hidden visibility). Updates lazyReexports to propagate alias flags (rather than trampoline flags) when building the initial destinations map for the redirectable symbols manager. Together these changes allow the LazyObjectLinkingLayer to link objects containing weak and hidden symbols.
2025-02-15[ExecutionEngine] Avoid repeated hash lookups (NFC) (#127303)Kazu Hirata1-2/+3
2025-02-13[ORC] Silence unused variable warnings.Lang Hames1-0/+2
2025-02-13Orc: Suppress a warning in #126691NAKAMURA Takumi1-0/+1
2025-02-11[ExecutionEngine] Fix formatting (NFC)Kazu Hirata1-2/+4
2025-02-11[ExecutionEngine] Fix a warningKazu Hirata1-1/+1
This patch fixes: llvm/lib/ExecutionEngine/Orc/TargetProcess/UnwindInfoManager.cpp:53:20: error: unused variable 'AddFnName' [-Werror,-Wunused-variable]
2025-02-11[NFC] [clang] fixed unused variable warningFlorian Mayer1-1/+1
2025-02-12[ORC] Switch to singleton pattern for UnwindInfoManager. (#126691)Lang Hames5-242/+94
The find-dynamic-unwind-info callback registration APIs in libunwind limit the number of callbacks that can be registered. If we use multiple UnwindInfoManager instances, each with their own own callback function (as was the case prior to this patch) we can quickly exceed this limit (see https://github.com/llvm/llvm-project/issues/126611). This patch updates the UnwindInfoManager class to use a singleton pattern, with the single instance shared between all LLVM JITs in the process. This change does _not_ apply to compact unwind info registered through the ORC runtime (which currently installs its own callbacks). As a bonus this change eliminates the need to load an IR "bouncer" module to supply the unique callback for each instance, so support for compact-unwind can be extended to the llvm-jitlink tools (which does not support adding IR).
2025-02-07[ORC] Force eh-frame use for older Darwins on x86-64 in MachOPlatform, LLJIT.Lang Hames6-19/+78
The system libunwind on older Darwins does not support JIT registration of compact-unwind. Since the CompactUnwindManager utility discards redundant eh-frame FDEs by default we need to remove the compact-unwind section first when targeting older libunwinds in order to preserve eh-frames. While LLJIT was already doing this as of eae6d6d18bd, MachOPlatform was not. This was causing buildbot failures in the ORC runtime (e.g. in https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/3479/). This patch updates both LLJIT and MachOPlatform to check a bootstrap value, "darwin-use-ehframes-only", to determine whether to forcibly preserve eh-frame sections. If this value is present and set to true then compact-unwind sections will be discarded, causing eh-frames to be preserved. If the value is absent or set to false then compact-unwind will be used and redundant FDEs in eh-frames discarded (FDEs that are needed by the compact-unwind section are always preserved). rdar://143895614
2025-02-07[ORC] Add a FIXME. NFC.Lang Hames1-0/+3
2025-02-06[JITLink] Add a jitlink::Symbol::getSection() convenience method.Lang Hames3-3/+3
`Sym.getSection()` is equivalent to `Sym.getBlock().getSection()`.
2025-02-05Re-reapply "[ORC] Enable JIT support for the compact-unwind..." with fixes.Lang Hames11-21/+510
Re-enables compact-unwind support in JITLink, which was reverted in b04847b427d due to buildbot failures. The underlying cause for the failures on the buildbots was the lack of compact-unwind registration support on older Darwin OSes. Since the CompactUnwindManager pass now removes eh-frames by default we were left with unwind-info that could not be registered. On x86-64, where eh-frame info is produced by default the solution is to fall back to using eh-frames. On arm64 we simply can't support exceptions on older OSes. This patch updates the EHFrameRegistrationPlugin to remove the compact-unwind section (__LD,__compact_unwind) when installed, forcing use of eh-frames when the EHFrameRegistrationPlugin is used. In LLJIT, the EHFrameRegistrationPlugin continues to be used for all non-Darwin platform, and will be added on Darwin platforms when the a CompactUnwindRegistrationPlugin instance can't be created (e.g. due to missing support for compact-unwind info registration). The lit.cfg.py script is updated to check whether the host OSes default unwind info supports JIT registration, allowing tests to be disabled for older Darwin OSes on arm64.
2025-02-05[ORC] Moch MachOPlatform unwind-info fixes.Lang Hames1-31/+11
Some eh-frame records are CIEs, which don't point to functions. We need to skip these records. This patch reuses EHFrameCFIBlockInspector to identify function targets, rather than a custom loop. Any performance impact will be minimal, and essentially irrelevant once compact-unwind support re-lands (since at that point we'll discard most eh-frame records). For unwind-info sections: don't assume one block per record: the unwind-info section packs all records into a single block.
2025-02-05[ORC] Add note to call endSession to assertion messages.Lang Hames2-2/+8
The most likely cause of these assertions is a failure to call endSession. The new message should clients spot the issue more easily.
2025-02-05[ORC] Fix eh-frame record target finding in MachOPlatform.Lang Hames1-13/+44
Unwind-info records only have one keep-alive edge to their target function, but eh-frame records may have multiple edges (to the CIE, function, personality, and lsda). We need to identify the target-function edge differently for each section type.
2025-02-05[ORC] Rename MachOCompactUnwindSectionName to MachOUnwindInfoSectionName.Lang Hames2-2/+2
a1ff2d18466 should have disambiguated MachOCompactUnwindInfoSectionName to MachOUnwindInfoSectionName, given how it's used in MachOPlatform and its value. A MachOCompactUnwindSectionName variable with an appropriate value will be added in an upcoming patch to re-enable compact-unwind support in JITLink.
2025-02-04Fix build if ITTAPI_SOURCE_DIR is specified (#106924)Zentrik1-1/+4
de92615d68f allows specifying the source directory of ittapi. This change allows configuring the source directory of ittapi here as well.
2025-02-03[ORC] Drop 'Info' from MachOCompactUnwindInfoSectionName.Lang Hames2-3/+2
Rename MachOCompactUnwindInfoSectionName to MachOCompactUnwindSectionName. Background: There are two related sections used for compact-unwind info processing: __LD,__compact_unwind -- the input table stored in relocatable object formats, and __TEXT,__unwind_info -- the compressed table produced by the linker and consumed by libunwind. To keep the distinction clear we'll use *CompactUnwind* for names that refer to the __LD,__compact_unwind input tables and *UnwindInfo* for names that refer to the __TEXT,__unwind_info output tables. Dropping 'Info' from the variable above clarifies which section it refers to.
2025-02-03[ORC] Fix file comment formatting. NFC.Lang Hames1-2/+1
2025-01-30Revert "Reapply "[ORC] Enable JIT support for the compact-unwind frame..." ↵Ben Langmuir9-496/+19
with fixes." (#125098) This reverts commit d6524c8dfa37634257050ca71d16e117b802181c. This reverts commit b1bd73700a1fb6f450e0f6f9c405a9c8bde2cae7. This was causing bot failures on Darwin https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-cmake-RA-incremental/7315/ Clang.Interpreter.simple-exception.cpp Clang-Unit.Interpreter/ExceptionTests/_/ClangReplInterpreterExceptionTests/0.1 LLVM.ExecutionEngine/OrcLazy.minimal-throw-catch.ll https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/3415/ ORC-x86_64-darwin.TestCases/Darwin/Generic.exceptions.cpp ORC-x86_64-darwin.TestCases/Darwin/x86-64.lljit-ehframe.cpp
2025-01-30[ORC] Add missing files from d6524c8dfa3.Lang Hames2-0/+426
2025-01-30Reapply "[ORC] Enable JIT support for the compact-unwind frame..." with fixes.Lang Hames7-19/+70
This reapplies 4f0325873fa (and follow up patches 26fc07d5d88, a001cc0e6cdc, c9bc242e387, and fd174f0ff3e), which were reverted in 212cdc9a377 to investigate bot failures (e.g. https://lab.llvm.org/buildbot/#/builders/108/builds/8502) The fix to address the bot failures was landed in d0052ebbe2e. This patch also restricts construction of the UnwindInfoManager object to Apple platforms (as it won't be used on other platforms).
2025-01-29[ORC][LLJIT] Install eh-frame registration plugin during platform setup.Lang Hames1-8/+11
Attempt to install the EHFrameRegistrationPlugin during GenericLLVMIRPlatform setup, rather than object linking layer creation time. Platform classes are responsible for exception handling: installing the plugin unconditionally during linking-layer construction could result in frames being registered more than once when native platform classes are used. This is a precursor to re-landing compact unwind support (4f0325873fa).
2025-01-24Revert "[ORC] Enable JIT support for the compact-unwind frame info format..."Lang Hames9-497/+21
This reverts 4f0325873faccfbe171bae4babceb65975ca892e and follow-up patches (see below) while I investigate some ongoing failures on the buildbots. --- Revert "[clang-repl] Try to XFAIL testcase on arm32 without affecting arm64 darwin." This reverts commit fd174f0ff3e793fe96a6663b1488ed159cfe042f. Revert "[clang-repl] The simple-exception test now passes on arm64-darwin." This reverts commit c9bc242e387f4a4a3dfcd86561f3ec0ca8a72d62. Revert "[ORC] Destroy defunct MaterializationUnits outside the session lock." This reverts commit a001cc0e6cdcfa672b8aff9ce6d14782bb96356a. Revert "[ORC] Add explicit narrowing casts to fix build errors." This reverts commit 26fc07d5d88760ad659599184fd10181287d2d9e. Revert "[ORC] Enable JIT support for the compact-unwind frame info format on Darwin." This reverts commit 4f0325873faccfbe171bae4babceb65975ca892e.
2025-01-24[ORC] Destroy defunct MaterializationUnits outside the session lock.Lang Hames1-13/+21
MaterializationUnits may contain arbitrary resources that need cleanup. We want to do this outside the JIT's session lock. This should fix a lock-order-inversion warning in clang-repl (for details see https://github.com/llvm/llvm-project/issues/124215).
2025-01-23[ORC] Add explicit narrowing casts to fix build errors.Lang Hames1-2/+5
This should fix the compile errors seen in https://lab.llvm.org/buildbot/#/builders/154/builds/10779.
2025-01-23[ORC] Enable JIT support for the compact-unwind frame info format on Darwin.Lang Hames8-8/+473
For Darwin/arm64 (including Apple Silicon Macs) this will enable exception handling and stack unwinding in JIT'd code. Darwin supports two unwind-info formats: DWARF eh-frames and compact-unwind. On Darwin/x86-64 compilers usually produce both by default, and ORC supported exceptions and unwinding via eh-frames (same as on Linux), discarding the redundant compact-unwind info. On Darwin/arm64 compilers typically default to producing compact-unwind only, with DWARF eh-frames as a fallback for functions that can't be described in compact-unwind. Since ORC did not previously support the compact-unwind format and eh-frames were not present ORC was unable to handle exceptions or unwinding by default in Darwin/arm64 JIT'd code. This patch enables support for the compact-unwind-info format, and contains three major moving parts: (1) The JITLink CompactUnwindManager class is responsible for transforming the __compact_unwind records produced by the linker into the __unwind_info tables that libunwind parses during unwinding. To enable this the CompactUnwindManager class provides three JITLink passes: The prepareForPrune pass that splits the __compact_unwind section into single-record blocks, allowing unused records to be dead-stripped; the processAndReserveUnwindInfo pass that reserves space for the final __unwind_info section, and the writeUnwindInfo pass that writes the __unwind_info section. (2) The OrcTargetProcess UnwindInfoManager class maintains a table of registered JIT'd __unwind_info and __eh_frame sections, and handles requests from libunwind for unwind info sections (by registering a callback with libunwind's __unw_add_find_dynamic_unwind_sections function). (3) The Orc UnwindInfoRegistrationPlugin, which scans LinkGraphs for __unwind_info and __eh_frame sections to register with the UnwindInfoManager. This commit adds the CompactUnwindManager passes to the default JITLink pipelines for Darwin/arm64 and Darwin/x86-64, and UnwindInfoManager intances to the SelfExecutorProcessControl class (when built for apple platforms) and the llvm-jitlink-executor tool. The LLJIT class will now create an UnwindInfoRegistrationPlugin when targeting a process running on Darwin if it detects that an UnwindInfoManager is available to handle the registrations. The ORC runtime macho_platform class already supported libunwind callbacks, so out-of-process execution and unwinding support will work when loading the ORC runtime. The llvm-jitlink tool will only support compact-unwind when the orc-runtime is loaded, as the UnwindInfoRegistrationPlugin requires access to an IR compiler to load a helper module and llvm-jitlink does not provide an IR compiler.
2025-01-23[ExecutionEngine] Include <map> (#124083)Kazu Hirata1-0/+1
This patch reinstates an include of <map>, fixing a build failure caused by: commit 1f4d91ecb8529678a3d3919d7523743bd21942ca Author: Kazu Hirata <kazu@google.com> Date: Tue Nov 19 19:41:59 2024 -0800 [ExecutionEngine] Remove unused includes (NFC) (#116749) --------- Co-authored-by: h-vetinari <h.vetinari@gmx.com>
2025-01-23[IR] Replace of PointerType::getUnqual(Type) with opaque version (NFC) (#123909)Mats Jun Larsen1-7/+3
Follow up to https://github.com/llvm/llvm-project/issues/123569
2025-01-22[ORC][MachO] Prepare MachOPlatform for compact-unwind support.Lang Hames1-20/+28
The MachOPlatform::MachOPlatformPlugin class will now inject a "__jitlink$libunwind_dso_base" symbol into each LinkGraph pointing to the Mach header for the containing JITDylib. The compact-unwind support plugin will use this symbol as the dso-base for the __unwind_info sections. (Failure to inject this symbol would result in the compact-unwind support plugin creating a new header for every graph).
2025-01-22[ORC] Simplify error return. NFC.Lang Hames1-5/+2
2025-01-21[ORC-RT][LoongArch] Add initial support for loongarch64 in ELFNixPlatform ↵Ami-zhang1-0/+5
(#123575) Enable ELFNixPlatform support for loongarch64. These are few simple changes, but it allows us to use the orc runtime in ELF/LoongArch64 backend. This change adds test cases targeting the LoongArch64 Linux platform to the ORC runtime integration test suite. Since jitlink for loongarch64 is ready for general use, and ELF-based platforms support defining multiple static initializer table sections with differing priorities, some relevant test cases in compiler-rt for ELFNixPlatform support can be enabled.
2025-01-21[IR] Replace of PointerType::get(Type) with opaque version (NFC) (#123617)Mats Jun Larsen1-2/+2
In accordance with https://github.com/llvm/llvm-project/issues/123569 In order to keep the patch at reasonable size, this PR only covers for the llvm subproject, unittests excluded.
2025-01-20[ORC] Move EHFrameRegistrationPlugin into its own header + source file. NFC.Lang Hames4-96/+117
2025-01-20Fix typo in commentLang Hames1-1/+1
2025-01-20[ORC] Add BinaryFormat dependence to the LLVMOrcDebugging library.Lang Hames1-0/+1
This is needed as of 630139460ea7 for MachO::getCPUType and MachO::getCPUSubType.