Commit Graph

22 Commits

Author SHA1 Message Date
Lang Hames
63cc4f56a9 [Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.

These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.

Included in this patch:

1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
   components for building JIT infrastructure.
   Implementation code for these headers lives in lib/ExecutionEngine/Orc.

2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
   new components.

3) Minor changes to RTDyldMemoryManager needed to support the new components.
   These changes should not impact existing clients.

4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
   OrcMCJITReplacement class as its underlying execution engine, rather than
   MCJIT itself.

Tests to follow shortly.

Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226940 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-23 21:25:00 +00:00
Lang Hames
216e532dc1 [MCJIT] Reapply r222828 and r222810-r222812 with fix for MSVC move-op issues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222840 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26 16:54:40 +00:00
Aaron Ballman
19afe67157 Reverting r222828 and r222810-r222812 as they broke the build on Windows.
http://bb.pgr.jp/builders/ninja-clang-i686-msc17-R/builds/11753

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222833 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26 15:27:39 +00:00
Lang Hames
7acaefabf6 [MCJIT] Clean up RuntimeDyld's quirky object-ownership/modification scheme.
Previously, when loading an object file, RuntimeDyld (1) took ownership of the
ObjectFile instance (and associated MemoryBuffer), (2) potentially modified the
object in-place, and (3) returned an ObjectImage that managed ownership of the
now-modified object and provided some convenience methods. This scheme accreted
over several years as features were tacked on to RuntimeDyld, and was both
unintuitive and unsafe (See e.g. http://llvm.org/PR20722).

This patch fixes the issue by removing all ownership and in-place modification
of object files from RuntimeDyld. Existing behavior, including debugger
registration, is preserved.

Noteworthy changes include:

(1) ObjectFile instances are now passed to RuntimeDyld by const-ref.
(2) The ObjectImage and ObjectBuffer classes have been removed entirely, they
    existed to model ownership within RuntimeDyld, and so are no longer needed.
(3) RuntimeDyld::loadObject now returns an instance of a new class,
    RuntimeDyld::LoadedObjectInfo, which can be used to construct a modified
    object suitable for registration with the debugger, following the existing
    debugger registration scheme.
(4) The JITRegistrar class has been removed, and the GDBRegistrar class has been
    re-written as a JITEventListener.

This should fix http://llvm.org/PR20722 .



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222810 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-26 06:53:26 +00:00
Lang Hames
e2ef4419a8 [MCJIT] Turn the getSymbolAddress free function created in r218626 into a static
member of RTDyldMemoryManager (and rename to getSymbolAddressInProcess).

The functionality this provides is very specific to RTDyldMemoryManager, so it
makes sense to keep it in that class to avoid accidental re-use.

No functional change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218741 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 04:11:13 +00:00
David Blaikie
03b4667e14 Unit test r218187, changing RTDyldMemoryManager::getSymbolAddress's behavior favor mangled lookup over unmangled lookup.
The contract of this function seems problematic (fallback in either
direction seems like it could produce bugs in one client or another),
but here's some tests for its current behavior, at least. See the
commit/review thread of r218187 for more discussion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218626 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-29 21:25:13 +00:00
Benjamin Kramer
00e08fcaa0 Canonicalize header guards into a common format.
Add header guards to files that were missing guards. Remove #endif comments
as they don't seem common in LLVM (we can easily add them back if we decide
they're useful)

Changes made by clang-tidy with minor tweaks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 16:26:38 +00:00
Craig Topper
0b6cb7104b [C++11] More 'nullptr' conversion. In some cases just using a boolean check instead of comparing to nullptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206252 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-15 06:32:26 +00:00
Lang Hames
061a739395 Extend RTDyld API to enable optionally precomputing the total amount of memory
required for all sections in a module. This can be useful when targets or
code-models place strict requirements on how sections must be laid out
in memory.

If RTDyldMemoryManger::needsToReserveAllocationSpace() is overridden to return
true then the JIT will call the following method on the memory manager, which
can be used to preallocate the necessary memory.

void RTDyldMemoryManager::reserveAllocationSpace(uintptr_t CodeSize,
                                                 uintptr_t DataSizeRO,
                                                 uintptr_t DataSizeRW)

Patch by Vaidas Gasiunas. Thanks very much Viadas!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201259 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-12 21:30:07 +00:00
Chandler Carruth
974a445bd9 Re-sort all of the includes with ./utils/sort_includes.py so that
subsequent changes are easier to review. About to fix some layering
issues, and wanted to separate out the necessary churn.

Also comment and sink the include of "Windows.h" in three .inc files to
match the usage in Memory.inc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198685 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-07 11:48:04 +00:00
Andrew Kaylor
43507d026b Adding support for deregistering EH frames with MCJIT.
Patch by Yaron Keren



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192753 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-16 00:14:21 +00:00
Andrew Kaylor
528f6d787b Adding multiple object support to MCJIT EH frame handling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192504 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-11 21:25:48 +00:00
Andrew Kaylor
b868e9101c Adding support and tests for multiple module handling in lli
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191938 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-04 00:49:38 +00:00
Filip Pizlo
6eb43d2956 This threads SectionName through the allocateCodeSection/allocateDataSection APIs, both in C++ and C land.
It's useful for the memory managers that are allocating a section to know what the name of the section is.  
At a minimum, this is useful for low-level debugging - it's customary for JITs to be able to tell you what 
memory they allocated, and as part of any such dump, they should be able to tell you some meta-data about 
what each allocation is for.  This allows clients that supply their own memory managers to do this.  
Additionally, we also envision the SectionName being useful for passing meta-data from within LLVM to an LLVM 
client.

This changes both the C and C++ APIs, and all of the clients of those APIs within LLVM.  I'm assuming that 
it's safe to change the C++ API because that API is allowed to change.  I'm assuming that it's safe to change 
the C API because we haven't shipped the API in a release yet (LLVM 3.3 doesn't include the MCJIT memory 
management C API).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191804 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-02 00:59:25 +00:00
Andrew Kaylor
8e9ec01534 Adding multiple module support for MCJIT.
Tests to follow.

PIC with small code model and  EH frame handling will not work with multiple modules.  There are also some rough edges to be smoothed out for remote target support.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191722 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 01:47:35 +00:00
Filip Pizlo
6cfed36338 Expose the RTDyldMemoryManager through the C API. This allows clients of
the C API to provide their own way of allocating JIT memory (both code 
and data) and finalizing memory permissions (page protections, cache 
flush).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182448 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-22 02:46:43 +00:00
Filip Pizlo
a4ea4a7203 Put RTDyldMemoryManager into its own file, and make it linked into
libExecutionEngine. Move method implementations that aren't specific to 
allocation out of SectionMemoryManager and into RTDyldMemoryManager.

This is in preparation for exposing RTDyldMemoryManager through the C 
API.

This is a fixed version of r182407 and r182411. That first revision 
broke builds because I forgot to move the conditional includes of 
various POSIX headers from SectionMemoryManager into 
RTDyldMemoryManager. Those includes are necessary because of how 
getPointerToNamedFunction works around the glibc libc_nonshared.a thing. 
The latter revision still broke things because I forgot to include 
llvm/Config/config.h.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182418 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21 20:24:07 +00:00
Filip Pizlo
50f19a906a Roll out r182411 and 182412 because it's still broken.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182415 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21 20:17:14 +00:00
Filip Pizlo
876af64ac7 Put RTDyldMemoryManager into its own file, and make it linked into
libExecutionEngine. Move method implementations that aren't specific to 
allocation out of SectionMemoryManager and into RTDyldMemoryManager.

This is in preparation for exposing RTDyldMemoryManager through the C 
API.

This is a fixed version of r182407. That revision broke builds because I 
forgot to move the conditional includes of various POSIX headers from 
SectionMemoryManager into RTDyldMemoryManager. Those includes are 
necessary because of how getPointerToNamedFunction works around the 
glibc libc_nonshared.a thing.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182411 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21 20:07:12 +00:00
Filip Pizlo
1441bf7a41 Roll out r182407 and r182408 because they broke builds.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182409 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21 20:03:01 +00:00
Filip Pizlo
52755c472a Expose the RTDyldMemoryManager through the C API. This allows clients of
the C API to provide their own way of allocating JIT memory (both code 
and data) and finalizing memory permissions (page protections, cache 
flush).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182408 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21 20:00:56 +00:00
Filip Pizlo
3bcc3e6f63 Put RTDyldMemoryManager into its own file, and make it linked into
libExecutionEngine. Move method implementations that aren't specific to 
allocation out of SectionMemoryManager and into RTDyldMemoryManager.

This is in preparation for exposing RTDyldMemoryManager through the C 
API.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182407 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-21 19:56:00 +00:00