Commit Graph

748 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
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
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
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
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
cff463369b [ORC] Use JITEvaluatedSymbol for IndirectStubsManager findStub and findPointer.
Existing implementations of these methods do not require lazy materialization,
and switching to JITEvaluatedSymbol allows us to remove error checking on the
client side.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333835 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-03 02:18:03 +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
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
Krasimir Georgiev
60231abbcc Fix ODR violation from r333230
This is an ODR violation, for example in ExecutionEngine/MCJIT/MCJIT.o: multiple definition of 'LLVMCreateIntelJITEventListener'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333265 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-25 10:10:02 +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
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
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
0b44b42eaf [ORC] Add some comments to Layer.h.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333028 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-22 20:50:36 +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
1948145a6a [ORC] Make some more operations on VSO private. These should be done via a
MaterializationResponsibility instance.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332919 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 23:46:29 +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
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
e78f10b99e [ORC] Make MaterializationResponsibility's constructor private.
MaterializationResponsibility instances should be created by
MaterializationUnits only. Making the constructor private enforces this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332665 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-17 20:48:50 +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
Adrian Prantl
0b24b74655 Remove @brief commands from doxygen comments, too.
This is a follow-up to r331272.

We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by
  for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done

https://reviews.llvm.org/D46290

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331275 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-01 16:10:38 +00:00
Adrian Prantl
26b584c691 Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

  for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331272 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-01 15:54:18 +00:00
Andres Freund
a3df84bd43 Test commit access.
Remove trailing whitespace.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330551 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-22 17:53:34 +00:00
Lang Hames
2c63662d70 [ORC] Make VSO symbol resolution/finalization operations private.
This forces these operations to be carried out via a
MaterializationResponsibility instance, ensuring responsibility is explicitly
tracked.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330356 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-19 18:42:49 +00:00
Lang Hames
08893d364d [ORC] Add a MaterializationResponsibility class to track responsibility for
materializing function definitions.

MaterializationUnit instances are responsible for resolving and finalizing
symbol definitions when their materialize method is called. By contract, the
MaterializationUnit must materialize all definitions it is responsible for and
no others. If it can not materialize all definitions (because of some error)
then it must notify the associated VSO about each definition that could not be
materialized. The MaterializationResponsibility class tracks this
responsibility, asserting that all required symbols are resolved and finalized,
and that no extraneous symbols are resolved or finalized. In the event of an
error it provides a convenience method for notifying the VSO about each
definition that could not be materialized.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330142 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-16 18:05:24 +00:00
Lang Hames
3963b7d5e4 [ORC] Merge VSO notifyResolutionFailed and notifyFinalizationFailed in to
notifyMaterializationFailed.

The notifyMaterializationFailed method can determine which error to raise by
looking at which queue the pending queries are in (resolution or finalization).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330141 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-16 18:05:22 +00:00
Weiming Zhao
d752376056 Rename ObjectMemoryBuffer to SmallVectorMemoryBuffer; NFCI
Summary: As discussed in https://reviews.llvm.org/D45606, it makes more sense to name the class as SmallVectorMemoryBuffer

Reviewers: bkramer, dblaikie

Reviewed By: dblaikie

Subscribers: mehdi_amini, eraman, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330107 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-16 03:44:03 +00:00
Weiming Zhao
68232226c4 NFC: Move ObjectMemoryBuffer to support
Summary:
Since the class is used by both MCJIT and LTO, it makes more sense to move it to Support lib.
This is a follow up patch to r329929 and https://reviews.llvm.org/D45244

Reviewers: bkramer, dblaikie

Reviewed By: bkramer

Subscribers: mehdi_amini, eraman, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330093 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-15 05:17:14 +00:00
Lang Hames
4eb94074a0 [ORC] Use insert rather than emplace.
Hopefully this will fix the build failure at
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/9028

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329944 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 19:54:41 +00:00
Lang Hames
741d7afdf1 [ORC] Plumb error notifications through the VSO interface.
This allows materializers to notify the VSO that they were unable to
resolve or finalize symbols.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329934 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 18:35:08 +00:00
Benjamin Kramer
6724658f85 [MCJIT] Remove the anchor from mcjit.
This is a layering violation. LTO shouldn't depend on MCJIT. The right
fix for this is moving the class somewhere else.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329929 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-12 17:28:30 +00:00
Weiming Zhao
66258c9888 Add missing vtable anchors
Summary: This patch adds anchor() for MemoryBuffer, raw_fd_ostream, RTDyldMemoryManager, SectionMemoryManager, etc.

Reviewers: jlebar, eli.friedman, dblaikie

Reviewed By: dblaikie

Subscribers: mehdi_amini, mgorny, dblaikie, weimingz, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329861 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-11 23:09:20 +00:00
Lang Hames
eee57fe80c [ORC] Add a debugging check to catch dangling references to SymbolStringPools.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329019 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-02 21:39:39 +00:00
Lang Hames
9b17e6e1c4 [ORC] Fix a think-o: ExecutionSession should create a SymbolStringPool if none
is passed in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329018 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-02 21:34:48 +00:00
Lang Hames
73bcd8b27c [ORC] Create a new SymbolStringPool by default in ExecutionSession constructor.
This makes the common case of constructing an ExecutionSession tidier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329013 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-02 20:57:56 +00:00
Lang Hames
507d7742b9 [ORC] Rename SymbolSource to MaterializationUnit, and make the materialization
operation all-or-nothing, rather than allowing materialization on a per-symbol
basis.

This addresses a shortcoming of per-symbol materialization: If a
MaterializationUnit (/SymbolSource) wants to materialize more symbols than
requested (which is likely: most materializers will want to materialize whole
modules) then it needs a way to notify the symbol table about the extra symbols
being materialized. This process (checking what has been requested against what
is being provided and notifying the symbol table about the difference) has to
be repeated at every level of the JIT stack. Making materialization
all-or-nothing eliminates this issue, simplifying both materializer
implementations and the symbol table (VSO class) API. The cost is that
per-symbol materialization (e.g. for individual symbols in a module) now
requires multiple MaterializationUnits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327946 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-20 03:49:29 +00:00
Lang Hames
6531c3164c [ORC] Re-apply r327566 with a fix for test-global-ctors.ll.
Also clang-formats the patch, which I should have done the first time around.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327594 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-15 00:30:14 +00:00
Reid Kleckner
d1e7e3c8a8 Revert "[ORC] Switch from shared_ptr to unique_ptr for addModule methods."
This reverts commit r327566, it breaks
test/ExecutionEngine/OrcMCJIT/test-global-ctors.ll.

The test doesn't crash with a stack trace, unfortunately. It merely
returns 1 as the exit code.

ASan didn't produce a report, and I reproduced this on my Linux machine
and Windows box.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327576 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 21:32:34 +00:00
Lang Hames
96ae7f8910 [ORC] Switch from shared_ptr to unique_ptr for addModule methods.
Layer implementations typically mutate module state, and this is better
reflected by having layers own the Module they are operating on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327566 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 20:29:45 +00:00
Lang Hames
dda1921ef4 [ExecutionEngine] Add a getSymbolTable method to RuntimeDyld.
This can be used to extract the symbol table from a RuntimeDyld instance prior
to disposing of it.

This patch also updates RTDyldObjectLinkingLayer to use the new method, rather
than requesting symbols one at a time via getSymbol.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327476 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 06:25:07 +00:00
Lang Hames
a4b7c02dd5 [ORC] Add a 'lookup' convenience function for finding symbols in a list of VSOs.
The lookup function takes a list of VSOs, a set of symbol names (or just one
symbol name) and a materialization function object. It returns an
Expected<SymbolMap> (if given a set of names) or an Expected<JITEvaluatedSymbol>
(if given just one name). The lookup method constructs an
AsynchronousSymbolQuery for the given names, applies that query to each VSO in
the list in turn, and then blocks waiting for the query to complete. If
threading is enabled then the materialization function object can be used to
execute the materialization on different threads. If threading is disabled the
MaterializeOnCurrentThread utility must be used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327474 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 04:18:04 +00:00
Lang Hames
734c4808f8 [ORC] Switch to shared_ptr ownership for SymbolSources in VSOs.
This makes it easy to free a SymbolSource (and any related
resources) when the last reference in a VSO is dropped.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325727 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-21 21:55:57 +00:00