summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine
Commit message (Collapse)AuthorAge
* [RuntimeDyld] Use a raw_ostream and llvm::format for int-to-string conversions.Lang Hames2014-06-27
| | | | | | | | Some users' C++11 standard libraries don't support std::to_string yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211961 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] #include <cctype> header in RuntimeDyldChecker.cpp.Lang Hames2014-06-27
| | | | | | | Hopefully this will unbreak the windows bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211958 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Add a framework for testing relocation logic in RuntimeDyld.Lang Hames2014-06-27
| | | | | | | | | | | | | | | | | | | | | | This patch adds a "-verify" mode to the llvm-rtdyld utility. In verify mode, llvm-rtdyld will test supplied expressions against the linked program images that it creates in memory. This scheme can be used to verify the correctness of the relocation logic applied by RuntimeDyld. The expressions to test will be read out of files passed via the -check option (there may be more than one of these). Expressions to check are extracted from lines of the form: # rtdyld-check: <expression> This system is designed to fit the llvm-lit regression test workflow. It is format and target agnostic, and supports verification of images linked for remote targets. The expression language is defined in llvm/include/llvm/RuntimeDyldChecker.h . Examples can be found in test/ExecutionEngine/RuntimeDyld. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211956 91177308-0d34-0410-b5e6-96231b3b80d8
* Silencing some -Wcast-qual warnings. No functional changes intended.Aaron Ballman2014-06-27
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211923 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld, PowerPC] Fix/improve handling of TOC relocationsUlrich Weigand2014-06-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current PPC64 RuntimeDyld code to handle TOC relocations has two problems: - With recent linkers, in addition to the relocations that implicitly refer to the TOC base (R_PPC64_TOC*), you can now also use the .TOC. magic symbol with any other relocation to refer to the TOC base explicitly. This isn't currently used much in ELFv1 code (although it could be), but it is essential in ELFv2 code. - In a complex JIT environment with multiple modules, each module may have its own .toc section, and TOC relocations in one module must refer to *its own* TOC section. The current findPPC64TOC implementation does not correctly implement this; in fact, it will always return the address of the first TOC section it finds anywhere. (Note that at the time findPPC64TOC is called, we don't even *know* which module the relocation originally resided in, so it is not even possible to fix this routine as-is.) This commit fixes both problems by handling TOC relocations earlier, in processRelocationRef. To do this, I've removed the findPPC64TOC routine and replaced it by a new routine findPPC64TOCSection, which works analogously to findOPDEntrySection in scanning the sections of the ObjImage provided by its caller, processRelocationRef. This solves the issue of finding the correct TOC section associated with the current module. This makes it straightforward to implement both R_PPC64_TOC relocations, and relocations explicitly refering to the .TOC. symbol, directly in processRelocationRef. There is now a new problem in implementing the R_PPC64_TOC16* relocations, because those can now in theory involve *three* different sections: the relocation may be applied in section A, refer explicitly to a symbol in section B, and refer implicitly to the TOC section C. The final processing of the relocation thus may only happen after all three of these sections have been assigned final addresses. There is currently no obvious means to implement this in its general form with the common-code RuntimeDyld infrastructure. Fortunately, ppc64 code usually makes no use of this most general form; in fact, TOC16 relocations are only ever generated by LLVM for symbols residing themselves in the TOC, which means "section B" == "section C" in the above terminology. This special case can easily be handled with the current infrastructure, and that is what this patch does. [ Unhandled cases result in an explicit error, unlike the current code which silently returns the wrong TOC base address ... ] This patch makes the JIT work on both BE and LE (ELFv2 requires additional patches, of course), and allowed me to successfully run complex JIT scenarios (via mesa/llvmpipe). Reviewed by Hal Finkel. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211885 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Teach MachOObjectImage to deregister itself with the debugger uponLang Hames2014-06-26
| | | | | | | | destruction the same way ELFObjectImage does. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211815 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Adds the necessary hooks to MCJIT to be able to debug generatedLang Hames2014-06-25
| | | | | | | | | | MachO files using the GDB JIT debugging interface. Patch by Keno Fischer. Thanks Keno! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211652 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.Rafael Espindola2014-06-24
| | | | | | | Once the objects are constructed, they own the buffer. Passing a unique_ptr makes that clear. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211595 91177308-0d34-0410-b5e6-96231b3b80d8
* Pass a std::unique_ptr& to the create??? methods is lib/Object.Rafael Espindola2014-06-23
| | | | | | | | This makes the buffer ownership on error conditions very natural. The buffer is only moved out of the argument if an object is constructed that now owns the buffer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211546 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Replace Execution Engine's mutex with std::recursive_mutex."Zachary Turner2014-06-20
| | | | | | | | | | This reverts commit 1f502bd9d7d2c1f98ad93a09ffe435e11a95aedd, due to GCC / MinGW's lack of support for C++11 threading. It's possible this will go back in after we come up with a reasonable solution. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211401 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Fix ppc64 stub relocations on little-endianUlrich Weigand2014-06-20
| | | | | | | | | | | | | | | | | When RuntimeDyldELF creates stub functions, it needs to install relocations that will resolve to the final address of the target routine. Since those are 16-bit relocs, they need to be applied to the least-significant halfword of the instruction. On big-endian ppc64, this means that addresses have to be adjusted by 2, which is what the code currently does. However, on a little-endian system, the address must *not* be adjusted; the least-significant halfword is the first one. This patch updates the RuntimeDyldELF code to take the target byte order into account. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211384 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Support more PPC64 relocationsUlrich Weigand2014-06-20
| | | | | | | | | | | | This adds support for several missing PPC64 relocations in the straight-forward manner to RuntimeDyldELF.cpp. Note that this actually fixes a failure of a large-model test case on PowerPC, allowing the XFAIL to be removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211382 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace Execution Engine's mutex with std::recursive_mutex.Zachary Turner2014-06-18
| | | | | | | | | | | | | This change has a bit of a trickle down effect due to the fact that there are a number of derived implementations of ExecutionEngine, and that the mutex is not tightly encapsulated so is used by other classes directly. Reviewed by: rnk Differential Revision: http://reviews.llvm.org/D4196 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211214 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove more occurrences of the unused-mutex-parameter pattern.Zachary Turner2014-06-17
| | | | | | | | | | | | | | | | This pattern loses some of its usefulness when the mutex type is statically polymorphic as opposed to runtime polymorphic, as swapping out the mutex type requires changing a significant number of function parameters, and templatizing the function parameter requires the methods to be defined in the headers. Furthermore, if LLVM is compiled with threads disabled then there may even be no mutex to acquire anyway, so it should not be up to individual APIs to know whether or not acquiring a mutex is required to use those APIs to begin with. It should be up to the user of the API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211125 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup more unreferenced MutexGuard parameters on functions.Zachary Turner2014-06-16
| | | | | | | | | | | These parameters are intended to serve as sort of a contract that you cannot access the functions outside of a mutex. However, the entire JIT class cannot be accessed outside of a mutex anyway, and all methods acquire a lock as soon as they are entered. Since the containing class already is not intended to be thread-safe, it only serves to add code clutter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211071 91177308-0d34-0410-b5e6-96231b3b80d8
* Clean up some unnecessary mutex guards.Zachary Turner2014-06-16
| | | | | | | | | | | | | | | These were being used as unreferenced parameters to enforce that the methods must not be called without holding a mutex, but all of the methods in question were internal, and the methods were only exposed through an interface whose entire purpose was to serialize access to these structures, so expecting the methods to be accessed under a mutex is reasonable enough. Reviewed by: blaikie Differential Revision: http://reviews.llvm.org/D4162 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211054 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert the Archive API to use ErrorOr.Rafael Espindola2014-06-16
| | | | | | | | | Now that we have c++11, even things like ErrorOr<std::unique_ptr<...>> are easy to use. No intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211033 91177308-0d34-0410-b5e6-96231b3b80d8
* Using llvm::sys::swapByteOrder() for the common case of byte-swapping a ↵Artyom Skrobov2014-06-14
| | | | | | value in place git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210978 91177308-0d34-0410-b5e6-96231b3b80d8
* Renaming SwapByteOrder() to getSwappedBytes()Artyom Skrobov2014-06-14
| | | | | | | | The next commit will add swapByteOrder(), acting in-place git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210973 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove 'using std::errro_code' from lib.Rafael Espindola2014-06-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210871 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove all uses of 'using std::error_code' from headers.Rafael Espindola2014-06-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210866 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use 'using std::error_code' in include/llvm.Rafael Espindola2014-06-12
| | | | | | This should make sure that most new uses use the std prefix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210835 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove system_error.h.Rafael Espindola2014-06-12
| | | | | | | This is a minimal change to remove the header. I will remove the occurrences of "using std::error_code" in a followup patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210803 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a Constant version of stripPointerCasts.Rafael Espindola2014-06-04
| | | | | | Thanks to rnk for the suggestion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210205 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow alias to point to an arbitrary ConstantExpr.Rafael Espindola2014-06-03
| | | | | | | | | | | | | | | | | | | | | This patch changes GlobalAlias to point to an arbitrary ConstantExpr and it is up to MC (or the system assembler) to decide if that expression is valid or not. This reduces our ability to diagnose invalid uses and how early we can spot them, but it also lets us do things like @test5 = alias inttoptr(i32 sub (i32 ptrtoint (i32* @test2 to i32), i32 ptrtoint (i32* @bar to i32)) to i32*) An important implication of this patch is that the notion of aliased global doesn't exist any more. The alias has to encode the information needed to access it in its metadata (linkage, visibility, type, etc). Another consequence to notice is that getSection has to return a "const char *". It could return a NullTerminatedStringRef if there was such a thing, but when that was proposed the decision was to just uses "const char*" for that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210062 91177308-0d34-0410-b5e6-96231b3b80d8
* Updates in IntelJITEventListener.cpp - by Arch Robison.Elena Demikhovsky2014-06-01
| | | | | | | | This patch updates IntelJITEventListener.cpp to account for revision 206654, which removed some methods from DILineInfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209989 91177308-0d34-0410-b5e6-96231b3b80d8
* ExecutionEngine: avoid NDEBUG in headersAlp Toker2014-05-31
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209981 91177308-0d34-0410-b5e6-96231b3b80d8
* Use error_code() instead of error_code::succes()Rafael Espindola2014-05-31
| | | | | | | There is no std::error_code::success, so this removes much of the noise in transitioning to std::error_code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209952 91177308-0d34-0410-b5e6-96231b3b80d8
* AArch64/ARM64: move ARM64 into AArch64's placeTim Northover2014-05-24
| | | | | | | | | | | | | | | This commit starts with a "git mv ARM64 AArch64" and continues out from there, renaming the C++ classes, intrinsics, and other target-local objects for consistency. "ARM64" test directories are also moved, and tests that began their life in ARM64 use an arm64 triple, those from AArch64 use an aarch64 triple. Both should be equivalent though. This finishes the AArch64 merge, and everyone should feel free to continue committing as normal now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209577 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Remove relocation bounds check introduced in r208375 (MachO only).Lang Hames2014-05-23
| | | | | | | | | | | | | | | | | | | | | We do all of our address arithmetic in 64-bit, and operations involving logically negative 32-bit offsets (actually represented as unsigned 64 bit ints) often overflow into higher bits. The overflow check could be preserved by casting to uint32 at the callsite for applyRelocationValue, but this would eliminate the value of the check. The right way to handle overflow in relocations is to make relocation processing target specific, and compute the values for RelocationEntry objects in the appropriate types (32-bit for 32-bit targets, 64-bit for 64-bit targets). This is coming as part of the cleanup I'm working on. This fixes another i386 regression test. <rdar://problem/16889891> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209536 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Teach RuntimeDyldMachO how to handle scattered VANILLA relocs onLang Hames2014-05-22
| | | | | | | | | | | | | | | | | | | | | | i386. This fixes two more MCJIT regression tests on i386: ExecutionEngine/MCJIT/2003-05-06-LivenessClobber.ll ExecutionEngine/MCJIT/2013-04-04-RelocAddend.ll The implementation of processScatteredVANILLA is tasteless (*ba-dum-ching*), but I'm working on a substantial tidy-up of RuntimeDyldMachO that should improve things. This patch also fixes a type-o in RuntimeDyldMachO::processSECTDIFFRelocation, and teaches that method to skip over the PAIR reloc following the SECTDIFF. <rdar://problem/16961886> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209478 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Fix x86-64 MachO GOT relocation handling.Lang Hames2014-05-19
| | | | | | | | | | | | For GOT relocations the addend should modify the offset to the GOT entry, not the value of the entry itself. Teach RuntimeDyldMachO to do The Right Thing here. Fixes <rdar://problem/16961886>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209154 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete getAliasedGlobal.Rafael Espindola2014-05-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209040 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Fix handling of i386 PC-rel external relocations. This fixesLang Hames2014-05-13
| | | | | | | | | | several more i386 MCJIT regression test failures. <rdar://problem/16889891> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208735 91177308-0d34-0410-b5e6-96231b3b80d8
* [un]wrap extracted from lib/Target/Target[MachineC].cpp, ↵Artyom Skrobov2014-05-13
| | | | | | lib/ExecutionEngine/ExecutionEngineBindings.cpp into include/llvm/IR/DataLayout.h git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208680 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Add support for MachO __jump_table and __pointers sections, andLang Hames2014-05-12
| | | | | | | | | | | | | SECTDIFF relocations on 32-bit x86. This fixes several of the MCJIT regression test failures that show up on 32-bit builds. <rdar://problem/16886294> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208635 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Unify the RuntimeDyldMachO resolve.*Relocation method signaturesLang Hames2014-05-09
| | | | | | | | | | | around RelocationEntries, rather than passing the same information via loose arguments. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208375 91177308-0d34-0410-b5e6-96231b3b80d8
* Use range loop.Rafael Espindola2014-05-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208346 91177308-0d34-0410-b5e6-96231b3b80d8
* Back out r208257 while I investigate tester failures.Lang Hames2014-05-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208267 91177308-0d34-0410-b5e6-96231b3b80d8
* [RuntimeDyld] Make RuntimeDyldImpl::resolveExternalSymbols preserve theLang Hames2014-05-07
| | | | | | | | | | | | | | | | | | | relocation entries it applies. Prior to this patch, RuntimeDyldImpl::resolveExternalSymbols discarded relocations for external symbols once they had been applied. This causes issues if the client calls MCJIT::finalizeLoadedModules more than once, and updates the location of any symbols in between (e.g. by calling MCJIT::mapSectionAddress). No test case yet: None of our in-tree memory managers support moving sections around. I'll have to hack up a dummy memory manager before I can write a unit test. Fixes <rdar://problem/16764378> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208257 91177308-0d34-0410-b5e6-96231b3b80d8
* [ARM64] Try and make the ELF MCJIT *slightly* less broken for ARM64.James Molloy2014-04-30
| | | | | | | | | A bunch of switch cases were missing, not just for ARM64 but also for AArch64_BE. I've fixed all those, but there's zero testing as ExecutionEngine tests are disabled when crosscompiling and I don't have a native platform available to test on. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207626 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the build with MSVC 2013 by explicitly requesting llvm::make_uniqueReid Kleckner2014-04-29
| | | | | | | MSVC 2013 provides std::make_unique, which it finds with ADL when one of the parameters is std::unique_ptr, leading to an ambiguous overload. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207597 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix MSVC build broken by r207580David Blaikie2014-04-29
| | | | | | | | Seems MSVC wants to be able to codegen inline-definitions of virtual functions even in TUs that don't define the key function - and it's well within its rights to do so. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207581 91177308-0d34-0410-b5e6-96231b3b80d8
* PR19553: Memory leak in RuntimeDyldELF::createObjectImageFromFileDavid Blaikie2014-04-29
| | | | | | | | | | | | | | | | This starts in MCJIT::getSymbolAddress where the unique_ptr<object::Binary> is release()d and (after a cast) passed to a single caller, MCJIT::addObjectFile. addObjectFile calls RuntimeDyld::loadObject. RuntimeDld::loadObject calls RuntimeDyldELF::createObjectFromFile And the pointer is never owned at this point. I say this point, because the alternative codepath, RuntimeDyldMachO::createObjectFile certainly does take ownership, so this seemed like a good hint that this was a/the right place to take ownership. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207580 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++] Use 'nullptr'.Craig Topper2014-04-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207394 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++] Use 'nullptr'.Craig Topper2014-04-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207083 91177308-0d34-0410-b5e6-96231b3b80d8
* [Modules] Fix potential ODR violations by sinking the DEBUG_TYPEChandler Carruth2014-04-22
| | | | | | | definition below all the header #include lines. This updates most of the miscellaneous other lib/... directories. A few left though. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206845 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[rtdyld,c++11] Range'ify symbol table walking."Jim Grosbach2014-04-21
| | | | | | | | | Tentative revert for http://lab.llvm.org:8011/builders/llvm-mips-linux/builds/8305. This reverts commit c2a58efff07294fca724f89500538f2ddbcd12ff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206773 91177308-0d34-0410-b5e6-96231b3b80d8
* [rtdyld,c++11] Range'ify symbol table walking.Jim Grosbach2014-04-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206769 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert getFileOffset to getOffset and move it to its only user.Rafael Espindola2014-04-21
| | | | | | | | | | | | | We normally don't drop functions from the C API's, but in this case I think we can: * The old implementation of getFileOffset was fairly broken * The introduction of LLVMGetSymbolFileOffset was itself a C api breaking change as it removed LLVMGetSymbolOffset. * It is an incredibly specialized use case. The only reason MCJIT needs it is because of its odd position of being a dynamic linker of .o files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206750 91177308-0d34-0410-b5e6-96231b3b80d8