4034 Commits

Author SHA1 Message Date
Kazu Hirata
4eed68357e
[llvm] Use "= default" (NFC) (#166088)
Identified with modernize-use-equals-default.
2025-11-02 17:16:47 -08:00
SahilPatidar
605a7d6534
REAPPLY [ORC] Add automatic shared library resolver for unresolved symbols. (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-11-01 11:19:28 +05:30
Kazu Hirata
817aff6960
[llvm] Use nullptr instead of 0 or NULL (NFC) (#165396)
Identified with modernize-use-nullptr.
2025-10-28 16:15:01 -07:00
Jordan Rupprecht
f58aa0ec8b
[ORC] Fix race when checking isComplete (#165063)
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.
2025-10-25 07:49:02 -04:00
SahilPatidar
2afbd3df2a
Revert "REAPPLY [ORC] Add automatic shared library resolver for unresolved symbols. #148410" (#165069)
Reverting llvm/llvm-project#164551 due to persistent build bot failure
caused by a path difference issue.
2025-10-25 10:23:46 +05:30
SahilPatidar
4f53413ff0
REAPPLY [ORC] Add automatic shared library resolver for unresolved symbols. #148410 (#164551)
This PR reapplies the changes previously introduced in #148410.
It introduces a redesigned and rebuilt Cling-based auto-loading
workaround that enables scanning libraries and resolving unresolved
symbols within those libraries.
2025-10-24 15:13:29 +05:30
Kazu Hirata
c5f1c694ac
[ExecutionEngine] Add "override" where appropriate (NFC) (#164757)
Note that "override" makes "virtual" redundant.

Identified with modernize-use-override.
2025-10-23 07:09:03 -07:00
Lang Hames
9173846640
Reapply "[ORC] Replace ORC's baked-in dependence ... (#163027)" with … (#164340)
…fixes.

This reapplies c8c86efbbb5, which was reverted in 13ca8723d1b due to bot
failures. Those failures were compilation errors exposed when LLVM is
built with LLVM_ENABLE_EXPENSIVE_CHECKS=On. They have been fixed in this
commit.
2025-10-20 17:40:01 -07:00
Lang Hames
13ca8723d1 Revert "[ORC] Replace ORC's baked-in dependence tracking ... (#163027)"
Reverts commit c8c86efbbb55e51597c1bd8feb2e947bc0de3422 while I investigate bot
failures, e.g. https://lab.llvm.org/buildbot/#/builders/187/builds/12743.
2025-10-20 16:20:37 -07:00
Lang Hames
c8c86efbbb
[ORC] Replace ORC's baked-in dependence tracking with WaitingOnGraph. (#163027)
WaitingOnGraph tracks waiting-on relationships between nodes (intended
to represent symbols in an ORC program) in order to identify nodes that
are *Ready* (i.e. are not waiting on any other nodes) or have *Failed*
(are waiting on some node that cannot be produced).

WaitingOnGraph replaces ORC's baked-in data structures that were
tracking the same information (EmissionDepUnit, EmissionDepUnitInfo,
...). Isolating this information in a separate data structure simplifies
the code, allows us to unit test it, and simplifies performance testing.

The WaitingOnGraph uses several techniques to improve performance
relative to the old data structures, including symbol coalescing
("SuperNodes") and symbol keys that don't perform unnecessary reference
counting (NonOwningSymbolStringPtr).

This commit includes unit tests for common dependence-tracking issues
that have led to ORC bugs in the past.
2025-10-20 15:59:56 -07:00
SahilPatidar
8db1aabf8b
Revert "[ORC] Add automatic shared library resolver for unresolved symbols." (#163943)
Reverts llvm/llvm-project#148410

Reverting this change due to a few buildbot/test failures. Will
investigate and reapply once the issues are resolved.
2025-10-17 13:47:10 +02:00
SahilPatidar
1e7a23f822
[ORC] Add automatic shared library resolver for unresolved symbols. (#148410)
This PR introduces a redesigned and rebuilt Cling-based auto-loading
workaround, which enables scanning libraries and searching for
unresolved symbols within the scanned libraries.
2025-10-17 16:23:31 +05:30
Lang Hames
9c456e5eb7
[ORC] Add SimpleRemoteMemoryMapper (new MemoryMapper implementation). (#163707)
SimpleRemoteMemoryMapper is a MemoryMapper implementation that manages
remote memory via EPC-calls to reserve, initialize, deinitialize, and
release operations. It is compatible with the
SimpleExecutorMemoryManager backend, and its introduction allows
MapperJITLinkMemoryManager to use this backend.

It is also intended to be compatible with the
orc_rt::SimpleNativeMemoryMap backend.
2025-10-16 18:57:48 +11:00
Lang Hames
4374ca3cab
[ORC] Align ExecutorSimpleMemoryManager w/ orc_rt::SimpleNativeMemoryMap (#163693)
Teach ExecutorSimpleMemoryManager to handle slab reserve/release
operations, plus separate initialize/deinitialize for regions within the
slab. The release operation automatically deinitializes any regions
within each slab that have not already been released.

EPCGenericJITLinkMemoryManager is updated to use the reserve (allocate),
initialize (finalize), and relesae (deallocate) operations.

This brings ExecutorSimpleMemoryManager into alignment with the
orc_rt::SimpleNativeMemoryMap class, allowing SimpleNativeMemoryMap to
be used as a backend for EPCGenericJITLinkMemoryManager.

A future commit will introduce a new MemoryMapper class that will make
SimpleNativeMemoryMap usable as a backend for
MapperJITLinkMemoryManager.

This work will make it easier to re-use in-tree APIs and tools with the
new ORC runtime.
2025-10-16 16:08:23 +11:00
Lang Hames
8b60c05a7e
Revert "[ORC] Make runAllocActions and runDeallocActions asynchorous." (#163480)
This reverts commit 3b5842c9c41a441280100045ef62bb8a0fe7200f.

The intent of the original commit was to begin enabling asynchronous
alloation actions (calls attached to JIT'd memory initialization and
deinitialization). The asynchronous allocation actions scheme was
fleshed-out in a development branch, but ran into an issue: Functions
implementing actions are allowed to live in JIT'd code (e.g. in the ORC
runtime), but we can't genally rely on tail-call elimination kicking in.
This resulting in dealloc actions returning via stack frames that had
been deallocated, triggering segfaults.

It's possible that there are other approaches that would allow
asynchronous allocation actions to work, but they're not on the critical
path for JIT improvements so for now we'll just revert.
2025-10-15 12:21:28 +11:00
Lang Hames
2db5b326e1
[ORC] Add LinkGraph& argument to MemoryMapper::prepare. (#163121)
This gives MemoryMapper implementations a chance to allocate working
memory using the LinkGraph's allocator.
2025-10-13 17:20:39 +11:00
SahilPatidar
bb36630ecd
[ORC][Runtime] Add dlupdate for coff (#115448)
With the help of @lhames, This pull request introduces the dlupdate
function in the ORC runtime. dlupdate enables incremental execution of
new initializers introduced in the REPL environment. Unlike traditional
dlopen, which manages initializers, code mapping, and library reference
counts, dlupdate focuses exclusively on running new initializers.
2025-10-08 17:15:44 +05:30
SahilPatidar
e05d80ec7b
[ORC] Add Executor Resolver Utility (#143654)
This patch adds the new **executor-side resolver API** as suggested by
@lhames. It introduces a `DylibSymbolResolver` that helps resolve
symbols for each loaded dylib.

Previously, we returned a `DylibHandle` to the controller. Now, we wrap
the native handle inside `DylibSymbolResolver` and return a
`ResolverHandle` instead. This makes the code cleaner and separates the
symbol resolution logic from raw handle management.
2025-10-07 11:52:53 +05:30
Lang Hames
a7016c43da
[JITLink] Add LinkGraph name / triple to debugging output. (#161772)
Adds the name and triple of the graph to LinkGraph::dump output before
the rest of the graph content. Calls from JITLinkGeneric.cpp to dump the
graph are updated to avoid redundantly naming the graph.
2025-10-03 15:24:29 +10:00
Lang Hames
f29f1112f5 [JITLink][MachO] Use Triple::isArm64e consistently. 2025-10-01 11:07:37 +10:00
wanglei
6b23f4fc4d
[LoongArch] Add R_LARCH_MARK_LA relocation for la.abs
Match gas behavior: generate `R_LARCH_MARK_LA` relocation for `la.abs`.

Reviewers: heiher, SixWeining

Reviewed By: SixWeining, heiher

Pull Request: https://github.com/llvm/llvm-project/pull/161062
2025-09-30 09:58:12 +08:00
Kazu Hirata
84a796d7dd
[ExecutionEngine] Use std::tie for a lexicographical comparison (NFC) (#160007) 2025-09-21 19:17:05 -07:00
Zhijin Zeng
7a58e77143
[JITLink][RISC-V] Support R_RISCV_SET_ULEB128/R_RISCV_SUB_ULEB128 (#153778)
Support bolt instrument the elf binary which has exception handling table.

Fixes #153775
2025-09-09 17:51:30 +08:00
Matt Arsenault
819aa3521e
MC: Use Triple form of lookupTarget in more places (#157591) 2025-09-09 16:33:39 +09:00
Matt Arsenault
67823469bd
MC: Add Triple overloads for more MC constructors (#157321)
Avoids more Triple->string->Triple round trip. This
is a continuation of f137c3d592e96330e450a8fd63ef7e8877fc1908
2025-09-08 03:41:22 +00:00
Kazu Hirata
11b4f110e0
[llvm] Remove unused includes of SmallSet.h (NFC) (#154893)
We just replaced SmallSet<T *, N> with SmallPtrSet<T *, N>, bypassing
the redirection found in SmallSet.h.  With that, we no longer need to
include SmallSet.h in many files.
2025-08-22 10:33:46 -07:00
Kazu Hirata
3248fba497
[ExecutionEngine] Remove an unnecessary cast (NFC) (#154890)
getTargetFlags() already returns TargetFlagsType.
2025-08-22 10:33:31 -07:00
Kazu Hirata
07eb7b7692
[llvm] Replace SmallSet with SmallPtrSet (NFC) (#154068)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 140 instances that rely on this "redirection", with the
vast majority of them under llvm/. Since relying on the redirection
doesn't improve readability, this patch replaces SmallSet with
SmallPtrSet for pointer element types.
2025-08-18 07:01:29 -07:00
Kazu Hirata
84f4465135
[ExecutionEngine] Remove unnecessary casts (NFC) (#153931)
getLoadAddressWithOffset() and getLoadAddress() already return
uint64_t.
2025-08-16 06:47:25 -07:00
Lang Hames
3bc3b4cf5f [ORC] Add cloneExternalModuleToContext API.
cloneExternalModuleToContext can be used to clone an LLVM module onto a given
ThreadSafeContext. Callers of this function are responsible for ensuring
exclusive access to the source module and its LLVMContext.
2025-08-14 21:21:17 +10:00
Kazu Hirata
39941a2dbc
[ExecutionEngine] Remove an unnecessary cast (NFC) (#152836)
getValue() already returns uint64_t.
2025-08-09 06:57:58 -07:00
Kazu Hirata
35dd88918f
[llvm] Use llvm::iterator_range::empty (NFC) (#151905) 2025-08-04 07:40:46 -07:00
Kazu Hirata
b04968c4cd
[ExecutionEngine] Remove an unnecessary cast (NFC) (#151798)
value() already returns uint64_t.
2025-08-02 08:09:18 -07:00
Kazu Hirata
84576c7b5d
[ExecutionEngine] Remove an unnecessary cast (NFC) (#151082)
BaseObj is already of const MachOObjectFile &.
2025-07-29 08:18:53 -07:00
Kazu Hirata
f8ee63d9a9
[ExecutionEngine] Remove unnecessary casts (NFC) (#150785)
getArch() already returns Triple::ArchType.
2025-07-26 18:15:23 -07:00
Ami-zhang
4e35ae10c4
[RuntimeDyld][LoongArch] Support large code model (#148584)
Co-authored-by: Weining Lu <luweining@loongson.cn>
2025-07-21 09:28:24 +08:00
Pavel Labath
17784e8d29
[support] Add packed_endian_specific_integral::value() (#147974)
They are already implicitly convertible to the underlying type, but that
doesn't work in some contexts, and it can be useful to get the
underlying value without needing the remember/guess the right type.

I converted a couple of call sites to demonstrate usefulness, but
there's likely more of them. I know at least of at least a few in LLDB,
but I don't want to make this a cross-project patch.
2025-07-11 08:27:58 +02:00
SahilPatidar
d733c8e5c5
[Orc] Fix error handling in ORCPlatformSupport::initialize (#144637)
Previously, `result` was checked before handling the `Error` returned by
`callSPSWrapper`. If `Error` was `success` but `result` indicated
failure, the original `Error` was silently dropped, triggering an
assertion failure for unhandled `Error`.

This patch ensures the `Error` is checked and returned before inspecting
`result`, preventing assertion failures.

Co-authored-by: Anutosh Bhat <andersonbhat491@gmail.com>
2025-07-07 11:38:14 +05:30
Austin
a550fef906
[llvm] Use llvm::fill instead of std::fill(NFC) (#146911)
Use llvm::fill instead of std::fill
2025-07-04 14:10:28 +08:00
Lang Hames
2638fa1be6
[ORC] Add cloneToContext: Clone Module to a given ThreadSafeContext (#146852)
This is a generalization of the existing cloneToNewContext operation:
rather than cloning the given module into a new ThreadSafeContext it
clones it into any given ThreadSafeContext. The given ThreadSafeContext
is locked to ensure that the cloning operation is safe.
2025-07-03 22:04:41 +10:00
Lang Hames
41fd13c635 [ORC] Fix file header comment formatting. NFC. 2025-07-03 20:17:12 +10:00
Lang Hames
0bfa0bcd79
[ORC] Replace ThreadSafeContext::getContext with withContextDo. (#146819)
This removes ThreadSafeContext::Lock, ThreadSafeContext::getLock, and
ThreadSafeContext::getContext, and replaces them with a
ThreadSafeContext::withContextDo method (and const override).

The new method can be used to access an existing
ThreadSafeContext-wrapped LLVMContext in a safe way:

ThreadSafeContext TSCtx = ... ;
TSCtx.withContextDo([](LLVMContext *Ctx) {
  // this closure has exclusive access to Ctx.
});

The new API enforces correct locking, whereas the old APIs relied on
manual locking (which almost no in-tree code preformed, relying instead
on incidental exclusive access to the ThreadSafeContext).
2025-07-03 17:03:39 +10:00
Kazu Hirata
289c066ac4
[ExecutionEngine] Remove unnecessary casts (NFC) (#146218)
R and K are already of Edge::Kind in all these cases.
2025-06-28 13:03:45 -07:00
Kazu Hirata
26ec66dc18
[llvm] Use a new constructor of ArrayRef (NFC) (#146008)
ArrayRef now has a new constructor that takes a parameter whose type
has data() and size().  This patch migrates:

  ArrayRef<T>(X.data(), X.size()

to:

  ArrayRef<T>(X)
2025-06-26 23:38:12 -07:00
Lang Hames
f93df5ebd9
[ORC] Add read operations to orc::MemoryAccess. (#145834)
This commit adds operations to orc::MemoryAccess for reading basic types
(uint8_t, uint16_t, uint32_t, uint64_t, pointers, buffers, and strings)
from executor memory.

The InProcessMemoryAccess and EPCGenericMemoryAccess implementations are
updated to support the new operations.
2025-06-27 09:49:17 +10:00
Lang Hames
0faa181434
[ORC] Extract MemoryAccess from ExecutorProcessControl, break up header. (#145671)
This moves the MemoryAccess interface out of the ExecutorProcessControl
class and splits implementation classes InProcessMemoryManager and
SelfExecutorProcessControl out of ExecutorProcessControl.h and into
their own headers.
2025-06-26 10:31:43 +10:00
Lang Hames
36a060a4e5 [ORC] Sink DynamicLibrary.h header include into ExecutorProcessControl.cpp.
This include is only used for implementation, so shouldn't be in the public
header.
2025-06-25 20:07:10 +10:00
Lang Hames
6cfa03f1f1
[ORC] Drop unused LinkGraphLinkingLayer::Plugin::notifyLoaded method. (#145457)
This method was included in the original Plugin API as a counterpart to
JITEventListener::notifyLoaded but was never used.
2025-06-24 19:00:24 +10:00
Maksim Panchenko
0c33799e37
[JITLink] Include target addend in out-of-range error (#145423)
When JITLink reports an out-of-range error, the underlying reason could
be hidden from the user if it's due to an excessively large target
addend. Add non-zero target addend to the message for clarity.
2025-06-23 22:46:15 -07:00
Lang Hames
ca04d74564 [ORC] DLLImportDefinitionGenerator should use LookupKind::Static.
LookupKind::DLSym should only be used for lookups issued on behalf of the ORC
runtime's emulated dlsym operation.

This should fix a bug where ORC runtime clients are unable to access functions
exported by the runtime.

https://github.com/llvm/llvm-project/issues/145296
2025-06-24 11:51:32 +10:00