Commit Graph

2089 Commits

Author SHA1 Message Date
Keno Fischer
a5f79d9770 Fix PREL31 relocation on ARM
Summary:
This is a 31bits relative relocation instead of a 32bits absolute relocation.

Reviewers: t.p.northover, peter.smith, rengolin

Subscribers: aemerson, llvm-commits, samparker

Differential Revision: https://reviews.llvm.org/D25069

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284780 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-20 21:15:29 +00:00
Simon Dardis
f7463aa366 [mips][mcjit] Add the majority of N32 support.
The missing piece is relocation composition for %hi(%neg(%gp_rel(x))) and
similar.

Patch by: Daniel Sanders


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284724 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-20 13:02:23 +00:00
Benjamin Kramer
06d5a1641d Do a sweep over move ctors and remove those that are identical to the default.
All of these existed because MSVC 2013 was unable to synthesize default
move ctors. We recently dropped support for it so all that error-prone
boilerplate can go.

No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284721 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-20 12:20:28 +00:00
Reid Kleckner
5b1c9f3223 Remove LLVM_NOEXCEPT and replace it with noexcept
Now that we have dropped MSVC 2013, all supported compilers support
noexcept and we can drop this portability macro.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284672 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 23:52:38 +00:00
Walter Erquinigo
f68eeb3359 Handle relocations to thumb functions when dynamic linking COFF modules
Summary:
This adds the necessary logic to support relocations to thumb functions in the COFF dynamic linker.
The jumps to function addresses are mostly blx, which requires the ISA selection bit when jumping to a thumb function.

Note: I'm determining if the relocation requires the ISA bit when creating the relocation entries and not when resolving the relocation. I have to do that because I need the ObjectFile and the actual Symbol, which are available only when creating the entries. It would require a gross refactor if I do it otherwise, but I'm okay with doing it if you think it's better.

Reviewers: peter.smith, compnerd

Subscribers: rengolin, sas

Differential Revision: https://reviews.llvm.org/D25151

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284410 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-17 18:56:18 +00:00
Mehdi Amini
d1fa61bdee Use StringRef instead of raw pointer in ExecutionEngine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283016 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-01 06:22:04 +00:00
Lang Hames
c12323739a [MCJIT] Fix some inconsistent handling of name mangling inside MCJIT.
This patch moves symbol mangling from findSymbol to getSymbolAddress. The
findSymbol, findExistingSymbol and findModuleForSymbol methods now always take
a mangled name, allowing the 'demangle-and-retry' cruft to be removed from
findSymbol. See http://llvm.org/PR28699 for details.

Patch by James Holderness. Thanks very much James!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281238 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-12 17:19:24 +00:00
Lang Hames
b80c6300c5 [ORC] Clone module flags metadata into the globals module in the
CompileOnDemandLayer.

Also contains a tweak to the orc-lazy jit in LLI to enable the test case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280632 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-04 17:53:30 +00:00
Lang Hames
c6f214bfea [ExecutionEngine] Move ObjectCache::anchor from MCJIT to ExecutionEngine.
ObjectCache is an ExecutionEngine utility, so its anchor belongs there. The
practical impact of this change is that ORC users no longer need to link MCJIT
to use ObjectCaches.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280616 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-04 07:24:11 +00:00
Saleem Abdulrasool
294618592b ExecutionEngine: fix a bug in the movt/movw relocator
According to the arm arm specifications, 4 bytes are needed for a shift instead
of 8, this was causing the movt instruction to write to a different register
sometimes.

Patch by Walter Erquinigo!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280005 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-29 20:42:03 +00:00
Eugene Zelenko
9feaa97ada Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D23789


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279535 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-23 17:14:32 +00:00
Lang Hames
472f1cbd1f [RuntimeDyld] Revert r279182 and 279201 -- they broke some ARM bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279275 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 17:06:39 +00:00
Lang Hames
84c33c6c95 [RuntimeDyld] Add support for ELF R_ARM_REL32 and R_ARM_GOT_PREL.
Patch by William Dillon. Thanks William!

This patch adds support for the R_ARM_REL32 and R_ARM_GOT_PREL ELF ARM
relocations to RuntimeDyld, which should allow JITing of code that
produces these relocations.

No test case: Unfortunately RuntimeDyldELF's GOT building mechanism (which
uses a separate section for GOT entries) isn't compatible with
RuntimeDyldChecker. The correct fix for this is to fix RuntimeDyldELF's GOT
support (it's fundamentally broken at the moment: separate sections aren't
guaranteed to be in range of a GOT entry load), but that's a non-trivial job.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279182 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-19 01:15:39 +00:00
Lang Hames
b60f9a25c0 Revert r279016 -- it breaks win32-elf JIT tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279029 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 01:33:28 +00:00
Lang Hames
5bc5c47fda [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!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279016 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-18 00:22:34 +00:00
Justin Bogner
6673ea81f6 Replace "fallthrough" comments with LLVM_FALLTHROUGH
This is a mechanical change of comments in switches like fallthrough,
fall-through, or fall-thru to use the LLVM_FALLTHROUGH macro instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278902 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 05:10:15 +00:00
David Majnemer
5d08e375ab Use the range variant of remove_if instead of unpacking begin/end
No functionality change is intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278475 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-12 04:32:37 +00:00
David Majnemer
2d62ce6ee8 Use the range variant of find/find_if 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278469 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-12 03:55:06 +00:00
Lang Hames
3f8d4e3f67 [MCJIT] Improve documentation and error handling for MCJIT::runFunction.
ExecutionEngine::runFunction is supposed to allow execution of arbitrary
function types, but MCJIT can only reasonably support a limited subset of
main-linke function types. This patch documents this limitation, and fixes
MCJIT::runFunction to abort with a meaningful error at runtime if called with
an unsupported function type.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278348 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11 15:56:23 +00:00
Lang Hames
04d404bad2 Re-apply r278065 (Weak symbol support in RuntimeDyld) with a fix for ELF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278149 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-09 19:27:17 +00:00
Lang Hames
06c9df2f1c Revert r278065 while I investigate some build-bot breakage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278069 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-08 22:57:30 +00:00
Lang Hames
fbda7015e7 [RuntimeDyld][Orc][MCJIT] Add partial weak-symbol support to RuntimeDyld.
This patch causes RuntimeDyld to check for existing definitions when it
encounters weak symbols. If a definition already exists then the new weak
definition is discarded. All symbol lookups within a "logical dylib" should now
agree on the address of any given weak symbol. This allows the JIT to better
match the behavior of the static linker for C++ code.

This support is only partial, as it does not allow strong definitions that
occur after the first weak definition (in JIT symbol lookup order) to override
the previous weak definitions. Support for this will be added in a future
patch.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278065 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-08 22:53:37 +00:00
Lang Hames
5a98b5874c [ExecutionEngine][RuntimeDyld] Move JITSymbol from ExecutionEngine to RuntimeDyld.
JITSymbol really belongs in RuntimeDyld. This should fix the llvm-rtdyld link
failures caused by r277943.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277945 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-07 01:19:37 +00:00
Lang Hames
5ca8eaf661 [RuntimeDyld] Remove symbol that is unused as of r277943.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277944 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-07 01:12:44 +00:00
Lang Hames
fdf5e1ee1e [RuntimeDyld] Replace manual flag checks with JITSymbolFlags::fromObjectSymbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277943 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-07 00:18:14 +00:00
Lang Hames
9350f3619a [ORC] Re-apply r277896, removing bogus triples and datalayouts that broke tests
on linux last time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277942 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-06 22:36:26 +00:00
Nico Weber
84f6a48c0d Revert r277896.
It breaks ExecutionEngine/OrcLazy/weak-function.ll on most bots.

Script:
--
...
--
Exit Code: 1

Command Output (stderr):
--
Could not find main function.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277907 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-06 02:00:45 +00:00
Lang Hames
38365dac94 [ORC] Add (partial) weak symbol support to the CompileOnDemand layer.
This adds partial support for weak functions to the CompileOnDemandLayer by
modifying the addLogicalModule method to check for existing stub definitions
before building a new stub for a weak function. This scheme is sufficient to
support ODR definitions, but fails for general weak definitions if strong
definition is encountered after the first weak definition. (A more extensive
refactor will be required to fully support weak symbols).

This patch does *not* add weak symbol support to RuntimeDyld: I hope to add
that in the near future.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277896 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-06 00:54:43 +00:00
Lang Hames
6429bcfeba [ExecutionEngine] Refactor - Roll JITSymbolFlags functionality into JITSymbol.h
and remove the JITSymbolFlags header.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277766 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-04 20:32:37 +00:00
Lang Hames
f4cfadb9c0 [Orc] Fix common symbol support in ORC.
Common symbol support in ORC was broken in r270716 when the symbol resolution
rules in RuntimeDyld were changed. With the switch to lazily materialized
symbols in r277386, common symbols can be supported by having
RuntimeDyld::emitCommonSymbols search for (but not materialize!) definitions
elsewhere in the logical dylib.

This patch adds the 'Common' flag to JITSymbolFlags, and the necessary check
to RuntimeDyld::emitCommonSymbols.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277397 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01 22:23:24 +00:00
Lang Hames
075c1e2e1a [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.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277386 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01 20:49:11 +00:00
Nitesh Jain
d64a2c4149 [LLVM][MIPS] Fix createStubFunction to emit JR encoding based on Arch.
Reviewers: vkalintiris, dsanders

Subscribers: jaydeep, bhushan, mohit.bhakkad, slthakur, llvm-commits

Differential Revision: https://reviews.llvm.org/D21172

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275559 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 12:56:37 +00:00
Lang Hames
36105c0dde [Object] Change Archive::findSym to return an Expected<Optional<Child>>.
As suggested by Rafael in review of D22079 - this was accidentally left out of
the final commit (r275316).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275469 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 20:44:27 +00:00
Saleem Abdulrasool
4d45f1ed0d X86: handle external tail calls in Windows JIT
If there was a tail call, we would incorrectly handle the relocation.  It would
end up indexing into the array with an incorrect section id.  The symbol was
external to the module, so the Section ID was UNDEFINED (-1).  We would then
index the SmallVector with this ID, triggering an assertion.  Use the Value
rather than the section load address in this case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275442 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 17:27:06 +00:00
Lang Hames
aacf2fbfe4 [Object] Re-apply r275316 now that I have the corresponding LLD patch ready.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275361 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 02:24:01 +00:00
Lang Hames
5daf897d80 [Object] Revert r275316, Archive::child_iterator changes, while I update lld.
Should fix the bots broken by r275316.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275353 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 00:37:04 +00:00
Lang Hames
9b42acafff [Object] Change Archive::child_iterator for better interop with Error/Expected.
See http://reviews.llvm.org/D22079

Changes the Archive::child_begin and Archive::children to require a reference
to an Error. If iterator increment fails (because the archive header is
damaged) the iterator will be set to 'end()', and the error stored in the
given Error&. The Error value should be checked by the user immediately after
the loop. E.g.:

Error Err;
for (auto &C : A->children(Err)) {
  // Do something with archive child C.
}
// Check the error immediately after the loop.
if (Err)
  return Err;

Failure to check the Error will result in an abort() when the Error goes out of
scope (as guaranteed by the Error class).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275316 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-13 21:13:05 +00:00
Reid Kleckner
3fb0b9e151 Prune RelocVisitor.h include to avoid including COFF.h from MCJIT.h
This helps to mitigate the conflict between COFF.h and winnt.h, which is
PR28399.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274637 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 16:56:42 +00:00
NAKAMURA Takumi
283ee8181a Reformat blank lines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274481 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-04 01:26:33 +00:00
NAKAMURA Takumi
6f439639f1 Reformat comment lines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274480 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-04 01:26:27 +00:00
NAKAMURA Takumi
ef2b8e71c3 Untabify.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274479 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-04 01:26:21 +00:00
NAKAMURA Takumi
7810e667e7 Reformat.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274478 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-04 01:26:14 +00:00
Kevin Enderby
cf2cc47aa3 Fix lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp for r273701
and the change to libObject’s getSymbolAddress() to Expected<...> .


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273740 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 22:38:30 +00:00
Kevin Enderby
317de7ce5b Thread Expected<...> up from libObject’s getSymbolAddress() for symbols to allow
a good error message to be produced.

This is nearly the last libObject interface that used ErrorOr and the last one
that appears in llvm/include/llvm/Object/MachO.h .  For Mach-O objects this is
just a clean up because it’s version of getSymbolAddress() can’t return an
error.

I will leave it to the experts on COFF and ELF to actually add meaning full
error messages in their tests if they wish.  And also leave it to these experts
to change the last two ErrorOr interfaces in llvm/include/llvm/Object/ObjectFile.h
for createCOFFObjectFile() and createELFObjectFile() if they wish.

Since there are no test cases for COFF and ELF error cases with respect to
getSymbolAddress() in the test suite this is no functional change (NFC).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273701 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 18:24:42 +00:00
Saleem Abdulrasool
8324138899 ExecutionEngine: silence unused value warning
The Value is only used in debug or asserts builds.  Just cast to void to silence
an unused variable warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273684 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 14:31:09 +00:00
Saleem Abdulrasool
7fb006603a ExecutionEngine: add preliminary support for COFF ARM
This adds rudimentary support for COFF ARM to the dynamic loader for the
exeuction engine.  This can be used by lldb to JIT code into a COFF ARM
environment.  This lays the foundation for the loader, though a few of the
relocation types are yet unhandled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273682 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 14:11:44 +00:00
Peter Collingbourne
277258478e IR: Introduce Module::global_objects().
This is a convenience iterator that allows clients to enumerate the
GlobalObjects within a Module.

Also start using it in a few places where it is obviously the right thing
to use.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273470 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-22 20:29:42 +00:00
Benjamin Kramer
e5eb673413 Apply another batch of fixes from clang-tidy's performance-unnecessary-value-param.
Contains some manual fixes. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273047 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17 20:41:14 +00:00
Reid Kleckner
71b1fedfef [PATCH] Fix RuntimeDyldCOFFI386 to handle relocations with a non-zero addend
This fixes IMAGE_REL_I386_DIR32, IMAGE_REL_I386_DIR32NB,
IMAGE_REL_I386_SECREL, and IMAGE_REL_I386_REL32 relocations.

Based on patch by Jon Turney <jon.turney@dronecode.org.uk>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272911 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-16 16:21:41 +00:00
Peter Collingbourne
63b34cdf34 IR: Introduce local_unnamed_addr attribute.
If a local_unnamed_addr attribute is attached to a global, the address
is known to be insignificant within the module. It is distinct from the
existing unnamed_addr attribute in that it only describes a local property
of the module rather than a global property of the symbol.

This attribute is intended to be used by the code generator and LTO to allow
the linker to decide whether the global needs to be in the symbol table. It is
possible to exclude a global from the symbol table if three things are true:
- This attribute is present on every instance of the global (which means that
  the normal rule that the global must have a unique address can be broken without
  being observable by the program by performing comparisons against the global's
  address)
- The global has linkonce_odr linkage (which means that each linkage unit must have
  its own copy of the global if it requires one, and the copy in each linkage unit
  must be the same)
- It is a constant or a function (which means that the program cannot observe that
  the unique-address rule has been broken by writing to the global)

Although this attribute could in principle be computed from the module
contents, LTO clients (i.e. linkers) will normally need to be able to compute
this property as part of symbol resolution, and it would be inefficient to
materialize every module just to compute it.

See:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160509/356401.html
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160516/356738.html
for earlier discussion.

Part of the fix for PR27553.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272709 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-14 21:01:22 +00:00