101 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Nico Weber
0f38c60baf IWYU for llvm-config.h in llvm, additions.
See r331124 for how I made a list of files missing the include.
I then ran this Python script:

    for f in open('filelist.txt'):
        f = f.strip()
        fl = open(f).readlines()

        found = False
        for i in xrange(len(fl)):
            p = '#include "llvm/'
            if not fl[i].startswith(p):
                continue
            if fl[i][len(p):] > 'Config':
                fl.insert(i, '#include "llvm/Config/llvm-config.h"\n')
                found = True
                break
        if not found:
            print 'not found', f
        else:
            open(f, 'w').write(''.join(fl))

and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p`
and tried to fix include ordering and whatnot.

No intended behavior change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331184 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-30 14:59:11 +00:00
Lang Hames
52d1558d20 [ORC] Fix an assertion condition from r329934.
Thanks to Alexander Ivchenko for finding the issue!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330359 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-19 19:30:35 +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
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
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
0dadf10b4a [ORC] Don't fully qualify explicit destructor call -- it confuses some compilers.
This should fix the builder failure at
http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/19224

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327955 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-20 05:56:58 +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
58ecc853fc [ORC] Fix a data race in the lookup function.
The Error locals need to be protected by a mutex. (This could be fixed by
having the promises / futures contain Expected and Error values, but
MSVC's future implementation does not support this yet).

Hopefully this will fix some of the errors seen on the builders due to
r327474.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327477 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 06:25:08 +00:00
Lang Hames
50f412d325 [ORC] Silence a compiler error.
This should fix the builder error at
http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/19006

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327475 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-14 05:23:56 +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
Lang Hames
d8d27ad50d [ORC] Switch to shared_ptr ownership for AsynchronousSymbolQueries.
Queries need to stay alive until each owner has set the values they are
responsible for.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325179 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-14 22:12:56 +00:00
Lang Hames
faeaa17224 [ORC] Refactor the various lookupFlags methods to return the flags map via the
first argument.

This makes lookupFlags more consistent with lookup (which takes the query as the
first argument) and composes better in practice, since lookups are usually
linearly chained: Each lookupFlags can populate the result map based on the
symbols not found in the previous lookup. (If the maps were returned rather than
passed by reference there would have to be a merge step at the end).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323398 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-25 01:43:00 +00:00
Lang Hames
e0267674fd [ORC] Add orc::SymbolResolver, a Orc/Legacy API interop header, and an
orc::SymbolResolver to JITSymbolResolver adapter.

The new orc::SymbolResolver interface uses asynchronous queries for better
performance. (Asynchronous queries with bulk lookup minimize RPC/IPC overhead,
support parallel incoming queries, and expose more available work for
distribution). Existing ORC layers will soon be updated to use the
orc::SymbolResolver API rather than the legacy llvm::JITSymbolResolver API.

Because RuntimeDyld still uses JITSymbolResolver, this patch also includes an
adapter that wraps an orc::SymbolResolver with a JITSymbolResolver API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323073 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-22 03:00:31 +00:00
Lang Hames
c69d5ffd14 [ORC] Add a lookupFlags method to VSO.
lookupFlags returns a SymbolFlagsMap for the requested symbols, along with a
set containing the SymbolStringPtr for any symbol not found in the VSO.

The JITSymbolFlags for each symbol will have been stripped of its transient
JIT-state flags (i.e. NotMaterialized, Materializing).

Calling lookupFlags does not trigger symbol materialization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323060 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-21 03:20:39 +00:00
Lang Hames
11d1660180 [ORC] More cleanup. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323059 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-21 03:20:36 +00:00
Lang Hames
e85f69d55b [ORC] Cleanup. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323057 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-21 02:24:45 +00:00
Lang Hames
08bbfe4e7a [ExecutionEngine] Rename JITSymbol::isStrongDefinition to isStrong.
For symmetry with isWeak, isCommon.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322594 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 20:39:51 +00:00
Lang Hames
b8d3880c38 [ORC] Add a stub ExecutionSession and VModuleKey type.
ExecutionSession will represent a running JIT program.

VModuleKey is a unique key assigned to each module added as part of
an ExecutionSession. The Layer concept will be updated in future to
require a VModuleKey when a module is added.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322336 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-12 00:22:05 +00:00
Lang Hames
c7c090f163 [ORC] Re-apply r321838 again with a workaround for a bug present in the libcxx
version being used on some of the green dragon builders (plus a clang-format).

Workaround: AsynchronousSymbolQuery and VSO want to work with
JITEvaluatedSymbols anyway, so just use them (instead of JITSymbol, which
happens to tickle the bug).

The libcxx bug being worked around was fixed in r276003, and there are plans to
update the offending builders.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@322140 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-10 00:09:38 +00:00
Lang Hames
f8f6c8dfc7 [ORC] Remove AsynchronousSymbolQuery while I debug an issue on one of the
builders.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321941 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-06 20:14:22 +00:00
Lang Hames
173be72e84 [ORC] Yet more debugging output to diagnose test failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321927 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-06 05:19:07 +00:00
Lang Hames
972c9575f0 [ORC] Temporarily adding some redundant asserts / debug output to aid in
debugging a tester failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321920 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-06 01:06:07 +00:00
Lang Hames
cac7dd493a [ORC] Re-apply just the AsynchronousSymbolLookup class from r321838 while I
investigate builder / test failures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321910 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-05 22:50:43 +00:00
Lang Hames
d84b15b1d9 [ORC] Re-revert r321838: Tests are still failing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321858 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-05 03:10:15 +00:00
Lang Hames
9b3761cc7d [ORC] Re-apply r321838 - Addition of new ORC core APIs.
The original commit broke the builders due to a think-o in an assertion:
AsynchronousSymbolQuery's constructor needs to check the callback member
variables, not the constructor arguments.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321853 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-05 02:21:02 +00:00
Lang Hames
60d5d5c881 Revert r321838 -- It broke some of the builders.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321842 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-05 00:29:37 +00:00