Commit Graph

1640 Commits

Author SHA1 Message Date
Rafael Espindola
3f4ed32b43 Make it explicit that ExecutionEngine takes ownership of the modules.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215967 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 04:04:25 +00:00
Rafael Espindola
f359f7ef8c Use a range loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215948 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-18 23:15:59 +00:00
Lang Hames
08f77a9f42 [MCJIT] Respect target endianness in RuntimeDyldMachO and RuntimeDyldChecker.
This patch may address some of the issues described in http://llvm.org/PR20640.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215938 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-18 21:43:16 +00:00
Rafael Espindola
6de46b5183 Use copy initialization to initialize std::unique_ptr.
Thanks to David Blaikie for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215867 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-17 23:38:08 +00:00
Lang Hames
e8d6e37938 [MCJIT] Support DisableSymbolSearching and InstallLazyFunctionCreator in MCJIT.
Patch by Anthony Pesch. Thanks Anthony!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215613 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-14 02:38:20 +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
Lang Hames
e5885cab3e [MCJIT] Simplify immediate decoding code in the RuntimeDyldMachO hierarchy.
Cleanup only: no functional change.

This patch makes RuntimeDyldMachO targets directly responsible for decoding
immediates, rather than letting them implement catch a callback from generic
code. Since this is a very target specific operation, it makes sense to let the
target-specific code drive it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215255 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 23:12:22 +00:00
Eric Christopher
aa5b9c0f6f Temporarily Revert "Nuke the old JIT." as it's not quite ready to
be deleted. This will be reapplied as soon as possible and before
the 3.6 branch date at any rate.

Approved by Jim Grosbach, Lang Hames, Rafael Espindola.

This reverts commits r215111, 215115, 215116, 215117, 215136.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215154 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-07 22:02:54 +00:00
Lang Hames
362510890f [MCJIT] Replace a c-style cast with reinterpret_cast + static_cast.
C-style casts (and reinterpret_casts) result in implementation defined
values when a pointer is cast to a larger integer type. On some platforms
this was leading to bogus address computations in RuntimeDyldMachOAArch64.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215143 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-07 20:41:57 +00:00
Rafael Espindola
7b232e2bb6 fix configure+make build
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215116 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-07 14:38:49 +00:00
Rafael Espindola
875710a2fd Nuke the old JIT.
I am sure we will be finding bits and pieces of dead code for years to
come, but this is a good start.

Thanks to Lang Hames for making MCJIT a good replacement!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215111 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-07 14:21:18 +00:00
Eric Christopher
9f85dccfc6 Remove the TargetMachine forwards for TargetSubtargetInfo based
information and update all callers. No functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214781 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04 21:25:23 +00:00
Lang Hames
354ed5f15e [MCJIT] Fix an overly-aggressive check in RuntimeDyldMachOARM.
This should fix the MachO_ARM_PIC_relocations.s test failures on some 32-bit
testers.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214613 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-02 03:00:49 +00:00
Rafael Espindola
748566982e Include Archive.h
MSVC was complaining about Archive being an incomplete type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214542 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 19:28:15 +00:00
Rafael Espindola
db11712170 Move virtual method out of line.
Should fix the MSVC build.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214539 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 18:49:24 +00:00
Rafael Espindola
6312816b42 Replace comment about ownership with std::unique_ptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214533 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 18:09:32 +00:00
Rafael Espindola
af30da42f9 Use range loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214530 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 18:04:14 +00:00
Rafael Espindola
9aa0b5e11e Remove some calls to std::move.
Instead of moving out the data in a ErrorOr<std::unique_ptr<Foo>>, get
a reference to it.

Thanks to David Blaikie for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214516 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 14:31:55 +00:00
Rafael Espindola
79002da926 Use std::unique_ptr to make the ownership explicit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214377 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 03:12:45 +00:00
Rafael Espindola
fa003d07fd Delete dead code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214370 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-31 01:14:09 +00:00
Lang Hames
1febfa28a4 [MCJIT] Fix the ARM BR24 relocation in RuntimeDyldMachO.
We now (1) correctly decode the branch immediate, (2) modify the immediate to
corretly treat it as PC-rel, and (3) properly populate the stub entry.
Previously we had been doing each of these wrong.

<rdar://problem/17750739>



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214285 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-30 03:35:05 +00:00
Lang Hames
41364b7d54 [MCJIT] Add options to llvm-rtdyld to describe a phony target address space for
use in -verify mode.

This patch adds three hidden command line options to llvm-rtdyld:

 -target-addr-start <start-addr> : Specify the start of the virtual address
                                   space on the phony target.

 -target-addr-end   <end-addr>   : Specify the end of the virtual address space
                                   on the phony target.

 -target-section-sep <sep>       : Specify the separation (in bytes) between the
                                   end of one section and the start of the next.

These options automatically default to sane values for the target platform. In
particular, they allow narrow (e.g. 32-bit, 16-bit) targets to be tested from
wider (e.g. 64-bit, 32-bit) hosts without overflowing pointers.

The section separation option defaults to zero, but can be set to a large number
(e.g. 1 << 32) to force large separations between sections in order to
stress-test large-code-model code.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214255 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29 23:43:13 +00:00
Lang Hames
2531afb330 [MCJIT] Make sure we print the full 64-bit result of exprs in RuntimeDyldChecker.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214227 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29 21:38:20 +00:00
Lang Hames
fbfb01496b [MCJIT] Make the RuntimeDyldChecker stub_addr builtin use file names rather than
full paths for its first argument.

This allows us to remove the annoying sed lines in the test cases, and write
direct references to file names in stub_addr calls (rather than <filename>
placeholders).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214211 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29 20:40:37 +00:00
Juergen Ributzka
6277ad6748 [RuntimeDyld][AArch64] Make encode/decodeAddend also work on big-endian hosts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214205 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29 19:57:15 +00:00
Juergen Ributzka
26dd3e6531 [RuntimeDyld][AArch64] Make encode/decodeAddend more typesafe by using the relocation enum type. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214204 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-29 19:57:11 +00:00
Rafael Espindola
6e1b8585bc Remove dead code.
Every user has been switched to using EngineBuilder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213871 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 16:02:28 +00:00
Saleem Abdulrasool
58ba15dbe6 ExecutionEngine: remove a stray semicolon
Detected via GCC 4.8 [-Wpedantic].

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213776 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23 18:09:28 +00:00
Tim Northover
9231148e69 AArch64: remove arm64 triple enumerator.
Having both Triple::arm64 and Triple::aarch64 is extremely confusing, and
invites bugs where only one is checked. In reality, the only legitimate
difference between the two (arm64 usually means iOS) is also present in the OS
part of the triple and that's what should be checked.

We still parse the "arm64" triple, just canonicalise it to Triple::aarch64, so
there aren't any LLVM-side test changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213743 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23 12:32:47 +00:00
NAKAMURA Takumi
a63fc16e5f RuntimeDyldMachOAArch64.h: Fix a warning. [-Wunused-variable]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213710 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23 00:17:44 +00:00
Lang Hames
8c3156eb82 [MCJIT] Make stub_addr functionality in RuntimeDyldChecker work in release mode.
There's no reason to restrict this particular piece of RuntimeDyldChecker
functionality to +Asserts builds.

This should fix failures in MachO_x86-64_PIC_relocations.s on release bots.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213708 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 23:50:51 +00:00
Lang Hames
f072ab78ee [MCJIT] Teach RuntimeDyldChecker to handle underscores at the start of symbols.
RuntimeDyldChecker had been testing isalpha(Expr[0]) to recognise symbol tokens,
and throwing unrecognized token errors when it hit symbols with leading
underscores. This fixes that.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213706 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 23:17:21 +00:00
Lang Hames
fa8abbd9be [MCJIT] Improve stub_addr file-not-found diagnostic to help track down a
buildbot failure.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213701 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 23:07:52 +00:00
Lang Hames
daf061cf05 [MCJIT] Refactor and add stub inspection to the RuntimeDyldChecker framework.
This patch introduces a 'stub_addr' builtin that can be used to find the address
of the stub for a given (<file>, <section>, <symbol>) tuple. This address can be
used both to verify the contents of stubs (by loading from the returned address)
and to verify references to stubs (by comparing against the returned address).

Example (1) - Verifying stub contents:

Load 8 bytes (assuming a 64-bit target) from the stub for 'x' in the __text
section of f.o, and compare that value against the addres of 'x'.

# rtdyld-check: *{8}(stub_addr(f.o, __text, x) = x

Example (2) - Verifying references to stubs:

Decode the immediate of the instruction at label 'l', and verify that it's
equal to the offset from the next instruction's PC to the stub for 'y' in the
__text section of f.o (i.e. it's the correct PC-rel difference).

# rtdyld-check: decode_operand(l, 4) = stub_addr(f.o, __text, y) - next_pc(l)
l:
        movq    y@GOTPCREL(%rip), %rax

Since stub inspection requires cooperation with RuntimeDyldImpl this patch
pimpl-ifies RuntimeDyldChecker. Its implementation is moved in to a new class,
RuntimeDyldCheckerImpl, that has access to the definition of RuntimeDyldImpl.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213698 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 22:47:39 +00:00
Juergen Ributzka
d3e2d81592 Appease the buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213694 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 22:02:19 +00:00
Juergen Ributzka
04e8cc79cd [RuntimeDyld][MachO][AArch64] Add a helper function for encoding addends in instructions.
Factor out the addend encoding into a helper function and simplify the
processRelocationRef.

Also add a few simple rtdyld tests. More tests to come once GOTs can be tested too.

Related to <rdar://problem/17768539>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213689 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 21:42:55 +00:00
Juergen Ributzka
6f2f090b06 [RuntimeDyld][MachO][AArch64] Implement the decodeAddend method.
This adds the required functionality to decode the immediate encoded in an
instruction that is referenced in a relocation entry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213688 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 21:42:51 +00:00
Juergen Ributzka
214c554b64 [RuntimeDyld][MachO][AArch64] Add assertion to check for duplicate addend definition.
In MachO for AArch64 it is possible to have an explicit addend defined by
the ARM64_RELOC_ADDEND relocation or having an addend encoded within the
instruction. Only one of them are allowed per relocation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213687 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 21:42:49 +00:00
Juergen Ributzka
5b50a3c769 [RuntimeDyld] Change the return type of decodeAddend to match the storage type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213686 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-22 21:42:46 +00:00
Aaron Ballman
bb9fd2cbd4 Fixing an MSVC conversion warning about implicitly converting the shift results to 64-bits. No functional change intended.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213515 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-21 12:31:43 +00:00
Ulrich Weigand
68b292b026 [PowerPC] ELFv2 dynamic loader support
This patch enables the new ELFv2 ABI in the runtime dynamic loader.
The loader has to implement the following features:
- In the ELFv2 ABI, do not look up a function descriptor in .opd, but
  instead use the local entry point when resolving a direct call.
- Update the TOC restore code to use the new TOC slot linkage area
  offset.
- Create PLT stubs appropriate for the ELFv2 ABI.

Note that this patch also adds common-code changes. These are necessary
because the loader must check the newly added ELF flags: the e_flags
header bits encoding the ABI version, and the st_other symbol table
entry bits encoding the local entry point offset.  There is currently
no way to access these, so I've added ObjectFile::getPlatformFlags and
SymbolRef::getOther accessors.

Reviewed by Hal Finkel.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213491 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-20 23:53:14 +00:00
Lang Hames
e8cfb5988f [MCJIT] Add a 'decodeAddend' method to RuntimeDyldMachO and teach
getBasicRelocationEntry to use this rather than 'memcpy' to get the
relocation addend. Targets with non-trivial addend encodings (E.g. AArch64) can
override decodeAddend to handle immediates with interesting encodings.

No functional change.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213435 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-19 00:19:17 +00:00
Lang Hames
7b1a0fd7ab [MCJIT] [AArch64] Make sure to propegate ARM64_RELOC_ADDEND values into the
RelocationEntry.

No test case yet, as this primarily hits GOT entries, which RuntimeDyldChecker
can't examine yet. I'm actively working on features that will enable us to
test this.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213408 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-18 20:29:36 +00:00
Lang Hames
353cec5eba [MCJIT] Fix the alignment requirements for ARM and AArch64 which were mistakenly
relaxed in the big RuntimeDyldMachO cleanup of r213293.

No test case yet - this was found via inspection and there's no easy way to test
GOT alignment in RuntimeDyldChecker at the moment. I'm working on adding support
for this now, and hope to have a test case for this soon.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213331 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 23:11:30 +00:00
Alp Toker
3cf9f37312 Drop the udis86 wrapper from llvm::sys
This optional dependency on the udis86 library was added some time back to aid
JIT development, but doesn't make much sense to link into LLVM binaries these
days.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213300 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 20:05:29 +00:00
Lang Hames
be406de225 [MCJIT] Significantly refactor the RuntimeDyldMachO class.
The previous implementation of RuntimeDyldMachO mixed logic for all targets
within a single class, creating problems for readability, maintainability, and
performance. To address these issues, this patch strips the RuntimeDyldMachO
class down to just target-independent functionality, and moves all
target-specific functionality into target-specific subclasses RuntimeDyldMachO.

The new class hierarchy is as follows:

class RuntimeDyldMachO
Implemented in RuntimeDyldMachO.{h,cpp}
Contains logic that is completely independent of the target. This consists
mostly of MachO helper utilities which the derived classes use to get their
work done.


template <typename Impl>
class RuntimeDyldMachOCRTPBase<Impl> : public RuntimeDyldMachO
Implemented in RuntimeDyldMachO.h
Contains generic MachO algorithms/data structures that defer to the Impl class
for target-specific behaviors.

RuntimeDyldMachOARM : public RuntimeDyldMachOCRTPBase<RuntimeDyldMachOARM>
RuntimeDyldMachOARM64 : public RuntimeDyldMachOCRTPBase<RuntimeDyldMachOARM64>
RuntimeDyldMachOI386 : public RuntimeDyldMachOCRTPBase<RuntimeDyldMachOI386>
RuntimeDyldMachOX86_64 : public RuntimeDyldMachOCRTPBase<RuntimeDyldMachOX86_64>
Implemented in their respective *.h files in lib/ExecutionEngine/RuntimeDyld/MachOTargets
Each of these contains the relocation logic specific to their target architecture.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213293 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-17 18:54:50 +00:00
Lang Hames
04fc9aeda3 [MCJIT] Improve a RuntimeDyldChecker diagnostic.
When a RuntimeDyldChecker test requests an invalid operand for an instruction,
print the decoded instruction to aid diagnosis.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213202 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16 22:02:20 +00:00
Lang Hames
58d03b3e08 [RuntimeDyld] Revert r211652 - MachO object GDB registration support.
The registration scheme used in r211652 violated the read-only contract of
MemoryBuffer. This caused crashes in llvm-rtdyld where macho objects were backed
by read-only mmap'd memory.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213086 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-15 19:35:22 +00:00
Lang Hames
a8940be6df [RuntimeDyld] Handle endiannes differences between the host and target while
reading MachO files magic numbers in RuntimeDyld.

This is required now that we're testing cross-platform JITing (via
RuntimeDyldChecker), and should fix some issues that David Fang has seen on PPC
builds.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213012 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-14 23:19:50 +00:00
Lang Hames
f7d3052fc7 [RuntimeDyld] Fix stub size and offset for AArch64 in RuntimeDyldMachO.h.
<rdar://problem/17648000>



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212864 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-12 00:16:47 +00:00