1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
Commit Graph

375 Commits

Author SHA1 Message Date
Lang Hames
4bba9adcc4 [Orc] Add support for emitting indirect stubs directly into the JIT target's
memory, rather than representing the stubs in IR. Update the CompileOnDemand
layer to use this functionality.

Directly emitting stubs is much cheaper than building them in IR and codegen'ing
them (see below). It also plays well with remote JITing - stubs can be emitted
directly in the target process, rather than having to send them over the wire.

The downsides are:

(1) Care must be taken when resolving symbols, as stub symbols are held in a
    separate symbol table. This is only a problem for layer writers and other
    people using this API directly. The CompileOnDemand layer hides this detail.

(2) Aliases of function stubs can't be symbolic any more (since there's no
    symbol definition in IR), but must be converted into a constant pointer
    expression. This means that modules containing aliases of stubs cannot be
    cached. In practice this is unlikely to be a problem: There's no benefit to
    caching such a module anyway.

On balance I think the extra performance is more than worth the trade-offs: In a
simple stress test with 10000 dummy functions requiring stubs and a single
executed "hello world" main function, directly emitting stubs reduced user time
for JITing / executing by over 90% (1.5s for IR stubs vs 0.1s for direct
emission).

llvm-svn: 250712
2015-10-19 17:43:51 +00:00
Lang Hames
c41c667ccd [Orc] Enable user supplied partitioning functors in the CompileOnDemand layer.
Previously the CompileOnDemand layer always created single-function partitions.
In theory this new API allows for more interesting partitions, though this has
not been well tested yet.

llvm-svn: 249623
2015-10-07 21:53:41 +00:00
Mehdi Amini
be5a5fb8a7 Fix lli with OrcLazyJIT: the default DataLayout was used.
Set the correct one using the TargetMachine instead.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 243664
2015-07-30 17:29:33 +00:00
Mehdi Amini
9f0c09e5bf Remove access to the DataLayout in the TargetMachine
Summary:
Replace getDataLayout() with a createDataLayout() method to make
explicit that it is intended to create a DataLayout only and not
accessing it for other purpose.

This change is the last of a series of commits dedicated to have a
single DataLayout during compilation by using always the one owned
by the module.

Reviewers: echristo

Subscribers: jholewinski, llvm-commits, rafael, yaron.keren

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

(cherry picked from commit 5609fc56bca971e5a7efeaa6ca4676638eaec5ea)

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 243114
2015-07-24 16:04:22 +00:00
Mehdi Amini
3a4451076e Revert "Remove access to the DataLayout in the TargetMachine"
This reverts commit 0f720d984f419c747709462f7476dff962c0bc41.

It breaks clang too badly, I need to prepare a proper patch for clang
first.

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 243089
2015-07-24 03:36:55 +00:00
Mehdi Amini
30b6ee8541 Remove access to the DataLayout in the TargetMachine
Summary:
Replace getDataLayout() with a createDataLayout() method to make
explicit that it is intended to create a DataLayout only and not
accessing it for other purpose.

This change is the last of a series of commits dedicated to have a
single DataLayout during compilation by using always the one owned
by the module.

Reviewers: echristo

Subscribers: jholewinski, llvm-commits, rafael, yaron.keren

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

(cherry picked from commit 5609fc56bca971e5a7efeaa6ca4676638eaec5ea)

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 243083
2015-07-24 01:44:39 +00:00
Rafael Espindola
afc94ffbf8 Simplify a few uses of remove_filename by using parent_path instead.
llvm-svn: 242334
2015-07-15 21:24:07 +00:00
Rafael Espindola
72dc307fa0 Simplify the Mangler interface now that DataLayout is mandatory.
We only need to pass in a DataLayout when mangling a raw string, not when
constructing the mangler.

llvm-svn: 240405
2015-06-23 13:59:29 +00:00
Daniel Sanders
df4e26d91a Replace string GNU Triples with llvm::Triple in TargetMachine::getTargetTriple(). NFC.
Summary:
This continues the patch series to eliminate StringRef forms of GNU triples
from the internals of LLVM that began in r239036.

Reviewers: rengolin

Reviewed By: rengolin

Subscribers: llvm-commits, rengolin

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

llvm-svn: 239815
2015-06-16 13:15:50 +00:00
Lang Hames
1a8adf3075 [Orc] Tidy up initialization based on review feedback for r239561 from dblaikie.
NFC.

llvm-svn: 239645
2015-06-12 23:13:06 +00:00
Lang Hames
920fcbb99b [Orc] Fix a bug in the CompileOnDemand layer where stub decls were not cloned
into partitions. Also, add an option to clone stub definitions (not just decls)
into partitions: these definitions could be inlined in some places to avoid the
overhead of calling via the stub.

Found by inspection - no test case yet, although I plan to add a unit test for
this once the CompileOnDemand layer refactoring settles down.

llvm-svn: 239640
2015-06-12 21:31:15 +00:00
Douglas Katzman
5eb858225c Wrap some long lines in LLVMBuild files. NFC
As suggested by jroelofs in a prior review (D9752),
it makes sense to generally prefer multi-line format.

llvm-svn: 239632
2015-06-12 18:44:57 +00:00
Lang Hames
3915aa0469 [Orc] Remove some unnecesary includes and whitespace that slipped in to r239561.
NFC.

llvm-svn: 239564
2015-06-11 22:12:24 +00:00
Lang Hames
02dba28dd5 [Orc] Make partition identification in the CompileOnDemand layer lazy.
This also breaks out the logical dylib symbol resolution logic.

llvm-svn: 239561
2015-06-11 21:45:19 +00:00
Lang Hames
2393a461f7 [lli] Make the OptLevel (-O=<char>) option accessible to the lazy JIT.
No test case - this only affects generated code performance.

llvm-svn: 239383
2015-06-09 02:43:27 +00:00
Sanjay Patel
6e86f62fd3 add missing dependency on Target lib for tools
This was exposed by r238842 (which was reverted by r238900)
when doing a CMake build with -DBUILD_SHARED_LIBS=ON.

llvm-svn: 238953
2015-06-03 19:07:51 +00:00
Benjamin Kramer
0e31955b32 Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types
If the type isn't trivially moveable emplace can skip a potentially
expensive move. It also saves a couple of characters.


Call sites were found with the ASTMatcher + some semi-automated cleanup.

memberCallExpr(
    argumentCountIs(1), callee(methodDecl(hasName("push_back"))),
    on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))),
    hasArgument(0, bindTemporaryExpr(
                       hasType(recordDecl(hasNonTrivialDestructor())),
                       has(constructExpr()))),
    unless(isInTemplateInstantiation()))

No functional change intended.

llvm-svn: 238602
2015-05-29 19:43:39 +00:00
Eric Christopher
2ba04d1116 Migrate existing backends that care about software floating point
to use the information in the module rather than TargetOptions.

We've had and clang has used the use-soft-float attribute for some
time now so have the backends set a subtarget feature based on
a particular function now that subtargets are created based on
functions and function attributes.

For the one middle end soft float check go ahead and create
an overloadable TargetLowering::useSoftFloat function that
just checks the TargetSubtargetInfo in all cases.

Also remove the command line option that hard codes whether or
not soft-float is set by using the attribute for all of the
target specific test cases - for the generic just go ahead and
add the attribute in the one case that showed up.

llvm-svn: 237079
2015-05-12 01:26:05 +00:00
Lang Hames
a366b4ef77 [Orc] Reapply r236465 with fixes for the MSVC bots.
llvm-svn: 236506
2015-05-05 17:37:18 +00:00
Lang Hames
1ee1ff3529 [Orc] Revert r236465 - It broke the Windows bots.
Looks like the usual missing explicit move-constructor issue with MSVC. I should
have a fix shortly.

llvm-svn: 236472
2015-05-04 23:30:01 +00:00
Pete Cooper
601370f079 Add TransformUtils dependency to lli.
After r236465, Orc uses ValueMaterializer and so needs to link against TransformUtils to get the ValueMaterializer::anchor().

llvm-svn: 236467
2015-05-04 22:33:39 +00:00
Lang Hames
63e2fcbb79 [Orc] Refactor the compile-on-demand layer to make module partitioning lazy,
and avoid cloning unused decls into every partition.

Module partitioning showed up as a source of significant overhead when I
profiled some trivial test cases. Avoiding the overhead of partitionging
for uncalled functions helps to mitigate this.

This change also means that it is no longer necessary to have a
LazyEmittingLayer underneath the CompileOnDemand layer, since the
CompileOnDemandLayer will not extract or emit function bodies until they are
called.

llvm-svn: 236465
2015-05-04 22:03:10 +00:00
Richard Trieu
b05d298163 Fix -Wpessimizing-move warnings by removing std::move calls.
llvm-svn: 236278
2015-04-30 23:07:00 +00:00
Eric Christopher
2b1be84066 Remove the JITEmitDebugInfo TargetOptions as they're only set and
not used anywhere in llvm.

llvm-svn: 235265
2015-04-19 03:20:51 +00:00
NAKAMURA Takumi
bbd7024ce1 lli/OrcLazyJIT.cpp: Use <cstdio> for printf(3) introduced in r234908.
llvm-svn: 235175
2015-04-17 10:01:30 +00:00
Lang Hames
47006e855e [Orc] Refactor the CompileOnDemandLayer to make its addModuleSet method
signature match the other layers.

This makes it possible to compose other layers (e.g. IRTransformLayer) on top
of CompileOnDemandLayer.

llvm-svn: 235029
2015-04-15 18:26:24 +00:00
Lang Hames
1f8eae7989 [Orc] Reapply r234815, outputting via stdout instead.
llvm-svn: 234908
2015-04-14 16:58:05 +00:00
Aaron Ballman
8a1833659d Silencing a -Wreturn-type warning, as the switch is fully-covered; NFC.
llvm-svn: 234884
2015-04-14 13:26:11 +00:00
Lang Hames
9b402995fc [Orc] Disambiguate call to make_unique. This should fix the builders broken by
r234805.

llvm-svn: 234806
2015-04-13 22:33:05 +00:00
Lang Hames
dd40ba2a66 [Orc] Add an Orc layer for applying arbitrary transforms to IR, use it to add
debugging output to the LLI orc-lazy JIT, and update the orc-lazy "hello.ll"
test to actually test for lazy compilation.

llvm-svn: 234805
2015-04-13 22:12:54 +00:00
Alexander Kornienko
71412ece39 Use 'override/final' instead of 'virtual' for overridden methods
The patch is generated using clang-tidy misc-use-override check.

This command was used:

  tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \
    -checks='-*,misc-use-override' -header-filter='llvm|clang' \
    -j=32 -fix -format

http://reviews.llvm.org/D8925

llvm-svn: 234679
2015-04-11 02:11:45 +00:00
Lang Hames
3dbd9b3b85 [Orc] Add support classes for inspecting and running C++ static ctor/dtors, and
use these to add support for C++ static ctors/dtors to the Orc-lazy JIT in LLI.

Replace the trivial_retval_1 regression test - the new 'hello' test is covering
strictly more code. 

llvm-svn: 233885
2015-04-02 04:34:45 +00:00
Lang Hames
cd2a4f7ef3 [Orc] Reflect process symbols into the LLI Orc-lazy JIT.
This makes symbol resolution essentially identical between MCJIT and the LLI
Orc-lazy JIT.

llvm-svn: 233786
2015-04-01 04:42:56 +00:00
Lang Hames
086c48c2e6 [Orc] Separate callback manager selection from callback manager construction for
OrcLazyJIT in lli.

Separating these concerns enables more natural error handling.

llvm-svn: 233579
2015-03-30 18:37:01 +00:00
Lang Hames
27fb68307a [MCJIT][Orc] Refactor RTDyldMemoryManager, weave RuntimeDyld::SymbolInfo through
MCJIT.

This patch decouples the two responsibilities of the RTDyldMemoryManager class,
memory management and symbol resolution, into two new classes:
RuntimeDyld::MemoryManager and RuntimeDyld::SymbolResolver.

The symbol resolution interface is modified slightly, from:

  uint64_t getSymbolAddress(const std::string &Name);

to:

  RuntimeDyld::SymbolInfo findSymbol(const std::string &Name);

The latter passes symbol flags along with symbol addresses, allowing RuntimeDyld
and others to reason about non-strong/non-exported symbols.


The memory management interface removes the following method:

  void notifyObjectLoaded(ExecutionEngine *EE,
                          const object::ObjectFile &) {}

as it is not related to memory management. (Note: Backwards compatibility *is*
maintained for this method in MCJIT and OrcMCJITReplacement, see below).


The RTDyldMemoryManager class remains in-tree for backwards compatibility.
It inherits directly from RuntimeDyld::SymbolResolver, and indirectly from
RuntimeDyld::MemoryManager via the new MCJITMemoryManager class, which
just subclasses RuntimeDyld::MemoryManager and reintroduces the
notifyObjectLoaded method for backwards compatibility).

The EngineBuilder class retains the existing method:

  EngineBuilder&
  setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager> mcjmm);

and includes two new methods:

  EngineBuilder&
  setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM);

  EngineBuilder&
  setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR);

Clients should use EITHER:

A single call to setMCJITMemoryManager with an RTDyldMemoryManager.

OR (exclusive)

One call each to each of setMemoryManager and setSymbolResolver.

This patch should be fully compatible with existing uses of RTDyldMemoryManager.
If it is not it should be considered a bug, and the patch either fixed or
reverted.

If clients find the new API to be an improvement the goal will be to deprecate
and eventually remove the RTDyldMemoryManager class in favor of the new classes.

llvm-svn: 233509
2015-03-30 03:37:06 +00:00
Lang Hames
efdbea8d66 [Orc] Remove another unnecessary typedef.
llvm-svn: 233184
2015-03-25 12:32:36 +00:00
Lang Hames
66e55d58ea [Orc][lli] Add a very simple Orc-based lazy JIT to lli.
This ensures that we're building and testing the CompileOnDemand layer, at least
in a basic way.

Currently x86-64 only, and with limited to no library calls enabled (depending
on host platform). Patches welcome. ;)

To enable access to the lazy JIT, this patch replaces the '-use-orcmcjit' lli
option with a new option:
'-jit-kind={ mcjit | orc-mcjit | orc-lazy }'.

All regression tests are updated to use the new option, and one trivial test of
the new lazy JIT is added.

llvm-svn: 233182
2015-03-25 12:11:48 +00:00
Benjamin Kramer
45a545b9c6 Purge unused includes throughout libSupport.
NFC.

llvm-svn: 232976
2015-03-23 18:07:13 +00:00
Rafael Espindola
381311d5f0 Fix cmake build.
llvm-svn: 232663
2015-03-18 20:21:06 +00:00
Reid Kleckner
8387c0d5ea CMake: Disable ENABLE_EXPORTS for executables with MSVC
The MSVC linker won't produce a .lib file for an executable that doesn't
export anything, and LLVM doesn't maintain dllexport annotations or .def
files listing all C++ symbols. It also doesn't support exporting all
symbols, like binutils ld.

CMake 3.2 changed the Ninja generator to list both the .exe and .lib
files as outputs of executable build targets. Ninja would always re-link
executables with ENABLE_EXPORTS because the .lib output file was not
present, and therefore the target was out of date.

llvm-svn: 232662
2015-03-18 20:09:13 +00:00
David Majnemer
6a0039a013 Replace a few instances of NULL with nullptr.
llvm-svn: 230599
2015-02-26 01:10:49 +00:00
NAKAMURA Takumi
0dd5b347b1 [CMake] Add RuntimeDyld to libdeps corresponding to r229343.
llvm-svn: 229351
2015-02-16 02:13:30 +00:00
Zachary Turner
f290870a28 Fix lli after the DebugInfo move.
llvm-svn: 227594
2015-01-30 18:42:03 +00:00
Zachary Turner
9a7f59f9ea Move DebugInfo to DebugInfo/DWARF.
In preparation for adding PDB support to LLVM, this moves the
DWARF parsing code to its own subdirectory under DebugInfo, and
renames LLVMDebugInfo to LLVMDebugInfoDWARF.

This is purely a mechanical / build system change.

Differential Revision: http://reviews.llvm.org/D7269
Reviewed by: Eric Christopher

llvm-svn: 227586
2015-01-30 18:07:45 +00:00
Lang Hames
128e9d3459 [Orc] Add orcjit to the dependencies list in the Makefile for lli.
This should fix a few more broken bots.

llvm-svn: 226973
2015-01-24 00:01:29 +00:00
Lang Hames
d130bea052 [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.

llvm-svn: 226940
2015-01-23 21:25:00 +00:00
Chris Bieneman
9a06c4c87f Assigning and copying command line option objects shouldn't be allowed.
Summary:
The default copy and assignment operators for these objects probably don't actually do what the clients intend, so they should be deleted.

Places using the assignment operator to set the value of an option should cast to the option's data type first to call into the override for operator=. Places using the copy constructor just need to be changed to not copy (i.e. passing by const reference instead of value).

Reviewers: dexonsmith, chandlerc

Subscribers: llvm-commits

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

llvm-svn: 226762
2015-01-22 01:49:59 +00:00
Yaron Keren
718583fb16 Silence gcc 4.9.1 warning 'xyz' is used uninitialized in this function.
In release builds this is actually possible as without asserts there is 
no testing of the actual read bytes and the variables could be partially
uninitialized.

llvm-svn: 224114
2014-12-12 11:07:51 +00:00
Lang Hames
c0a1957308 [MCJIT] Unique-ptrify the RTDyldMemoryManager member of MCJIT. NFC.
llvm-svn: 223183
2014-12-03 00:51:19 +00:00
Duncan P. N. Exon Smith
57cead164b DebugIR: Delete -debug-ir
llvm-svn: 222945
2014-11-29 03:15:47 +00:00