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

370 Commits

Author SHA1 Message Date
Lang Hames
bde6fbe904 [RuntimeDyld] Strip leading '_' from symbols on 32-bit windows in
RTDyldMemoryManager::getSymbolAddressInProcess()

This should allow JIT'd code for win32 to find in-process symbols. See
http://llvm.org/PR28699 .

Patch by James Holderness. Thanks James!

llvm-svn: 279016
2016-08-18 00:22:34 +00:00
David Majnemer
85242fb9f9 Use the range variant of find instead of unpacking begin/end
If the result of the find is only used to compare against end(), just
use is_contained instead.

No functionality change is intended.

llvm-svn: 278433
2016-08-11 22:21:41 +00:00
Lang Hames
9a3ce89b6d [ExecutionEngine][MCJIT][Orc] Replace RuntimeDyld::SymbolInfo with JITSymbol.
This patch replaces RuntimeDyld::SymbolInfo with JITSymbol: A symbol class
that is capable of lazy materialization (i.e. the symbol definition needn't be
emitted until the address is requested). This can be used to support common
and weak symbols in the JIT (though this is not implemented in this patch).

For consistency, RuntimeDyld::SymbolResolver is renamed to JITSymbolResolver.

For space efficiency a new class, JITEvaluatedSymbol, is introduced that
behaves like the old RuntimeDyld::SymbolInfo - i.e. it is just a pair of an
address and symbol flags. Instances of JITEvaluatedSymbol can be used in
symbol-tables to avoid paying the space cost of the materializer.

llvm-svn: 277386
2016-08-01 20:49:11 +00:00
Justin Lebar
fb1b33aafe Fix warning in ObjectTransformLayerTest.
Doing "I++" inside of an EXPECT_* triggers

  warning: expression with side effects has no effect in an unevaluated context

because EXPECT_* partially expands to

  EqHelper<(sizeof(::testing::internal::IsNullLiteralHelper(MockObjects[I++] + 1)) == 1)>

which is an unevaluated context.

llvm-svn: 275293
2016-07-13 18:27:49 +00:00
Lang Hames
96b587081e [Orc] Add conversion to/from RuntimeDyld::SymbolInfo for JITSymbol.
This tidies up some code that was manually constructing RuntimeDyld::SymbolInfo
instances from JITSymbols. It will save more mess in the future when
JITSymbol::getAddress is extended to return an Expected<TargetAddress> rather
than just a TargetAddress, since we'll be able to embed the error checking in
the conversion.

llvm-svn: 271350
2016-05-31 23:14:26 +00:00
Rafael Espindola
878239cf88 Delete dead code. Reloc::Default is the default.
llvm-svn: 269954
2016-05-18 16:19:20 +00:00
Lang Hames
4b5f32caf6 [ORC] clang-format code that was touched in r267457. NFC.
Commit r267457 made a lot of type-substitutions threw off code formatting and
alignment. This patch should tidy those changes up.

llvm-svn: 267475
2016-04-25 21:21:20 +00:00
Lang Hames
d32e77ff0e [ORC] Thread Error/Expected through the RPC library.
This replaces use of std::error_code and ErrorOr in the ORC RPC support library
with Error and Expected. This required updating the OrcRemoteTarget API, Client,
and server code, as well as updating the Orc C API.

This patch also fixes several instances where Errors were dropped.

llvm-svn: 267457
2016-04-25 19:56:45 +00:00
Lang Hames
27f8f7a332 [Orc] Add pthread dependence to the RPCUtilsTest unit test.
llvm-svn: 266766
2016-04-19 17:13:52 +00:00
Lang Hames
f95640aabc [Orc] Disable RPC callST unit test until the S390 failures encountered during
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/3459 can be
debugged/fixed.

llvm-svn: 266717
2016-04-19 06:01:51 +00:00
Lang Hames
8dea229f20 [Orc] Tidy up some of the RPC primitives, add a unit-test for the callST
(synchronous call) primitive.

llvm-svn: 266711
2016-04-19 04:43:09 +00:00
Lang Hames
7f7e42c67c [Orc] Re-commit r266581 with fixes for MSVC, and format cleanups.
Fixes:

(1) Removes constexpr (unsupported in MSVC)
(2) Move constructors (remove explicitly defaulted ones)
(3) <future> - Add warning suppression for MSVC.

llvm-svn: 266663
2016-04-18 19:55:43 +00:00
Nico Weber
9dc54a8808 Revert 266581 (and follow-up 266588), it doesn't build on Windows.
Three problems:
1. <future> can't be easily used.  If you must use it, see
   include/Support/ThreadPool.h for how.
2. constexpr problems, even after 266588.
3. Move assignment operators can't be defaulted in MSVC2013.

llvm-svn: 266615
2016-04-18 13:57:08 +00:00
Lang Hames
e6614e766c [ORC] Generalize the ORC RPC utils to support RPC function return values and
asynchronous call/handle. Also updates the ORC remote JIT API to use the new
scheme.

The previous version of the RPC tools only supported void functions, and
required the user to manually call a paired function to return results. This
patch replaces the Procedure typedef (which only supported void functions) with
the Function typedef which supports return values, e.g.:

  Function<FooId, int32_t(std::string)> Foo;

The RPC primitives and channel operations are also expanded. RPC channels must
support four new operations: startSendMessage, endSendMessage,
startRecieveMessage and endRecieveMessage, to handle channel locking. In
addition, serialization support for tuples to RPCChannels is added to enable
multiple return values.

The RPC primitives are expanded from callAppend, call, expect and handle, to:

appendCallAsync - Make an asynchronous call to the given function.

callAsync - The same as appendCallAsync, but calls send on the channel when
            done.

callSTHandling - Blocking call for single-threaded code. Wraps a call to
                 callAsync then waits on the result, using a user-supplied
                 handler to handle any callbacks from the remote.

callST - The same as callSTHandling, except that it doesn't handle
         callbacks - it expects the result to be the first return.

expect and handle - as before.

handleResponse - Handle a response from the remote.

waitForResult - Wait for the response with the given sequence number to arrive.

llvm-svn: 266581
2016-04-18 01:06:49 +00:00
Mehdi Amini
ea195a382e Remove every uses of getGlobalContext() in LLVM (but the C API)
At the same time, fixes InstructionsTest::CastInst unittest: yes
you can leave the IR in an invalid state and exit when you don't
destroy the context (like the global one), no longer now.

This is the first part of http://reviews.llvm.org/D19094

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266379
2016-04-14 21:59:01 +00:00
Duncan P. N. Exon Smith
5f366e4aa0 Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes."
This reverts commit r265454 since it broke the build.  E.g.:

  http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/

llvm-svn: 265459
2016-04-05 20:45:04 +00:00
Eugene Zelenko
a612bac11f Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; other minor fixes.
Some Include What You Use suggestions were used too.

Use anonymous namespaces in source files.

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

llvm-svn: 265454
2016-04-05 20:19:49 +00:00
Lang Hames
fa38efeccb [Orc] Switch RPC Procedure to take a function type, rather than an arg list.
No functional change, just a little more readable.

llvm-svn: 263951
2016-03-21 16:56:25 +00:00
Lang Hames
c3c1858604 [RuntimeDyld] Fix '_' stripping in RTDyldMemoryManager::getSymbolAddressInProcess.
The RTDyldMemoryManager::getSymbolAddressInProcess method accepts a
linker-mangled symbol name, but it calls through to dlsym to do the lookup (via
DynamicLibrary::SearchForAddressOfSymbol), and dlsym expects an unmangled
symbol name.

Historically we've attempted to "demangle" by removing leading '_'s on all
platforms, and fallen back to an extra search if that failed. That's broken, as
it can cause symbols to resolve incorrectly on platforms that don't do mangling
if you query '_foo' and the process also happens to contain a 'foo'.

Fix this by demangling conditionally based on the host platform. That's safe
here because this function is specifically for symbols in the host process, so
the usual cross-process JIT looking concerns don't apply.

M    unittests/ExecutionEngine/ExecutionEngineTest.cpp
M    lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp

llvm-svn: 262657
2016-03-03 21:23:15 +00:00
Amaury Sechet
c4e8893256 Kill LLVMAddTargetData
Summary: It's red, it's dead.

Reviewers: joker.eph, Wallbraker, echristo

Subscribers: llvm-commits, axw

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

llvm-svn: 260919
2016-02-16 00:22:02 +00:00
Lang Hames
5d09e23f7a [Orc] Add lazy-JITting support for i386.
This patch adds a new class, OrcI386, which contains the hooks needed to
support lazy-JITing on i386 (currently only for Pentium 2 or above, as the JIT
re-entry code uses the FXSAVE/FXRSTOR instructions).

Support for i386 is enabled in the LLI lazy JIT and the Orc C API, and
regression and unit tests are enabled for this architecture.

llvm-svn: 260338
2016-02-10 01:02:33 +00:00
Joseph Tremoulet
6905486a9e [Unittest] Clean up formatting, NFC
Summary:
Use an early return to reduce indentation.
Remove unused local.

Reviewers: dblaikie, lhames

Subscribers: lhames, llvm-commits

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

llvm-svn: 259663
2016-02-03 17:11:24 +00:00
Chris Bieneman
1b8d4f74aa Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

"I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened."
- Obi Wan Kenobi

Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark

Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits

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

llvm-svn: 258861
2016-01-26 21:29:08 +00:00
Eugene Zelenko
966902f532 Fix Clang-tidy modernize-use-nullptr and modernize-use-override warnings; other minor fixes.
Differential revision: reviews.llvm.org/D16568

llvm-svn: 258831
2016-01-26 18:48:36 +00:00
NAKAMURA Takumi
297ef6c65b ObjectTransformLayerTest.cpp: Rework r258633. [-Winconsistent-missing-override]
Sorry for the noise.

llvm-svn: 258635
2016-01-23 20:48:50 +00:00
NAKAMURA Takumi
bf43da04ea ObjectTransformLayerTest.cpp: Fix a warning. [-Wredundant-move]
llvm-svn: 258634
2016-01-23 20:45:55 +00:00
NAKAMURA Takumi
c4428c11d5 ObjectTransformLayerTest.cpp: Fix a warning. [-Winconsistent-missing-override]
llvm-svn: 258633
2016-01-23 20:45:50 +00:00
Joseph Tremoulet
59d64a8443 [ORC] Update ObjectTransformLayer signature
Summary:
Update ObjectTransformLayer::addObjectSet to take the object set by
value rather than reference and pass it to the base layer with move
semantics rather than copy, to match r258185's changes to
ObjectLinkingLayer.

Update the unit test to verify that ObjectTransformLayer's signature stays
in sync with ObjectLinkingLayer's.


Reviewers: lhames

Subscribers: llvm-commits

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

llvm-svn: 258630
2016-01-23 18:36:01 +00:00
Lang Hames
7bbae4dc58 [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
526cf61162 [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
c6ee17b71b [Orc] Revert r258031 - it broke the builders.
llvm-svn: 258034
2016-01-18 01:51:51 +00:00
Lang Hames
2d38694617 [Orc] Expand a comment explaining a unit test.
llvm-svn: 258032
2016-01-18 01:00:19 +00:00
Lang Hames
c96132f0d0 [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
dac7e64ae5 [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
387a94a205 [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
e3f56c7faa 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
f1200209c6 [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
359dea2a6b 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
096bda3427 [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
dde8f900ec [Orc] Rename IndirectStubsManagerBase to IndirectStubsManager.
No functional change.

llvm-svn: 254885
2015-12-06 19:44:45 +00:00
Lang Hames
c8c41976a3 [Orc] Move some code up into the JITCompileCallbackManager base class. NFC.
llvm-svn: 254778
2015-12-04 22:09:19 +00:00
Lang Hames
84deb31665 [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
7c062ccc18 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
9a95592e5f Orc: Streamline some lambda usage in a unit test
llvm-svn: 252070
2015-11-04 19:43:24 +00:00
Aaron Ballman
52c1d43c18 Silence an extra semicolon warning; NFC.
llvm-svn: 252046
2015-11-04 14:40:54 +00:00
Rafael Espindola
7ec60e8686 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
c04851c1d4 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
f8e78a5c05 [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
d06d3863b2 [Orc] Expose the compile callback API through the C bindings.
llvm-svn: 251683
2015-10-30 03:20:21 +00:00
Lang Hames
943a5001e8 [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
fb1fbdd1de [Orc] Rename IndirectStubsManagerBase method 'init' to 'createStubs'.
llvm-svn: 251641
2015-10-29 18:36:27 +00:00
NAKAMURA Takumi
5ae830ec21 OrcJITTests: Update libdeps corresponding to r251604.
llvm-svn: 251619
2015-10-29 06:40:04 +00:00
Lang Hames
7c0a045b19 [Orc] Add missing file for r251604.
llvm-svn: 251605
2015-10-29 03:53:42 +00:00
Lang Hames
5d4b1fd0d0 [Orc] Add support for RuntimeDyld::setProcessAllSections.
llvm-svn: 251604
2015-10-29 03:52:58 +00:00
Lang Hames
f1a1d671ef [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
eb14899f9b OrcJITTests: Prune unused libdeps.
llvm-svn: 251506
2015-10-28 09:59:50 +00:00
NAKAMURA Takumi
f7d022a78f OrcJITTests: Update libdeps.
llvm-svn: 251504
2015-10-28 09:37:09 +00:00
Craig Topper
5a82c57a8f Fix a -Wpessimizing-move warning.
llvm-svn: 251495
2015-10-28 04:54:46 +00:00
Lang Hames
b30e948a5f [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
17ab368657 [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
3c4da45364 [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
ec967600c9 [Orc] Add experimental C bindings for Orc.
llvm-svn: 251472
2015-10-28 00:28:26 +00:00
Lang Hames
4133627552 [Orc] Fix indentation.
llvm-svn: 251423
2015-10-27 17:45:48 +00:00
Duncan P. N. Exon Smith
43390ff2fc unittests: Remove implicit ilist iterator conversions, NFC
llvm-svn: 250843
2015-10-20 18:30:20 +00:00
Lang Hames
2dba99dd71 [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
7d1f4ff326 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
d7003090ac [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
20373f3760 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
2be0223b90 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
f6229dbc63 [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
8d3f0a8c24 MCJITTests/MCJITCAPITest.cpp: Try to appease i686-win32.
llvm-svn: 243639
2015-07-30 13:06:53 +00:00
Lang Hames
1dbdf92b9c [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
ccd56c36bb [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
27456ab028 [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
ec04c2efbd 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
ed1282388e [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
f7254a68ab [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
e4a548dd26 [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
Benjamin Kramer
c5f28c35c8 Don't use std::make_unique.
We still have to support C++11 standard libraries, make_unique is a C++14
feature.

llvm-svn: 240642
2015-06-25 13:47:36 +00:00
Joseph Tremoulet
8fc5afb15f [ORC] Add ObjectTransformLayer
Summary:
This is a utility for clients that want to insert a layer that modifies
each ObjectFile and then passes it along to the next layer.

Reviewers: lhames

Reviewed By: lhames

Subscribers: llvm-commits

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

llvm-svn: 240640
2015-06-25 13:35:22 +00:00
Keno Fischer
dc411f550e [MCJIT] Add a FindGlobalVariableNamed utility
Summary: This adds FindGlobalVariableNamed to ExecutionEngine
(plus implementation in MCJIT), which is an analog of
FindFunctionNamed for GlobalVariables.

Reviewers: lhames

Reviewed By: lhames

Subscribers: llvm-commits

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

llvm-svn: 240202
2015-06-20 00:55:58 +00:00
Petar Jovanovic
e26f67279e [Mips64] Add support for MCJIT for MIPS64r2 and MIPS64r6
Add support for resolving MIPS64r2 and MIPS64r6 relocations in MCJIT.

Patch by Vladimir Radosavljevic.

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

llvm-svn: 238424
2015-05-28 13:48:41 +00:00
David Blaikie
0be3b52a8f Simplify IRBuilder::CreateCall* by using ArrayRef+initializer_list/braced init only
llvm-svn: 237624
2015-05-18 22:13:54 +00:00
Reid Kleckner
42e37ba12d s/NULL/nullptr/ in OrcTestCommon.h to silence -Wsentinel in clang-cl
llvm-svn: 235386
2015-04-21 15:56:21 +00:00
Lang Hames
c39c3c89e5 [Orc] Make the makeStub function propagate argument attributes onto the call to
the function body.

This is necessary for correctness when lazily compiling.

Also, flesh out the Orc unit test infrastructure slightly, and add a unit test
for this.

llvm-svn: 235347
2015-04-20 20:41:45 +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
629180b642 [MCJIT] Enable MCJIT regression tests on Darwin.
Commit r233747 fixed the issue that had been blocking this.

llvm-svn: 233750
2015-03-31 20:48:52 +00:00
Lang Hames
1e87940341 [ExecutionEngine] Fix MCJIT::addGlobalMapping.
This patch fixes MCJIT::addGlobalMapping by changing the implementation of the
ExecutionEngineState class. The new implementation maintains a bidirectional
mapping between symbol names (std::strings) and addresses (uint64_ts), rather
than a mapping between Value*s and void*s.

This has fix has been made for backwards compatibility, however the strongly
preferred way to resolve unknown symbols is by writing a custom
RuntimeDyld::SymbolResolver (formerly RTDyldMemoryManager) and overriding the
findSymbol method. The addGlobalMapping method is a hangover from the legacy JIT
(which has was removed in 3.6), and may be deprecated in a future release as
part of a clean-up of the ExecutionEngine interface.

Patch by Murat Bolat. Thanks Murat!

llvm-svn: 233747
2015-03-31 20:31:14 +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
Benjamin Kramer
ce7baceeed Add missing includes. make_unique proliferated everywhere.
llvm-svn: 230909
2015-03-01 21:28:53 +00:00
David Blaikie
55b35d6f45 Fix Makefile build
llvm-svn: 230197
2015-02-23 00:53:35 +00:00
David Blaikie
4639d7a7ec [orc] Add a trivial unit test to get the ball rolling
I made my best guess at the Makefile, since I don't have a make build.

I'm not sure if it should be valid to add an empty list of things, but
it seemed the sort of degenerate case.

llvm-svn: 230196
2015-02-23 00:36:25 +00:00
NAKAMURA Takumi
0dd5b347b1 [CMake] Add RuntimeDyld to libdeps corresponding to r229343.
llvm-svn: 229351
2015-02-16 02:13:30 +00:00
Lang Hames
bad231721d Revert r227247 and r227228: "Add weak symbol support to RuntimeDyld".
This has wider implications than I expected when I reviewed the patch: It can
cause JIT crashes where clients have used the default value for AbortOnFailure
during symbol lookup. I'm currently investigating alternative approaches and I
hope to have this back in tree soon.

llvm-svn: 227287
2015-01-28 01:30:37 +00:00
Keno Fischer
04e2abc428 [ExecutionEngine] Fix r227228 tests on Windows
On Windows, we're running MCJIT with ELF, so the module needs to have
its Triple explicitly adjusted.

llvm-svn: 227247
2015-01-27 21:33:25 +00:00
Keno Fischer
bf90cfd379 [ExecutionEngine] Add weak symbol support to RuntimeDyld
Support weak symbols by first looking up if there is an externally visible symbol we can find,
and only if that fails using the one in the object file we're loading.

Reviewed By: lhames
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D6950

llvm-svn: 227228
2015-01-27 20:02:31 +00:00
Keno Fischer
f5773a9334 [ExecutionEngine] FindFunctionNamed: Skip declarations
Summary:
Basically all other methods that look up functions by name skip them if they are mere declarations.
Do the same in FindFunctionNamed.

Reviewers: lhames

Reviewed By: lhames

Subscribers: llvm-commits

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

llvm-svn: 227227
2015-01-27 19:29:00 +00:00
Vasileios Kalintiris
b3567820d5 Fix the C-API MCJIT test for 32-bit big endian machines.
Avoid using unions for storing the return value from
LLVMGetGlobalValueAddress() and LLVMGetFunctionAddress() and accessing it as
a pointer through another pointer member. This causes problems on 32-bit big
endian machines since the pointer gets the higher part of the return value of
the aforementioned functions.

llvm-svn: 226170
2015-01-15 15:36:04 +00:00
Peter Zotov
53cd127d2d [C API] Expose LLVMGetGlobalValueAddress and LLVMGetFunctionAddress.
Patch by Ramkumar Ramachandra <artagnon@gmail.com>

llvm-svn: 224720
2014-12-22 18:53:11 +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