Commit Graph

292 Commits

Author SHA1 Message Date
Lang Hames f129d6fb50 [Orc] Try to turn Orc execution unit tests back on for Linux.
The fix in r258324 (plus r258354) should allow Orc execution tests to run on
Linux.

llvm-svn: 258358
2016-01-20 22:16:14 +00:00
Lang Hames 2fe7acb773 [Orc] Refactor ObjectLinkingLayer::addObjectSet to defer loading objects until
they're needed.

Prior to this patch objects were loaded (via RuntimeDyld::loadObject) when they
were added to the ObjectLinkingLayer, but were not relocated and finalized until
a symbol address was requested. In the interim, another object could be loaded
and finalized with the same memory manager, causing relocation/finalization of
the first object to fail (as the first finalization call may have marked the
allocated memory for the first object read-only).

By deferring the loadObject call (and subsequent memory allocations) until an
object file is needed we can avoid prematurely finalizing memory.

llvm-svn: 258185
2016-01-19 21:06:38 +00:00
Lang Hames e4be3c82c0 [Orc] Revert r258031 - it broke the builders.
llvm-svn: 258034
2016-01-18 01:51:51 +00:00
Lang Hames 133f153936 [Orc] Expand a comment explaining a unit test.
llvm-svn: 258032
2016-01-18 01:00:19 +00:00
Lang Hames b41531b31f [Orc] Enable ORC execution unit tests on non-windows platforms.
Previously these were Darwin-only. Since the switch to direct binary emission
of stubs, trampolines and resolver blocks, these should work on other *nix
platforms too.

These tests can be enabled on Windows once known issues with ORC's handling of
Windows symbol mangling (see e.g. https://llvm.org/PR25940) have been fixed.

llvm-svn: 258031
2016-01-18 00:47:25 +00:00
Lang Hames 4d0a5a9ec6 [Orc] Add support for remote JITing to the ORC API.
This patch adds utilities to ORC for managing a remote JIT target. It consists
of:

1. A very primitive RPC system for making calls over a byte-stream.  See
RPCChannel.h, RPCUtils.h.

2. An RPC API defined in the above system for managing memory, looking up
symbols, creating stubs, etc. on a remote target. See OrcRemoteTargetRPCAPI.h.

3. An interface for creating high-level JIT components (memory managers,
callback managers, stub managers, etc.) that operate over the RPC API. See
OrcRemoteTargetClient.h.

4. A helper class for building servers that can handle the RPC calls. See
OrcRemoteTargetServer.h.

The system is designed to work neatly with the existing ORC components and
functionality. In particular, the ORC callback API (and consequently the
CompileOnDemandLayer) is supported, enabling lazy compilation of remote code.

Assuming this doesn't trigger any builder failures, a follow-up patch will be
committed which tests these utilities by using them to replace LLI's existing
remote-JITing demo code.

llvm-svn: 257305
2016-01-11 01:40:11 +00:00
Lang Hames b2b7a3c179 [RuntimeDyld] Add alignment arguments to the reserveAllocationSpace method of
RuntimeDyld::MemoryManager.

The RuntimeDyld::MemoryManager::reserveAllocationSpace method is called when
object files are loaded, and gives clients a chance to pre-allocate memory for
all segments. Previously only the size of each segment (code, ro-data, rw-data)
was supplied but not the alignment. This hasn't caused any problems so far, as
most clients allocate via the MemoryBlock interface which returns page-aligned
blocks. Adding alignment arguments enables finer grained allocation while still
satisfying alignment restrictions.

llvm-svn: 257294
2016-01-10 18:51:50 +00:00
NAKAMURA Takumi 96e303187c OrcJITTests//ObjectLinkingLayerTest.cpp: Appease msc18's C2327. It seems definition of nested class would confuse the context.
llvm\unittests\ExecutionEngine\Orc\ObjectLinkingLayerTest.cpp(115) : error C2327: 'llvm::OrcExecutionTest::TM' : is not a type name, static, or enumerator
  llvm\unittests\ExecutionEngine\Orc\ObjectLinkingLayerTest.cpp(115) : error C2065: 'TM' : undeclared identifier

FYI, "this->TM" was valid even before moving class SectionMemoryManagerWrapper.

llvm-svn: 257290
2016-01-10 15:56:49 +00:00
Lang Hames 859d73ce95 [Orc][RuntimeDyld] Prevent duplicate calls to finalizeMemory on shared memory
managers.

Prior to this patch, recursive finalization (where finalization of one
RuntimeDyld instance triggers finalization of another instance on which the
first depends) could trigger memory access failures: When the inner (dependent)
RuntimeDyld instance and its memory manager are finalized, memory allocated
(but not yet relocated) by the outer instance is locked, and relocation in the
outer instance fails with a memory access error.

This patch adds a latch to the RuntimeDyld::MemoryManager base class that is
checked by a new method: RuntimeDyld::finalizeWithMemoryManagerLocking, ensuring
that shared memory managers are only finalized by the outermost RuntimeDyld
instance.

This allows ORC clients to supply the same memory manager to multiple calls to
addModuleSet. In particular it enables the use of user-supplied memory managers
with the CompileOnDemandLayer which must reuse the supplied memory manager for
each function that is lazily compiled.

llvm-svn: 257263
2016-01-09 19:50:40 +00:00
Eric Christopher a6b96004b5 Reorganize the C API headers to improve build times.
Type specific declarations have been moved to Type.h and error handling
routines have been moved to ErrorHandling.h. Both are included in Core.h
so nothing should change for projects directly including the headers,
but transitive dependencies may be affected.

llvm-svn: 255965
2015-12-18 01:46:52 +00:00
Lang Hames dc7b6c3623 [Orc] Removing traces of takeOwnershipOfBuffers left after r251560.
Patch by Joshua Gerrard. Thanks Joshua!

llvm-svn: 254919
2015-12-07 17:35:56 +00:00
Lang Hames ea39de81e4 [Orc] Rename IndirectStubsManagerBase to IndirectStubsManager.
No functional change.

llvm-svn: 254885
2015-12-06 19:44:45 +00:00
Lang Hames e69b751155 [Orc] Move some code up into the JITCompileCallbackManager base class. NFC.
llvm-svn: 254778
2015-12-04 22:09:19 +00:00
Lang Hames f0f4b4c882 [Orc] Rename JITCompileCallbackManagerBase to JITCompileCallbackManager.
This class is turning into a useful interface, rather than an implementation
detail, so I'm dropping the 'Base' suffix.

No functional change.

llvm-svn: 254693
2015-12-04 02:15:39 +00:00
Eugene Zelenko ffec81ca00 Fix some Clang-tidy modernize warnings, other minor fixes.
Fixed warnings are: modernize-use-override, modernize-use-nullptr and modernize-redundant-void-arg.

Differential revision: http://reviews.llvm.org/D14312

llvm-svn: 252087
2015-11-04 22:32:32 +00:00
David Blaikie a895aa635c Orc: Streamline some lambda usage in a unit test
llvm-svn: 252070
2015-11-04 19:43:24 +00:00
Aaron Ballman 5db085d688 Silence an extra semicolon warning; NFC.
llvm-svn: 252046
2015-11-04 14:40:54 +00:00
Rafael Espindola e63e0188e4 Revert "Revert "[Orc] Directly emit machine code for the x86 resolver block and trampolines.""
This reverts commit r251937.

The test was updated to the new API, bring the API back.

llvm-svn: 251944
2015-11-03 16:40:37 +00:00
Rafael Espindola 2f344637d6 Revert "[Orc] Directly emit machine code for the x86 resolver block and trampolines."
This reverts commit r251933.

It broke the build of examples/Kaleidoscope/Orc/fully_lazy/toy.cpp.

llvm-svn: 251937
2015-11-03 16:25:20 +00:00
Lang Hames a4a227f7e8 [Orc] Directly emit machine code for the x86 resolver block and trampolines.
Bypassing LLVM for this has a number of benefits:

1) Laziness support becomes asm-syntax agnostic (previously lazy jitting didn't
   work on Windows as the resolver block was in Darwin asm).

2) For cross-process JITs, it allows resolver blocks and trampolines to be
   emitted directly in the target process, reducing cross process traffic.

3) It should be marginally faster.

llvm-svn: 251933
2015-11-03 16:10:18 +00:00
Lang Hames fd6e8dc369 [Orc] Expose the compile callback API through the C bindings.
llvm-svn: 251683
2015-10-30 03:20:21 +00:00
Lang Hames 3f88a9ea2c [Orc] Teach IndirectStubsManager to manage an expandable pool of stubs, rather
than a pre-allocated slab of stubs. Also add a convenience method for creating a
single stub, rather than a whole block a time.

llvm-svn: 251658
2015-10-29 22:04:22 +00:00
Lang Hames deadf2a40a [Orc] Rename IndirectStubsManagerBase method 'init' to 'createStubs'.
llvm-svn: 251641
2015-10-29 18:36:27 +00:00
NAKAMURA Takumi 3a063db203 OrcJITTests: Update libdeps corresponding to r251604.
llvm-svn: 251619
2015-10-29 06:40:04 +00:00
Lang Hames 5f7fcef17b [Orc] Add missing file for r251604.
llvm-svn: 251605
2015-10-29 03:53:42 +00:00
Lang Hames 645a22a1b7 [Orc] Add support for RuntimeDyld::setProcessAllSections.
llvm-svn: 251604
2015-10-29 03:52:58 +00:00
Lang Hames 6ac3fe2ab7 [Orc] Require target support for host before running execution unit tests.
Orc unit tests that execute code shouldn't run if the compiler doesn't have
target support for the host machine.

llvm-svn: 251551
2015-10-28 20:08:51 +00:00
NAKAMURA Takumi 13e4b9718c OrcJITTests: Prune unused libdeps.
llvm-svn: 251506
2015-10-28 09:59:50 +00:00
NAKAMURA Takumi 53ae707e39 OrcJITTests: Update libdeps.
llvm-svn: 251504
2015-10-28 09:37:09 +00:00
Craig Topper 9b1534df9d Fix a -Wpessimizing-move warning.
llvm-svn: 251495
2015-10-28 04:54:46 +00:00
Lang Hames 310a5bacb2 [Orc] Disable Orc C API unit tests on non-Darwin while I investigate more
builder failures.

llvm-svn: 251484
2015-10-28 03:12:51 +00:00
Lang Hames 130a7c4152 [Orc] Re-add C bindings for the Orc APIs, with a fix to remove the union that
was causing builder failures.

The bindings were originally added in r251472, and reverted in r251473 due to
the builder failures.

llvm-svn: 251482
2015-10-28 02:40:04 +00:00
Lang Hames f6bd01097a [Orc] Revert the C bindngs commit, r251472, while I debug some builder failures.
llvm-svn: 251473
2015-10-28 01:03:09 +00:00
Lang Hames ec6151066f [Orc] Add experimental C bindings for Orc.
llvm-svn: 251472
2015-10-28 00:28:26 +00:00
Lang Hames 4a51e5ddae [Orc] Fix indentation.
llvm-svn: 251423
2015-10-27 17:45:48 +00:00
Duncan P. N. Exon Smith c8925b1871 unittests: Remove implicit ilist iterator conversions, NFC
llvm-svn: 250843
2015-10-20 18:30:20 +00:00
Lang Hames c005656052 [Orc] Make CompileOnDemandLayer::findSymbol call BaseLayer::findSymbol if no
symbol definition is found in the logical dylibs.

llvm-svn: 250796
2015-10-20 04:35:02 +00:00
Hans Wennborg 083ca9bb32 Fix Clang-tidy modernize-use-nullptr warnings in source directories and generated files; other minor cleanups.
Patch by Eugene Zelenko!

Differential Revision: http://reviews.llvm.org/D13321

llvm-svn: 249482
2015-10-06 23:24:35 +00:00
Chandler Carruth 7b560d40bd [PM/AA] Rebuild LLVM's alias analysis infrastructure in a way compatible
with the new pass manager, and no longer relying on analysis groups.

This builds essentially a ground-up new AA infrastructure stack for
LLVM. The core ideas are the same that are used throughout the new pass
manager: type erased polymorphism and direct composition. The design is
as follows:

- FunctionAAResults is a type-erasing alias analysis results aggregation
  interface to walk a single query across a range of results from
  different alias analyses. Currently this is function-specific as we
  always assume that aliasing queries are *within* a function.

- AAResultBase is a CRTP utility providing stub implementations of
  various parts of the alias analysis result concept, notably in several
  cases in terms of other more general parts of the interface. This can
  be used to implement only a narrow part of the interface rather than
  the entire interface. This isn't really ideal, this logic should be
  hoisted into FunctionAAResults as currently it will cause
  a significant amount of redundant work, but it faithfully models the
  behavior of the prior infrastructure.

- All the alias analysis passes are ported to be wrapper passes for the
  legacy PM and new-style analysis passes for the new PM with a shared
  result object. In some cases (most notably CFL), this is an extremely
  naive approach that we should revisit when we can specialize for the
  new pass manager.

- BasicAA has been restructured to reflect that it is much more
  fundamentally a function analysis because it uses dominator trees and
  loop info that need to be constructed for each function.

All of the references to getting alias analysis results have been
updated to use the new aggregation interface. All the preservation and
other pass management code has been updated accordingly.

The way the FunctionAAResultsWrapperPass works is to detect the
available alias analyses when run, and add them to the results object.
This means that we should be able to continue to respect when various
passes are added to the pipeline, for example adding CFL or adding TBAA
passes should just cause their results to be available and to get folded
into this. The exception to this rule is BasicAA which really needs to
be a function pass due to using dominator trees and loop info. As
a consequence, the FunctionAAResultsWrapperPass directly depends on
BasicAA and always includes it in the aggregation.

This has significant implications for preserving analyses. Generally,
most passes shouldn't bother preserving FunctionAAResultsWrapperPass
because rebuilding the results just updates the set of known AA passes.
The exception to this rule are LoopPass instances which need to preserve
all the function analyses that the loop pass manager will end up
needing. This means preserving both BasicAAWrapperPass and the
aggregating FunctionAAResultsWrapperPass.

Now, when preserving an alias analysis, you do so by directly preserving
that analysis. This is only necessary for non-immutable-pass-provided
alias analyses though, and there are only three of interest: BasicAA,
GlobalsAA (formerly GlobalsModRef), and SCEVAA. Usually BasicAA is
preserved when needed because it (like DominatorTree and LoopInfo) is
marked as a CFG-only pass. I've expanded GlobalsAA into the preserved
set everywhere we previously were preserving all of AliasAnalysis, and
I've added SCEVAA in the intersection of that with where we preserve
SCEV itself.

One significant challenge to all of this is that the CGSCC passes were
actually using the alias analysis implementations by taking advantage of
a pretty amazing set of loop holes in the old pass manager's analysis
management code which allowed analysis groups to slide through in many
cases. Moving away from analysis groups makes this problem much more
obvious. To fix it, I've leveraged the flexibility the design of the new
PM components provides to just directly construct the relevant alias
analyses for the relevant functions in the IPO passes that need them.
This is a bit hacky, but should go away with the new pass manager, and
is already in many ways cleaner than the prior state.

Another significant challenge is that various facilities of the old
alias analysis infrastructure just don't fit any more. The most
significant of these is the alias analysis 'counter' pass. That pass
relied on the ability to snoop on AA queries at different points in the
analysis group chain. Instead, I'm planning to build printing
functionality directly into the aggregation layer. I've not included
that in this patch merely to keep it smaller.

Note that all of this needs a nearly complete rewrite of the AA
documentation. I'm planning to do that, but I'd like to make sure the
new design settles, and to flesh out a bit more of what it looks like in
the new pass manager first.

Differential Revision: http://reviews.llvm.org/D12080

llvm-svn: 247167
2015-09-09 17:55:00 +00:00
Lang Hames a4b3d4ec3e Add a global mapping layer for Orc. Adapted from a patch by Andy Somogyi.
Thanks Andy!

llvm-svn: 246226
2015-08-27 22:20:05 +00:00
David Blaikie 1bfe6c9932 Fix UB in MCJIT test cases that relied on union type punning
Reviewers: lhames, aaron.ballman

Differential Revision: http://reviews.llvm.org/D11779

llvm-svn: 244644
2015-08-11 18:17:45 +00:00
Lang Hames 1423bd05b5 [MCJIT] Fix a cast warning in the unit-test introduced in r243589.
Thanks to Aaron Ballman for spotting this.

llvm-svn: 243891
2015-08-03 18:03:40 +00:00
NAKAMURA Takumi 1c84ff5f60 MCJITTests/MCJITCAPITest.cpp: Try to appease i686-win32.
llvm-svn: 243639
2015-07-30 13:06:53 +00:00
Lang Hames 38008a5e36 [MCJIT] Fix a memory leak in a unit test that was introduced in r243589.
llvm-svn: 243609
2015-07-30 02:05:37 +00:00
Lang Hames 3393cfdef8 [MCJIT] Fix PR20656 by teaching MCJIT to honor ExecutionEngine's global mapping.
This is important for users of the C API who can't supply custom symbol
resolvers yet.

llvm-svn: 243589
2015-07-29 23:12:33 +00:00
Lang Hames 6f7012c2a1 [ExecutionEngine] Re-apply r241962 with fixes for ARM.
Patch by Pierre-Andre Saulais. Thanks Pierre-Andre!

llvm-svn: 242213
2015-07-14 22:11:10 +00:00
Renato Golin 9d9be7dd36 Revert "[ExecutionEngine] Use std::function rather than a function pointer for the LazyFunctionCreator."
This reverts commit r241962, as it was breaking all ARM buildbots.

It also reverts the two subsequent related commits:

r241974: "[ExecutionEngine] Add a static cast to the unittest for r241962 to suppress a warning."

r241973: "[ExecutionEngine] Remove cruft and fix a couple of warnings in the test case for r241962."
llvm-svn: 241983
2015-07-11 13:42:48 +00:00
Lang Hames b7a1176eed [ExecutionEngine] Add a static cast to the unittest for r241962 to suppress a
warning.

llvm-svn: 241974
2015-07-11 02:07:28 +00:00
Lang Hames 78bd9e5848 [ExecutionEngine] Remove cruft and fix a couple of warnings in the test case for
r241962.

llvm-svn: 241973
2015-07-11 01:59:04 +00:00
Lang Hames 11e086d275 [ExecutionEngine] Use std::function rather than a function pointer for the
LazyFunctionCreator.

Patch by Pierre-Andre Saulais. Thanks Pierre!

llvm-svn: 241962
2015-07-10 22:56:47 +00:00