2403 Commits

Author SHA1 Message Date
Jonas Devlieghere
686dfe3676 [Support] Make error banner optional in logAllUnhandledErrors
In a lot of places an empty string was passed as the ErrorBanner to
logAllUnhandledErrors. This patch makes that argument optional to
simplify the call sites.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346604 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-11 01:46:03 +00:00
Lang Hames
d71ec72114 [ORC] Fix hex printing of uint64_t values.
A plain "%x" format string will drop the high 32-bits. Use the PRIx64 macro
instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345696 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-31 05:16:14 +00:00
Matthias Braun
b3bc95870d ADT/STLExtras: Introduce llvm::empty; NFC
This is modeled after C++17 std::empty().

Differential Revision: https://reviews.llvm.org/D53909

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345679 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-31 00:23:23 +00:00
Lang Hames
8b9cbda1b3 [ORC] Re-apply r345077 with fixes to remove ambiguity in lookup calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345098 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 23:01:39 +00:00
Reid Kleckner
1989ce13fd Revert r345077 "[ORC] Change how non-exported symbols are matched during lookup."
Doesn't build on Windows. The call to 'lookup' is ambiguous. Clang and
MSVC agree, anyway.

http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/787
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\unittests\ExecutionEngine\Orc\CoreAPIsTest.cpp(315): error C2668: 'llvm::orc::ExecutionSession::lookup': ambiguous call to overloaded function
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\include\llvm/ExecutionEngine/Orc/Core.h(823): note: could be 'llvm::Expected<llvm::JITEvaluatedSymbol> llvm::orc::ExecutionSession::lookup(llvm::ArrayRef<llvm::orc::JITDylib *>,llvm::orc::SymbolStringPtr)'
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\include\llvm/ExecutionEngine/Orc/Core.h(817): note: or       'llvm::Expected<llvm::JITEvaluatedSymbol> llvm::orc::ExecutionSession::lookup(const llvm::orc::JITDylibSearchList &,llvm::orc::SymbolStringPtr)'
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\unittests\ExecutionEngine\Orc\CoreAPIsTest.cpp(315): note: while trying to match the argument list '(initializer list, llvm::orc::SymbolStringPtr)'

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345078 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 20:54:43 +00:00
Lang Hames
e4c9c3925c [ORC] Change how non-exported symbols are matched during lookup.
In the new scheme the client passes a list of (JITDylib&, bool) pairs, rather
than a list of JITDylibs. For each JITDylib the boolean indicates whether or not
to match against non-exported symbols (true means that they should be found,
false means that they should not). The MatchNonExportedInJD and MatchNonExported
parameters on lookup are removed.

The new scheme is more flexible, and easier to understand.

This patch also updates JITDylib search orders to be lists of (JITDylib&, bool)
pairs to match the new lookup scheme. Error handling is also plumbed through
the LLJIT class to allow regression tests to fail predictably when a lookup from
a lazy call-through fails.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345077 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 20:20:22 +00:00
Lang Hames
c407a17bdd [RuntimeDyld][COFF] Skip non-loaded sections when calculating ImageBase.
Non-loaded sections (whose unused load-address defaults to zero) should not
be taken into account when calculating ImageBase, or ImageBase will be
incorrectly set to 0.

Patch by Andrew Scheidecker. Thanks Andrew!

https://reviews.llvm.org/D51343

+        // The Sections list may contain sections that weren't loaded for
+        // whatever reason: they may be debug sections, and ProcessAllSections
+        // is false, or they may be sections that contain 0 bytes. If the
+        // section isn't loaded, the load address will be 0, and it should not
+        // be included in the ImageBase calculation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344995 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 01:36:33 +00:00
Lang Hames
41fdb6ac05 [ORC] Show JITDylib search order in JITDylib::dump.
This can be helpful in debugging search-order related failures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344994 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 01:36:32 +00:00
Lang Hames
abbd80eecc [ORC] Dump flags for JITDylib symbol table entries.
This can help when debugging flag-specific symbol table issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344993 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 01:36:31 +00:00
Lang Hames
56e3b243da [ORC] Guard access to the MemMgrs vector in RTDyldObjectLinkingLayer.
Otherwise we can end up with a data-race when linking concurrently.

This should fix an intermittent failure in the multiple-compile-threads-basic.ll
testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344956 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 21:17:56 +00:00
Lang Hames
e87aaa1093 [ORC] Make the VModuleKey optional, propagate it via MaterializationUnit and
MaterializationResponsibility.

VModuleKeys are intended to enable selective removal of modules from a JIT
session, however for a wide variety of use cases selective removal is not
needed and introduces unnecessary overhead. As of this commit, the default
constructed VModuleKey value is reserved as a "do not track" value, and
becomes the default when adding a new module to the JIT.

This commit also changes the propagation of VModuleKeys. They were passed
alongside the MaterializationResponsibity instance in XXLayer::emit methods,
but are now propagated as part of the MaterializationResponsibility instance
itself (and as part of MaterializationUnit when stored in a JITDylib).
Associating VModuleKeys with MaterializationUnits in this way should allow
for a thread-safe module removal mechanism in the future, even when a module
is in the process of being compiled, by having the
MaterializationResponsibility object check in on its VModuleKey's state
before commiting its results to the JITDylib.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344643 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-16 20:13:06 +00:00
Lang Hames
582b119624 [ORC] Rename ORC layers to make the "new" ORC layers the default.
This commit adds a 'Legacy' prefix to old ORC layers and utilities, and removes
the '2' suffix from the new ORC layers. If you wish to continue using the old
ORC layers you will need to add a 'Legacy' prefix to your classes. If you were
already using the new ORC layers you will need to drop the '2' suffix.

The legacy layers will remain in-tree until the new layers reach feature
parity with them. This will involve adding support for removing code from the
new layers, and ensuring that performance is comperable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344572 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 22:56:10 +00:00
Lang Hames
4812114f29 [ORC] Rename MultiThreadedSimpleCompiler to ConcurrentIRCompiler.
The new name is a better fit: This class does not actually spawn any new
threads for compilation, it is just safe to call from multiple threads
concurrently.

The "Simple" part of the name did not convey much either, so it was
dropped.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344567 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 22:36:22 +00:00
Lang Hames
52ff03cff9 [ORC] Switch to DenseMap/DenseSet for ORC symbol map/set types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344565 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 22:27:02 +00:00
Lang Hames
aa8c49dafa [ORC] Simplify naming for JITDylib definition generators.
Renames:
  JITDylib's setFallbackDefinitionGenerator method to setGenerator.
  DynamicLibraryFallbackGenerator class to DynamicLibrarySearchGenerator.
  ReexportsFallbackDefinitionGenerator to ReexportsGenerator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344489 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 05:07:54 +00:00
Lang Hames
54d4881c35 [ORC] During lookup, do not match against hidden symbols in other JITDylibs.
This adds two arguments to the main ExecutionSession::lookup method:
MatchNonExportedInJD, and MatchNonExported. These control whether and where
hidden symbols should be matched when searching a list of JITDylibs.

A similar effect could have been achieved by filtering search results, but
this would have involved materializing symbol definitions (since materialization
is triggered on lookup) only to throw the results away, among other issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344467 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-13 21:53:40 +00:00
Lang Hames
5148047f08 [ORC] Promote and rename private symbols inside the CompileOnDemand layer,
rather than require them to have been promoted before being passed in.

Dropping this precondition is better for layer composition (CompileOnDemandLayer
was the only one that placed pre-conditions on the modules that could be added).
It also means that the promoted private symbols do not show up in the target
JITDylib's symbol table. Instead, they are confined to the hidden implementation
dylib that contains the actual definitions.

For the 403.gcc testcase this cut down the public symbol table size from ~15,000
symbols to ~4000, substantially reducing symbol dependence tracking costs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344078 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-09 20:44:32 +00:00
Lang Hames
ee5c35b1a7 [ORC] Add a 'remove' method to JITDylib to remove symbols.
Symbols can be removed provided that all are present in the JITDylib and none
are currently in the materializing state. On success all requested symbols are
removed. On failure an error is returned and no symbols are removed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343928 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-06 23:03:59 +00:00
Lang Hames
c8d6c1623d [ORC] Pass symbol name to discard by const reference.
This saves some unnecessary atomic ref-counting operations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343927 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-06 23:02:06 +00:00
Lang Hames
eaf1a19dc4 [ORC] Pass Symbols to ExecutionSession::lookup by value, potentially saving a
copy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343442 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 04:59:10 +00:00
Lang Hames
2887f2e594 [ORC] Add convenience methods for creating DynamicLibraryFallbackGenerators for
libraries on disk, and for the current process.

Avoids more boilerplate during JIT construction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343430 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 00:59:28 +00:00
Lang Hames
0e735f0b53 [ORC] Add an 'intern' method to ExecutionEngine for interning symbol names.
This cuts down on boilerplate by reducing 'ES.getSymbolStringPool().intern(...)'
to 'ES.intern(...)'.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343427 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-30 23:18:24 +00:00
Lang Hames
04756ee526 [ORC] Extract and tidy up JITTargetMachineBuilder, add unit test.
(1) Adds comments for the API.

(2) Removes the setArch method: This is redundant: the setArchStr method on the
    triple should be used instead.

(3) Turns EmulatedTLS on by default. This matches EngineBuilder's behavior.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343423 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-30 19:12:23 +00:00
Lang Hames
90c3271e8e [ORC] Add partitioning support to CompileOnDemandLayer2.
CompileOnDemandLayer2 now supports user-supplied partition functions (the
original CompileOnDemandLayer already supported these).

Partition functions are called with the list of requested global values
(i.e. global values that currently have queries waiting on them) and have an
opportunity to select extra global values to materialize at the same time.

Also adds testing infrastructure for the new feature to lli.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343396 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-29 23:49:57 +00:00
Lang Hames
974e704961 [ORC] Clear SymbolToDefinitionMap when materializing a MaterializationUnit.
The map is inaccessible at this point, so we may as well reclaim the memory
early.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343395 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-29 23:49:56 +00:00
Lang Hames
94cc8ba720 [ORC] Make MaterializationResponsibility::getRequestedSymbols() const.
This makes it available for use in IRTransformLayer2::TransformFunction
instances (since a const MaterializationResponsibility& parameter was
added in r343365).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343367 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 22:03:17 +00:00
Lang Hames
7373792b4a [ORC] Add more utilities to aid debugging output.
(1) A const accessor for the LLVMContext held by a ThreadSafeContext.

(2) A const accessor for the ThreadSafeModules held by an IRMaterializationUnit.

(3) A const MaterializationResponsibility reference to IRTransformLayer2's
    transform function. This makes IRTransformLayer2 useful for JIT debugging
    (since it can inspect JIT state through the responsibility argument) as well
    as program transformations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343365 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 21:49:53 +00:00
Lang Hames
3bd24cdeac [ORC] Narrow a cast: the block guarded by the condition only handles
GlobalVariables, not all GlobalValues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343358 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 20:16:16 +00:00
Lang Hames
033636c6aa [ORC] Remove some dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343327 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 15:13:41 +00:00
Lang Hames
a6f5223feb [ORC] Improve debugging output for ORC.
(1) Print debugging output under a session lock to avoid garbled messages when
compiling on multiple threads.

(2) Name MaterializationUnits, add an ostream operator for them, and so they can
be easily referenced in debugging output, and have that ostream operator
optionally print code/data/hidden symbols provided by that materialization unit
based on command line options.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343323 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 15:03:11 +00:00
Lang Hames
217504b6a8 [ORC] clang-format the ThreadSafeModule code.
Evidently I forgot to do this before committing r343055.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343288 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-28 01:41:33 +00:00
Lang Hames
1d6ef08467 [ORC] Add definition for IRLayer::setCloneToNewContextOnEmit, use it to set the
flag to true in LLJIT when running in multithreaded mode.

The IRLayer::setCloneToNewContextOnEmit method sets a flag within the IRLayer
that causes modules added to that layer to be moved to a new context (by
serializing to/from a memory buffer) when they are emitted. This allows modules
that were all loaded on the same context to be compiled in parallel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343266 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 21:13:07 +00:00
Lang Hames
4bcdd90284 [ORC] Coalesce all of ORC's symbol renaming / linkage-promotion utilities into
one SymbolLinkagePromoter utility.

SymbolLinkagePromoter renames anonymous and private symbols, and bumps all
linkages to at least global/hidden-visibility. Modules whose symbols have been
promoted by this utility can be decomposed into sub-modules without introducing
link errors. This is used by the CompileOnDemandLayer to extract single-function
modules for lazy compilation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343257 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 19:27:20 +00:00
Lang Hames
4b09ab1858 [ORC] Use ExecutionSession's pre-constructed main JITDylib in LLJIT.
As of r342086 ExecutionSession automatically creates a 'main' JITDylib, so
there is no need for LLJIT to create its own.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343167 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 04:19:32 +00:00
Lang Hames
91c25dba63 Reapply r343058 with a fix for -DLLVM_ENABLE_THREADS=OFF.
Modifies lit to add a 'thread_support' feature that can be used in lit test
REQUIRES clauses. The thread_support flag is set if -DLLVM_ENABLE_THREADS=ON
and unset if -DLLVM_ENABLE_THREADS=OFF. The lit flag is used to disable the
multiple-compile-threads-basic.ll testcase when threading is disabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343122 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 16:26:59 +00:00
Hans Wennborg
3fccee2ee8 Revert r343058 "[ORC] Add support for multithreaded compiles to LLJIT and LLLazyJIT."
This doesn't work well in builds configured with LLVM_ENABLE_THREADS=OFF,
causing the following assert when running
ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll:

  lib/ExecutionEngine/Orc/Core.cpp:1748: Expected<llvm::JITEvaluatedSymbol>
  llvm::orc::lookup(const llvm::orc::JITDylibList &, llvm::orc::SymbolStringPtr):
  Assertion `ResultMap->size() == 1 && "Unexpected number of results"' failed.

> LLJIT and LLLazyJIT can now be constructed with an optional NumCompileThreads
> arguments. If this is non-zero then a thread-pool will be created with the
> given number of threads, and compile tasks will be dispatched to the thread
> pool.
>
> To enable testing of this feature, two new flags are added to lli:
>
> (1) -compile-threads=N (N = 0 by default) controls the number of compile threads
> to use.
>
> (2) -thread-entry can be used to execute code on additional threads. For each
> -thread-entry argument supplied (multiple are allowed) a new thread will be
> created and the given symbol called. These additional thread entry points are
> called after static constructors are run, but before main.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343099 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 12:15:23 +00:00
Lang Hames
1fe1a86443 [ORC] Update CompileOnDemandLayer2 to use the new lazyReexports mechanism
for lazy compilation, rather than a callback manager.

The new mechanism does not block compile threads, and does not require
function bodies to be renamed.

Future modifications should allow laziness on a per-module basis to work
without any modification of the input module.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343065 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 05:08:29 +00:00
Lang Hames
62e9680cdc [ORC] Add a "lazy call-through" utility based on the same underlying trampoline
implementation as lazy compile callbacks, and a "lazy re-exports" utility that
builds lazy call-throughs.

Lazy call-throughs are similar to lazy compile callbacks (and are based on the
same underlying state saving/restoring trampolines) but resolve their targets
by performing a standard ORC lookup rather than invoking a user supplied
compiler callback. This allows them to inherit the thread-safety of ORC lookups
while blocking only the calling thread (whereas compile callbacks also block one
compile thread).

Lazy re-exports provide a simple way of building lazy call-throughs. Unlike a
regular re-export, a lazy re-export generates a new address (a stub entry point)
that will act like the re-exported symbol when called. The first call via a
lazy re-export will trigger compilation of the re-exported symbol before calling
through to it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343061 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 04:18:30 +00:00
Lang Hames
089f5d0e08 [ORC] Refactor trampoline pool management out of JITCompileCallbackManager.
This will allow trampoline pools to be re-used for a new lazy-reexport utility
that generates looks up function bodies using the standard symbol lookup process
(rather than using a user provided compile function). This new utility provides
the same capabilities (since MaterializationUnits already allow user supplied
compile functions to be run) as JITCompileCallbackManager, but can use the new
asynchronous lookup functions to avoid blocking a compile thread.

This patch also updates createLocalCompileCallbackManager to return an error if
a callback manager can not be created, and updates clients of that API to
account for the change. Finally, the OrcCBindingsStack is updates so that if
a callback manager is not available for the target platform a valid stack
(without support for lazy compilation) can still be constructed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343059 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 03:32:12 +00:00
Lang Hames
410236759a [ORC] Add support for multithreaded compiles to LLJIT and LLLazyJIT.
LLJIT and LLLazyJIT can now be constructed with an optional NumCompileThreads
arguments. If this is non-zero then a thread-pool will be created with the
given number of threads, and compile tasks will be dispatched to the thread
pool.

To enable testing of this feature, two new flags are added to lli:

(1) -compile-threads=N (N = 0 by default) controls the number of compile threads
to use.

(2) -thread-entry can be used to execute code on additional threads. For each
-thread-entry argument supplied (multiple are allowed) a new thread will be
created and the given symbol called. These additional thread entry points are
called after static constructors are run, but before main.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343058 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 02:39:42 +00:00
Lang Hames
d813c35f4c [ORC] Add ThreadSafeModule and ThreadSafeContext wrappers to support concurrent
compilation of IR in the JIT.

ThreadSafeContext is a pair of an LLVMContext and a mutex that can be used to
lock that context when it needs to be accessed from multiple threads.

ThreadSafeModule is a pair of a unique_ptr<Module> and a
shared_ptr<ThreadSafeContext>. This allows the lifetime of a ThreadSafeContext
to be managed automatically in terms of the ThreadSafeModules that refer to it:
Once all modules using a ThreadSafeContext are destructed, and providing the
client has not held on to a copy of shared context pointer, the context will be
automatically destructed.

This scheme is necessary due to the following constraits: (1) We need multiple
contexts for multithreaded compilation (at least one per compile thread plus
one to store any IR not currently being compiled, though one context per module
is simpler). (2) We need to free contexts that are no longer being used so that
the JIT does not leak memory over time. (3) Module lifetimes are not
predictable (modules are compiled as needed depending on the flow of JIT'd
code) so there is no single point where contexts could be reclaimed.

JIT clients not using concurrency can safely use one ThreadSafeContext for all
ThreadSafeModules.

JIT clients who want to be able to compile concurrently should use a different
ThreadSafeContext for each module, or call setCloneToNewContextOnEmit on their
top-level IRLayer. The former reduces compile latency (since no clone step is
needed) at the cost of additional memory overhead for uncompiled modules (as
every uncompiled module will duplicate the LLVM types, constants and metadata
that have been shared).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343055 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 01:24:12 +00:00
Lang Hames
8f7a77b36f [ORC] Add an asynchronous jit-link function, jitLinkForORC, to RuntimeDyld and
switch RTDyldObjectLinkingLayer2 to use it.

RuntimeDyld::loadObject is currently a blocking operation. This means that any
JIT'd code whose call-graph contains an embedded complete K graph will require
at least K threads to link, which precludes the use of a fixed sized thread
pool for concurrent JITing of arbitrary code (whatever K the thread-pool is set
at, any code with a K+1 complete subgraph will deadlock at JIT-link time).

To address this issue, this commmit introduces a function called jitLinkForORC
that uses continuation-passing style to pass the fix-up and finalization steps
to the asynchronous symbol resolver interface so that linking can be performed
without blocking.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343043 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 22:57:44 +00:00
Lang Hames
bf745a628f Remove 'orc' namespace from MSVCErrorWorkarounds.h, fix some typos that were
breaking windows builds.

The 'orc' namespace was accidentally left in when the workarounds were moved
out of orc in r343011.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343025 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 20:48:57 +00:00
Lang Hames
a3c2b35ae0 Fix a missing includes and a use of the MSVC promise/future workaround that
were left out of r343011/r343012.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343022 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 20:16:06 +00:00
Lang Hames
32cb08f5ea [ORC] Reapply r342939 with a fix for MSVC's promise/future restrictions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343012 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 19:48:46 +00:00
Lang Hames
7617dcec90 Revert "[ORC] Switch to asynchronous resolution in JITSymbolResolver."
This reverts commit r342939.

MSVC's promise/future implementation does not like types that are not default
constructible. Reverting while I figure out a solution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342941 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 04:54:03 +00:00
Lang Hames
e6f49e3ad8 [ORC] Switch to asynchronous resolution in JITSymbolResolver.
Asynchronous resolution (where the caller receives a callback once the requested
set of symbols are resolved) is a core part of the new concurrent ORC APIs. This
change extends the asynchronous resolution model down to RuntimeDyld, which is
necessary to prevent deadlocks when compiling/linking on a fixed number of
threads: If RuntimeDyld's linking process were a blocking operation, then any
complete K-graph in a program will require at least K threads to link in the
worst case, as each thread would block waiting for all the others to complete.
Using callbacks instead allows the work to be passed between dependent threads
until it is complete.

For backwards compatibility, all existing RuntimeDyld functions will continue
to operate in blocking mode as before. This change will enable the introduction
of a new async finalization process in a subsequent patch to enable asynchronous
JIT linking.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342939 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 04:43:38 +00:00
Lang Hames
2ea08c4309 [ORC] Add some debugging output to Core.h/Core.cpp
Core now logs when materialization units are dispatched or return to JITDylibs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342853 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-23 21:30:05 +00:00
Lang Hames
e61aa61731 [ORC] Update ORC C bindings to use the new llvm::Error C API.
This replaces instances of the LLVMOrcErrorCode type with LLVMErrorRef,
simplifying the implementation of the OrcCBindingsStack class and ORC
C API bindings and making it possible to return arbitrary (wrapped)
llvm::Errors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342828 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-23 02:09:18 +00:00
Lang Hames
1f54a23724 [ORC] Merge ExecutionSessionBase with ExecutionSession by moving a couple of
template methods in JITDylib out-of-line.

This also splits JITDylib::define into a pair of template methods, one taking an
lvalue reference and the other an rvalue reference. This simplifies the
templates at the cost of a small amount of code duplication.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342087 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-12 21:49:02 +00:00