Commit Graph

2306 Commits

Author SHA1 Message Date
Lang Hames
6979160739 [ORC] Add an initial implementation of a replacement CompileOnDemandLayer.
CompileOnDemandLayer2 is a replacement for CompileOnDemandLayer built on the ORC
Core APIs. Functions in added modules are extracted and compiled lazily.
CompileOnDemandLayer2 supports multithreaded JIT'd code, and compilation on
multiple threads.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334967 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-18 18:01:43 +00:00
Lang Hames
dcd570fed7 [ORC] Keep weak flag on VSO symbol tables during materialization, but treat
materializing weak symbols as strong.

This removes some elaborate flag tweaking and plays nicer with RuntimeDyld,
which relies of weak/common flags to determine whether it should emit a given
weak definition. (Switching to strong up-front makes it appear as if there is
already an overriding definition, which would require an extra back-channel to
override).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334966 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-18 18:01:41 +00:00
Lang Hames
174673f81e [ORC] Remove redundant condition
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334918 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-17 23:54:58 +00:00
Lang Hames
00bb1a1722 [ORC] Only notify queries that they are resolved/ready when the query state
changes.

This guards against redundant notifications.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334916 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-17 18:59:01 +00:00
Lang Hames
501141aa48 [ORC] Suppress an unused variable warning for a debug-mode only use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334911 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-17 17:18:12 +00:00
Lang Hames
05afd8a029 [ORC] Erase empty dependence sets when adding new symbol dependencies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334910 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-17 16:59:53 +00:00
Lang Hames
e1646eb242 [ORC] In MaterializationResponsibility, only maintain the Materializing flag on
symbols in debug mode.

The MaterializationResponsibility class hijacks the Materializing flag to track
symbols that have not yet been resolved in order to guard against redundant
resolution. Since this is an API contract check and only enforced in debug mode
there is no reason to maintain the flag state in release mode.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334909 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-17 16:59:52 +00:00
Sean Fertile
80cb547d11 [PPC64] Support "symbol@high" and "symbol@higha" symbol modifers.
Add support for the "@high" and "@higha" symbol modifiers in powerpc64 assembly.
The modifiers represent accessing the segment consiting of bits 16-31 of a
64-bit address/offset.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334855 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-15 19:47:11 +00:00
Andrew Kaylor
156c4a865a Add debug info for OProfile profiling support
Patch by Gaetano Priori

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334782 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-15 00:07:28 +00:00
Lang Hames
a94df7d526 [ORC] Strip weak flags from a symbol once it is selected for materialization.
Once a symbol has been selected for materialization it can no longer be
overridden. Stripping the weak flag guarantees this (override attempts will
then be treated as duplicate definitions and result in a DuplicateDefinition
error).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334771 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 21:16:29 +00:00
Lang Hames
c6679d1e09 [ORC] Filter out self-dependencies in VSO::addDependencies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334724 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 15:32:59 +00:00
Lang Hames
6ba3aa8738 [ORC] Assert that the query argument to VSO::lookup must be non-null.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334723 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 15:32:59 +00:00
Lang Hames
26907984ce [ORC] Add a WaitUntilReady argument to blockingLookup.
If WaitUntilReady is set to true then blockingLookup will return once all
requested symbols are ready. If WaitUntilReady is set to false then
blockingLookup will return as soon as all requested symbols have been
resolved. In the latter case, if any error occurs in finalizing the symbols it
will be reported to the ExecutionSession, rather than returned by
blockingLookup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334722 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 15:32:58 +00:00
Lang Hames
103c75a7db [ORC] Strip the Materializing flag off finalized symbols in VSOs.
Finalized symbols are no longer in the materializing state.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334721 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 15:32:56 +00:00
Hans Wennborg
a86334c256 Fix -DLLVM_ENABLE_THREADS=OFF build after r334537
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334582 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 08:43:03 +00:00
Reid Kleckner
f38bd3d4b7 Remove malloc.h include from Intel JIT events code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334547 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 21:15:27 +00:00
Reid Kleckner
908b1550af Add null check to Intel JIT event listener
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334544 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 20:54:11 +00:00
Lang Hames
fd5548df54 [ORC] Add a fallback definition generator for VSOs.
If a VSO has a fallback definition generator attached it will be called during
lookup (and lookupFlags) for any unresolved symbols. The definition generator
can add new definitions to the VSO for any unresolved symbol. This allows VSOs
to generate new definitions on demand.

The immediate use case for this code is supporting VSOs that can import
definitions found via dlsym on demand.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334538 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 20:43:18 +00:00
Lang Hames
cdaeb5b41e [ORC] Refactor blocking lookup logic into the blockingLookup function, and
implement existing blocking lookups (the lookup function) and
JITSymbolResolverAdapter on top of that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334537 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 20:43:17 +00:00
Lang Hames
5ce1583427 [RuntimeDyld] Add an assert to catch misbehaving symbol resolvers.
Resolvers are required to find results for all requested symbols or return an
error, but if a resolver fails to adhere to this contract (by returning results
for only a subset of the requested symbols) then this code will infinite loop.
This assertion catches resolvers that fail to adhere to the contract.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334536 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 20:43:17 +00:00
Lang Hames
e6b73b045e [MCJIT] Call materializeAll on modules before compiling them in MCJIT.
This only affects modules with lazy GVMaterializers attached (usually modules
read off disk using the lazy bitcode reader). For such modules, materializing
before compiling prevents crashes due to missing function bodies /
initializers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334535 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 20:43:15 +00:00
Lang Hames
33c00a3db2 [ORC] Add a constructor to create an IRMaterializationUnit from a module and
pre-existing SymbolFlags and SymbolToDefinition maps.

This constructor is useful when delegating work from an existing
IRMaterialiaztionUnit to a new one, as it avoids the cost of re-computing these
maps.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333852 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-03 19:22:48 +00:00
Lang Hames
e9015c7760 [ORC] Add a getRequestedSymbols method to MaterializationResponsibility.
This method returns the set of symbols in the target VSO that have queries
waiting on them. This can be used to make decisions about which symbols to
delegate to another MaterializationUnit (typically this will involve
delegating all symbols that have *not* been requested to another
MaterializationUnit so that materialization of those symbols can be
deferred until they are requested).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333684 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-31 19:29:03 +00:00
Lang Hames
5da314cda8 [ORC] Rename IRMaterializationUnit's Discardable member to SymbolToDefinition,
and make it protected rather than private.

The new name reflects the actual information in the map, and this information
can be useful to derived classes (for example, to quickly look up the IR
definition of a requested symbol).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333683 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-31 19:29:01 +00:00
Hiroshi Inoue
9066b8af33 [PowerPC] fix broken JIT-compiled code with tail call optimization
The relocation for branch instructions in the dynamic loader of ExecutionEngine assumes branch instructions with R_PPC64_REL24 relocation type are only bl. However, with the tail call optimization, b instructions can be also used to jump into another function.
This patch makes the relocation to keep bits in the branch instruction other than the jump offset to avoid relocation rewrites a b instruction into bl.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333502 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-30 04:48:29 +00:00
Lang Hames
7264d3b64c [ORC] Fix an ambiguous make_unique call.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333492 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-30 02:40:40 +00:00
Lang Hames
543cda4110 [ORC] Update JITCompileCallbackManager to support multi-threaded code.
Previously JITCompileCallbackManager only supported single threaded code. This
patch embeds a VSO (see include/llvm/ExecutionEngine/Orc/Core.h) in the callback
manager. The VSO ensures that the compile callback is only executed once and that
the resulting address cached for use by subsequent re-entries.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333490 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-30 01:57:45 +00:00
Andres Freund
f501bf3e39 [C-API] Add functions to create GDB, Intel, Oprofile event listeners.
The additions of Intel, Oprofile listeners were done blindly.

Reviewed By: lhames

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333230 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 21:32:54 +00:00
Andres Freund
2373d70fe7 [ORC][C-API] Expose LLVMOrc{Unr,R}egisterJITEventListener().
Reviewed By: lhames

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333229 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 21:32:52 +00:00
Andres Freund
00af3355f1 [ORC] Add ability [un]register JITEventListener on Orc C stack.
Reviewed By: lhames

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333228 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 21:32:50 +00:00
Andres Freund
803d39f85c [ORC] Extend object layer callbacks so JITEventListener can be supported.
Currently RTDyldObjectLinkingLayer makes it hard to support
JITEventListeners. Which in turn means debugging and profiling JIT
generated code hard.

Supporting JITEventListeners at minimum requries a freed
callback (added).

As listeners expect the ObjectFile to be passed as well, an adaptor
between RTDyldObjectLinkingLayer and JITEventListeners would currently
need to also maintain ObjectFiles for all loaded modules. To make that
less awkward, extend the callbacks to pass the ObjectFile to both
Finalized and Freed callbacks.  That requires extending the lifetime
of the object file when callbacks are present.

Reviewed By: lhames

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333227 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 21:32:48 +00:00
Lang Hames
91b6092209 Add handling for GlobalAliases in ExecutionEngine::getConstantValue.
Patch by Brad Moody. Thanks Brad!

https://reviews.llvm.org/D42160

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333217 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 19:07:34 +00:00
Andres Freund
130bebd92f [ORC] Add findSymbolIn() wrapper to C bindings, take #2.
Re-appply r333147, reverted in r333152 due to a pre-existing bug. As
D47308 has been merged in r333206, the OSX issue should now be
resolved.

In many cases JIT users will know in which module a symbol
resides. Avoiding to search other modules can be more efficient. It
also allows to handle duplicate symbol names between modules.

Reviewed By: lhames

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333215 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 18:44:34 +00:00
Andres Freund
81a864f66c [ORC] Perform name mangling in findSymbolIn(), as done in findSymbol().
The lack of name mangling caused a unittest failure after r333147 (in
TestEagerIRCompilation), as OSX prefixes symbol names with '_'. The
lack of name mangling therefore leads to a NULL pointer being returned
and then called, hence the failure.

While it may look like it, this isn't an actual behavioral change, as
findSymbolIn() previously was not exposed externally, and essentially
dead code. Which explains why nobody noticed the issue previously.

Reviewers: lhames

Reviewed By: lhames

Subscribers: chandlerc, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333206 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 17:03:06 +00:00
Andres Freund
017f7dfd70 Revert r333147 "[ORC] Add findSymbolIn() wrapper to C bindings."
This reverts r333147 until https://reviews.llvm.org/D47308 is ready to
be reviewed. r333147 exposed a behavioural difference between
OrcCBindingsStack::findSymbolIn() and OrcCBindingsStack::findSymbol(),
where only the latter does name mangling. After r333147 that causes a
test failure on OSX, because the new test looks for main using
findSymbolIn() but the mangled name is _main.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333152 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 05:10:19 +00:00
Andres Freund
41d411071a [ORC] Add findSymbolIn() wrapper to C bindings.
In many cases JIT users will know in which module a symbol
resides. Avoiding to search other modules can be more efficient. It
also allows to handle duplicate symbol names between modules.

Reviewed By: lhames

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333147 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 01:01:42 +00:00
Lang Hames
60b28ca5a7 [RuntimeDyld][MachO] Add support for MachO::ARM64_RELOC_POINTER_TO_GOT reloc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333130 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-23 21:27:07 +00:00
Lang Hames
1d560c20ff [LKH] Add a new IRTransformLayer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333129 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-23 21:27:07 +00:00
Lang Hames
499fe95f13 [LKH] Add ObjectTransformLayer2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333128 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-23 21:27:06 +00:00
Lang Hames
38a4af251f [LKH] Add a new IRCompileLayer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333127 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-23 21:27:01 +00:00
Lang Hames
6e22163f52 [ORC] Move symbol-scanning and discard from BasicIRLayerMaterializationUnit in
to a base class (IRMaterializationUnit).

The new class, IRMaterializationUnit, provides a convenient base for any client
that wants to write a materializer for LLVM IR.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332993 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-22 16:15:38 +00:00
Lang Hames
78d8e193c3 [LKH] Add a replacement RTDyldLayer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332918 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 23:45:40 +00:00
Lang Hames
d9367a9197 [ORC] Preserve Materializing symbol flag during resolution.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332899 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 21:11:22 +00:00
Lang Hames
8b040c4121 [ORC] Lookup now returns an error if any symbols are not found.
Also tightens the behavior of ExecutionSession::failQuery. Queries can usually
only be failed by marking a symbol as failed-to-materialize, but
ExecutionSession::failQuery provides a second route, and both routes may be
executed from different threads. In the case that a query has already been
failed due to a materialization error, ExecutionSession::failQuery will
direct the error to ExecutionSession::reportError instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332898 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 21:11:21 +00:00
Lang Hames
1b804fe0ec [ORC] Remove the optional MaterializationResponsibility argument from lookup.
The lookup function provides blocking symbol resolution for JIT clients (not
layers themselves) so it does not need to track symbol dependencies via a
MaterializationResponsibility.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332897 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 21:11:21 +00:00
Lang Hames
e0b0d5fab7 [ORC] Add IRLayer and ObjectLayer interfaces and related MaterializationUnits.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332896 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 21:11:13 +00:00
Lang Hames
fe651d1a0e [ORC] Consolidate materialization errors, and generate them in VSO's
notifyFailed method rather than passing in an error generator.

VSO::notifyFailed is responsible for notifying queries that they will not
succeed due to error. In practice the queries don't care about the details
of the failure, just the fact that a failure occurred for some symbols.
Having VSO::notifyFailed take care of this simplifies the interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332666 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-17 20:48:58 +00:00
Lang Hames
bb60b65608 [ORC] Rewrite the VSO symbol table yet again. Update related utilities.
VSOs now track dependencies for materializing symbols. Each symbol must have its
dependencies registered with the VSO prior to finalization. Usually this will
involve registering the dependencies returned in
AsynchronousSymbolQuery::ResolutionResults for queries made while linking the
symbols being materialized.

Queries against symbols are notified that a symbol is ready once it and all of
its transitive dependencies are finalized, allowing compilation work to be
broken up and moved between threads without queries returning until their
symbols fully safe to access / execute.

Related utilities (VSO, MaterializationUnit, MaterializationResponsibility) are
updated to support dependence tracking and more explicitly track responsibility
for symbols from the point of definition until they are finalized.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332541 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-16 22:24:30 +00:00
Nicola Zaghen
0818e789cb Rename DEBUG macro to LLVM_DEBUG.
The DEBUG() macro is very generic so it might clash with other projects.
The renaming was done as follows:
- git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
- git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM
- Manual change to APInt
- Manually chage DOCS as regex doesn't match it.

In the transition period the DEBUG() macro is still present and aliased
to the LLVM_DEBUG() one.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332240 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-14 12:53:11 +00:00
Lang Hames
99deb0bcb1 [RuntimeDyld][MachO] Properly handle thumb to thumb calls within a section.
Previously thumb bits were only checked for external relocations (thumb to arm
code and vice-versa). This patch adds detection for thumb callees in the same
section asthe (also thumb) caller.

The MachO/Thumb test case is updated to cover this, and redundant checks
(handled by the MachO/ARM test) are removed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331838 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 01:38:13 +00:00