aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/Orc
AgeCommit message (Collapse)AuthorFilesLines
2024-01-23[Orc] Let LLJIT default to JITLink for ELF-based ARM targets (#77313)Stefan Gränitz1-0/+6
The JITLink AArch32 backend reached feature-parity with RuntimeDyld on ELF-based systems. This patch changes the default JIT-linker in Orc's LLJIT for these platforms. This allows us to run clang-repl with JITLink on ARM and use all the features we had with RuntimeDyld before. All existing tests for clang-repl are passing.
2024-01-19[llvm] Use SmallString::operator std::string (NFC)Kazu Hirata1-1/+1
2024-01-18[ORC][MachO] Support common load commands in the platform's mach-o header ↵Ben Langmuir1-19/+41
builder Add a HeaderOptions struct that can be used to configure commonly-used load commands LC_ID_DYLIB, LC_LOAD_DYLIB, and LC_RPATH when setupDylib creates a mach-o header.
2024-01-05[ORC] Add absoluteSymbolsLinkGraph to expose absolute symbols to platform ↵Ben Langmuir4-11/+29
(#77008) Adds a function to create a LinkGraph of absolute symbols, and a callback in dynamic library search generators to enable using it to expose its symbols to the platform/orc runtime. This allows e.g. using __orc_rt_run_program to run a precompiled function that was found via dlsym. Ideally we would use this in llvm-jitlink's own search generator, but it will require more work to align with the Process/Platform JITDylib split, so not handled here. As part of this change we need to handle LinkGraphs that only have absolute symbols.
2024-01-04[ORC] Refactor executor symbol lookup to use ExecutorSymbolDef (NFC) (#76989)Ben Langmuir6-14/+20
This migrates the dylib manager lookup and related APIs to replace ExecutorAddress with ExecutorSymbolDef so that in the future we can model JITSymbolFlags for these symbols. The current change should be NFC as we are only setting the Exported symbol flag.
2024-01-03[Orc] Deduplicate GDB JIT Interface declarations (NFC) (#76373)Stefan Gränitz1-23/+0
https://github.com/llvm/llvm-project/pull/76236 introduced the forth copy and it was time to deduplicate. This patch brings it back to 2, one in OrcTargetProcess and one in legacy ExecutionEngine.
2024-01-01[Orc] Fix process-symbols setup in LLJITBuilder for out-of-process case (#76244)Stefan Gränitz1-3/+3
For out-of-process support the DynamicLibrarySearchGenerator must go through EPC, otherwise we lookup symbols from the host and not the target process.
2023-12-25[llvm] Use StringRef::consume_front (NFC)Kazu Hirata1-2/+1
2023-12-11[llvm] Use StringRef::{starts,ends}_with (NFC) (#74956)Kazu Hirata7-10/+10
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
2023-12-11[ORC][LLJIT] Expose ORCPlatformSupport to aid custom native Platform setup.Lang Hames1-59/+48
LLJIT users may want to customize their native platform setup beyond what the ExecutorNativePlatform helper permits. In this case LLJIT users can construct the platform instance manually, and then add an ORCPlatformSupport instance to forward initialize/deinitialize operations to the ORC runtime.
2023-12-11[ORC][MachO] Expose SimpleMachOHeaderMU and related utilities.Lang Hames1-103/+93
SimpleMachOHeaderMU can be used as a convenient base for classes that create custom MachO headers. Instances of these custom classes can be used by passing a MachOHeaderMUBuilder using the MachOPlatform extensions added in ef314d39b92.
2023-12-11[llvm-c] Expose debug support for LLJIT in Orc C-API bindings (#73257)Stefan Gränitz3-1/+24
Allow C-API users to debug their JITed code via the GDB JIT Interface. This is currently supported on ELF and MachO based platforms. On other systems `LLVMOrcLLJITEnableDebugSupport()` returns an error. This patch adds a new C-API header `LLJITUtils.h`, which can host further advanced JIT features in the future. Using the header requires linking against LLVMOrcDebugging.
2023-12-11[ORC][MachO] Enable customization of MachO-headers produced by MachOPlatform.Lang Hames1-9/+21
MachOPlatform users can now override the default MachO header graph produced for JITDylibs when setupJITDylib is called.
2023-12-07[ORC-RT][ORC][MachO] Fix some issues with executor-side symbol tables.Lang Hames1-17/+36
1. Prevent deadlock by unlocking JDStatesMutex when calling back to the controller to request a push of new symbols. (If JDStatesMutex is locked then the push operation can't register the new symbols, and so can't complete). 2. Record MachOPlatform runtime symbols during bootstrap and attach their registration to the bootstrap-completion graph, similar to the way that deferred allocation actions are handled. We can't register the symbols the normal way during bootstrap since the symbol registration function is itself in the process of being materialized. 3. Add dlsym testcases to exercise these fixes.
2023-12-06[ORC] Use dyn_cast to check input type in StaticLibraryDefinitionGenerator.Lang Hames1-2/+2
Replaces an llvm::cast that assumed that all Binary instances were either Archive or MachOUniversalBinary instances with a dyn_cast. The cast was triggering an assert in StaticLibraryDefinitionGenerator::Load if that method was given a path or MemoryBuffer containing a relocatable object file. Switching to dyn_cast causes the operation to error out with a bad-format error as expected. Fixes rdar://119262300
2023-12-04[ORC][MachO] Fix JITDylib header-addr tracking in MachOPlatform.Lang Hames1-25/+35
HeaderAddr shouldn't be a member variable of MachOPlatformPlugin: there's only one plugin instance shared between all JITDylibs, so the shared HeaderAddr will be overwritten in an unpredictable and unsafe way. We haven't seen any issues due to this yet, but it triggered failures during testing of an upcoming llvm-jitlink patch (e.g. ORC-RT test Darwin/x86-64/jit-re-dlopen-trivial.S). This patch pre-fixes the issue in advance of the llvm-jitlink patch landing. This patch also removes some stale debugging output in MachOPlatform.
2023-12-03[llvm] Stop including map (NFC)Kazu Hirata1-2/+0
Identified with clangd.
2023-12-02[ORC-RT][ORC][MachO] Add executor-side symbol tables to MachO platform support.Lang Hames2-52/+184
Adds symbol tables to the JITDylibState struct in the ORC runtime MachOPlatformRuntimeState class. This table will hold the addresses of materialized symbols (registered by a new JITLink pass in MachOPlatform), allowing these to be looked up in the executor without an IPC request to the controller. The old lookup-symbols callback (made by the runtime in response to dlsym lookups) is replaced with a push-symbols callback that can trigger materialization of requested symbols. Holding a symbol table on the executor side should make repeat calls to dlsym (and other symbol lookup operations) cheaper since the IPC to trigger materialization happens at most once per symbol. It should also enable us (at some point in the future) to symbolicate backtraces in JIT'd code even if the controller process is gone (e.g. detached or crashed). The trade-off for this is increased memory consumption in the executor and larger JIT'd data transfers (since symbol names are now transferred to the executor unconditionally, even though they may never be used).
2023-11-30[llvm] Stop including llvm/ADT/StringSet.h (NFC)Kazu Hirata1-1/+0
Identified with clangd.
2023-11-27[ORC] Add a public unsafe-operations helper for SymbolStringPtr.Lang Hames1-63/+31
SymbolStringPoolEntryUnsafe provides unsafe access to SymbolStringPtr objects, allowing clients to manually retain and release pool entries, or consume or create SymbolStringPtr instances without affecting an entry's ref-count. This can be useful when writing C APIs that need to handle SymbolStringPtrs. As part of this patch the LLVM-C API implementation is updated to use the new utility, rather than the old, private OrcV2CAPIHelper utility.
2023-11-16[ORC] Fix some typos in comments in MachOPlatform.Lang Hames1-3/+3
2023-11-11[llvm] Stop including llvm/ADT/SmallPtrSet.h (NFC)Kazu Hirata1-1/+0
Identified with clangd.
2023-11-03[orc][mach-o] Fix mixing objc and swift code in a single JITDylib (#69258)Ben Langmuir1-4/+107
The system linker merges __objc_imageinfo flags values to select a compatible set of flags using the minimum swift version and only erroring on incompatible ABIs. Match that behaviour in the orc macho platform. One wrinkle is that the JIT can add new objects after the dylib is running code. In that case we only check for known incompatible flags and ignore the swift version. It's too late to change the flags at that point and swift version is unlikely to change runtime behaviour in practice.
2023-10-20[ExecutionEngine] Use llvm::is_contained (NFC)Kazu Hirata1-1/+1
2023-10-12Use llvm::endianness::{big,little,native} (NFC)Kazu Hirata2-4/+5
Note that llvm::support::endianness has been renamed to llvm::endianness while becoming an enum class as opposed to an enum. This patch replaces support::{big,little,native} with llvm::endianness::{big,little,native}.
2023-10-10Use llvm::endianness (NFC)Kazu Hirata5-5/+5
Now that llvm::support::endianness has been renamed to llvm::endianness, we can use the shorter form. This patch replaces support::endianness with llvm::endianness.
2023-10-10[llvm] Use llvm::endianness::{big,little,native} (NFC)Kazu Hirata5-14/+14
Now that llvm::support::endianness has been renamed to llvm::endianness, we can use the shorter form. This patch replaces support::endianness::{big,little,native} with llvm::endianness::{big,little,native}.
2023-10-05[Support] Deprecate system_endianness (#68279)Kazu Hirata1-2/+2
system_endianness() just returns llvm::endianness::native, a compile-time constant equivalent to std::native in C++20. This patch deprecates system_endianness() while replacing all invocations of system_endianness() with llvm::endianness::native. While we are at it, this patch replaces llvm::support::endianness::{big,little} with llvm::endianness::{big,little} in those statements that happen to call system_endianness(). It does not go out of its way to replace other occurrences of llvm::support::endianness::{big,little}.
2023-10-05[llvm] Replace uses of Type::getPointerTo (NFC)JOE19941-1/+1
opaque pointer clean-up effort (NFC)
2023-10-01[ExecutionEngine] Fix the call to DWARFContext::createKazu Hirata1-1/+5
Without this patch, we pass G.getEndianness() as one of the parameters to DWARFContext::create. The problem is that G.getEndianness() is of: enum endianness {big, little, native}; whereas DWARFContext::create is expecting "bool isLittleEndian". That is, we are relying on an implicit conversion to convert big and little to false and true, respectively. When we migrate llvm::support::endianness to std::endian in future, we can no longer rely on an implicit conversion because std::endian is declared with "enum class". Even if we could, the conversion would not be guaranteed to work because, for example, libcxx defines: enum class endian { little = 0xDEAD, big = 0xFACE, : where big and little are not boolean values. This patch fixes the problem by properly converting G.getEndianness() to a boolean value.
2023-09-29[ORC] Fix heap-use-after-free error in MachODebugObjectSynthesizer.cppMogball1-10/+8
At line 191, `addSymbol` takes the name by reference but does not make an internal copy to the string, meaning the local `optional<std::string>` would get freed and leave Orc with a dangling pointer. Fix this by just using an `optional<StringRef>` instead.
2023-09-29[llvm] Use more explicit cast methods (NFC)Nikita Popov1-2/+1
Instead of ConstantExpr::getCast() with a fixed opcode, use the corresponding getXYZ methods instead. For the one place creating a pointer bitcast drop it entirely, as this is redundant with opaque pointers.
2023-09-28[ORC] Add JITLink to dependencies of OrcDebugging.Lang Hames1-0/+1
The OrcDebugging library depends on JITLink after b2518971d82.
2023-09-28Re-apply "[ORC] Add N_SO and N_OSO stabs entries to MachO debug..." with fixes.Lang Hames4-8/+67
This re-applies db51e572893, which was reverted in 05b1a2cb3e6 due to bot failures. The DebuggerSupportPlugin now depends on DWARF, so it has been moved to the new OrcDebugging library (as has the enableDebuggerSupport API).
2023-09-28[ORC] Add DWARFContext generation from LinkGraphs, use in perf support.Prem Chintalapudi4-24/+172
This patch adds line numbers to perf jitdump records emitted by the PerfSupportPlugin, by parsing and using a DWARFContext from preserved debug sections. To avoid making the OrcJIT library depend on DebugInfoDWARF this patch introduces a new OrcDebugging library. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D146391
2023-09-28[ORC] Rename MemLifetimePolicy to MemLifetime.Lang Hames2-3/+3
The *Policy suffix came from the earlier MemAllocPolicy type, where it was included to distinguish the type from a memory-allocation operation. MemLifetime is a noun already, so the *Policy suffix is just dead weight now.
2023-09-27Re-apply "[ORC][LLJIT] Move enable-debugger-support utility out of..."Lang Hames3-54/+64
This re-applies e1a5bb59b91, which was reverted in e5f169f91a8 due to LSan failures on some bots (see https://github.com/llvm/llvm-project/issues/67586). The LSan failures were not caused by this patch (just exposed by it), so LSan was disabled for the failing test in 47625fea5e3. This should be safe to re-land now.
2023-09-23Use llvm::find (NFC)Kazu Hirata1-3/+1
2023-09-22Revert "[ORC][LLJIT] Move enable-debugger-support utility out of LLJITBuilder."Lang Hames3-64/+54
This reverts commit e1a5bb59b91d60c0d87feb78f0e0614589a4c927 while I investigate the bot failure at https://lab.llvm.org/buildbot/#/builders/168/builds/15831
2023-09-22[ORC][LLJIT] Move enable-debugger-support utility out of LLJITBuilder.Lang Hames3-54/+64
This change means that debugger support only needs to be linked in if it's used. The code size of debugger support is expected to increase as we improve it (e.g. pulling in DWARF parsing), so making it an optional extra is useful for controlling final binary sizes.
2023-09-22[ORC][LLJIT] Fix typo in assert message.Lang Hames1-1/+1
2023-09-22[ORC][LLJIT] Add a Pre-PlatformSetup-Setup function.Lang Hames1-0/+7
This function will be run prior to platform setup to provide LLJIT clients with a chance to customize the LLJIT instance (e.g. install plugins) before the JIT runtime is loaded. The motivating use-case is debugger support: We want to install the debugger plugin before the runtime is loaded (during platform setup) so that the runtime itself can be debugged. A patch to do this will be committed shortly.
2023-09-22Revert "[ORC] Add N_SO and N_OSO stabs entries to MachO debug objects."Lang Hames1-49/+3
This reverts commit db51e572893e9e4403d65920dc5e87a8885b059c. Reverted while I investigate build failures, e.g. https://lab.llvm.org/buildbot/#/builders/234/builds/12900
2023-09-22[ORC] Add N_SO and N_OSO stabs entries to MachO debug objects.Lang Hames1-3/+49
No testcase: This code generates an in-memory object file that is shared with the debugger. The object file is malformed in ways that don't matter to the debugger, but mean that it can't be inspected by most tools.
2023-09-20[ORC] Add writePointers to ExecutorProcessControl's MemoryAccessSunho Kim1-7/+21
Add pointer write functionality to MemoryAccess that is needed for implementing redirection manager. It also refactors the code a bit by introducing InProcessMemoryAccess class. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D157378
2023-09-18[ORC] Fix -Wunused-but-set-variable in JITLoaderPerf.cpp (NFC)Jie Fu1-1/+1
/data/llvm-project/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp:118:10: error: variable 'Written' set but not used [-Werror,-Wunused-but-set-variable] size_t Written = 0; ^ 1 error generated.
2023-09-18[ORC][JITLink] Non-debuginfo JITLink perf jitdump support.Prem Chintalapudi4-0/+756
This patch ports PerfJITEventListener to a JITLink plugin, but adds unwind record support and drops debuginfo support temporarily. Debuginfo can be enabled in the future by providing a way to obtain a DWARFContext from a LinkGraph. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D146169
2023-09-18[JITLink][PowerPC][RFC] Make JITLink default in LLJIT for ppc64 elfv2abiKai Luo1-0/+6
JITLink for ppc64 has implemented all relocations implemented in rtdyld for ppc64 and has passed all existed lit tests and unittests in llvm/clang/compiler-rt. I propose making JITLink for ppc64 default in LLJIT. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D159175
2023-09-14[NFC][CodeGen] Change CodeGenOpt::Level/CodeGenFileType into enum classes ↵Arthur Eubanks1-4/+4
(#66295) This will make it easy for callers to see issues with and fix up calls to createTargetMachine after a future change to the params of TargetMachine. This matches other nearby enums. For downstream users, this should be a fairly straightforward replacement, e.g. s/CodeGenOpt::Aggressive/CodeGenOptLevel::Aggressive or s/CGFT_/CodeGenFileType::
2023-09-11Re-apply 75c487602a "[ORC] Add a MachOBuilder utility, use it to..." with fixes.Lang Hames1-225/+116
This re-applies 75c487602a8 ([ORC] Add a MachOBuilder utility, use it to build MachO debug objects), which was reverted in 99e70cc3a5 due to build failures. The MachoBuilder class has been refactored to fix the errors.