summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
Commit message (Collapse)AuthorAgeFilesLines
* [ORC][JITLink] Name in-memory compiled objects after their source modules.Lang Hames2019-04-301-1/+2
| | | | | | | | In-memory compiled object buffer identifiers will now be derived from the identifiers of their source IR modules. This makes it easier to connect in-memory objects with their source modules in debugging output. llvm-svn: 359613
* [ORC] Allow JITDylib definition generators to return Errors.Lang Hames2019-04-302-58/+94
| | | | | | | | | | | | | | | | | | | | Background: A definition generator can be attached to a JITDylib to generate new definitions in response to queries. For example: a generator that forwards calls to dlsym can map symbols from a dynamic library into the JIT process on demand. If definition generation fails then the generator should be able to return an error. This allows the JIT API to distinguish between the case where a generator does not provide a definition, and the case where it was not able to determine whether it provided a definition due to an error. The immediate motivation for this is cross-process symbol lookups: If the remote-lookup generator is attached to a JITDylib early in the search list, and if a generator failure is misinterpreted as "no definition in this JITDylib" then lookup may continue and bind to a different definition in a later JITDylib, which is a bug. llvm-svn: 359521
* [ORC] Replace the LLJIT/LLLazyJIT Create methods with Builder utilities.Lang Hames2019-04-291-105/+131
| | | | | | | | | | | LLJITBuilder and LLLazyJITBuilder construct LLJIT and LLLazyJIT instances respectively. Over time these will allow more configurable options to be added while remaining easy to use in the default case, which for default in-process JITing is now: auto J = ExitOnErr(LLJITBuilder.create()); llvm-svn: 359511
* [ORC] Add a 'plugin' interface to ObjectLinkingLayer for events/configuration.Lang Hames2019-04-262-51/+153
| | | | | | | | | | | | | ObjectLinkingLayer::Plugin provides event notifications when objects are loaded, emitted, and removed. It also provides a modifyPassConfig callback that allows plugins to modify the JITLink pass configuration. This patch moves eh-frame registration into its own plugin, and teaches llvm-jitlink to only add that plugin when performing execution runs on non-Windows platforms. This should allow us to re-enable the test case that was removed in r359198. llvm-svn: 359357
* [ORC] Remove symbols from dependency lists when failing materialization.Lang Hames2019-04-251-2/+29
| | | | | | | | | When failing materialization of a symbol X, remove X from the dependants list of any of X's dependencies. This ensures that when X's dependencies are emitted (or fail themselves) they do not try to access the no-longer-existing MaterializationInfo for X. llvm-svn: 359252
* [JITLink] Refer to FDE's CIE (not the most recent CIE) when parsing eh-frame.Lang Hames2019-04-242-13/+27
| | | | | | | | | | | | | | | Frame Descriptor Entries (FDEs) have a pointer back to a Common Information Entry (CIE) that describes how the rest FDE should be parsed. JITLink had been assuming that FDEs always referred to the most recent CIE encountered, but the spec allows them to point back to any previously encountered CIE. This patch fixes JITLink to look up the correct CIE for the FDE. The testcase is a MachO binary with an FDE that refers to a CIE that is not the one immediately proceeding it (the layout can be viewed wit 'dwarfdump --eh-frame <testcase>'. This test case had to be a binary as llvm-mc now sorts FDEs (as of r356216) to ensure FDEs *do* point to the most recent CIE. llvm-svn: 359105
* Fix MSVC "32-bit shift implicitly converted to 64 bits" warning. NFCI.Simon Pilgrim2019-04-231-2/+2
| | | | llvm-svn: 358970
* [JITLink] Remove a lot of reduntant 'JITLink_' prefixes. NFC.Lang Hames2019-04-228-18/+22
| | | | llvm-svn: 358869
* [JITLink] Fix section start address calculation in eh-frame recorder.Lang Hames2019-04-221-0/+3
| | | | | | | | | | Section atoms are not sorted, so we need to scan the whole section to find the start address. No test case: Found by inspection, and any reproduction would depend on pointer ordering. llvm-svn: 358865
* [JITLink] Remove an overly strict error check in JITLink's eh-frame parser.Lang Hames2019-04-212-13/+4
| | | | | | | | The error check required FDEs to refer to the most recent CIE, but the eh-frame spec allows them to refer to any previously seen CIE. This patch removes the offending check. llvm-svn: 358840
* [JITLink] Factor basic common GOT and stub creation code into its own class.Lang Hames2019-04-212-72/+130
| | | | llvm-svn: 358838
* [JITLink] Add yet more detail to MachO/x86-64 unsupported relocation errors.Lang Hames2019-04-201-1/+4
| | | | | | | | Knowing the address/symbolnum field values makes it easier to identify the unsupported relocation, and provides enough information for the full bit pattern of the relocation to be reconstructed. llvm-svn: 358833
* [JITLink][ORC] Add JITLink to the list of dependencies for ORC.Lang Hames2019-04-201-1/+2
| | | | | | | | | The new ObjectLinkingLayer in ORC depends on JITLink. This should fix the build error at http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9621 llvm-svn: 358832
* [JITLink] Fix a bad formatv format string.Lang Hames2019-04-201-1/+1
| | | | llvm-svn: 358831
* [JITLink] Add BinaryFormat to JITLink's dependencies.Lang Hames2019-04-201-1/+1
| | | | | | | | | Hopefully this will fix the missing dependence on llvm::identify_magic that is showing up on some PPC bots. E.g. http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/9617 llvm-svn: 358827
* [JITLink] Add more detail to MachO/x86-64 "unsupported relocation" errors.Lang Hames2019-04-201-1/+5
| | | | | | | The extra information here will be helpful in diagnosing errors, like the ones currently occuring on the PPC big-endian bots. :) llvm-svn: 358826
* [JITLink] Silence some MSVC implicit cast warnings.Lang Hames2019-04-201-2/+3
| | | | llvm-svn: 358824
* [JITLink] Use memset instead of bzero.Lang Hames2019-04-201-2/+2
| | | | llvm-svn: 358822
* [JITLink] Fix a missing header and bad prototype.Lang Hames2019-04-201-1/+2
| | | | llvm-svn: 358819
* Initial implementation of JITLink - A replacement for RuntimeDyld.Lang Hames2019-04-2018-65/+3140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: JITLink is a jit-linker that performs the same high-level task as RuntimeDyld: it parses relocatable object files and makes their contents runnable in a target process. JITLink aims to improve on RuntimeDyld in several ways: (1) A clear design intended to maximize code-sharing while minimizing coupling. RuntimeDyld has been developed in an ad-hoc fashion for a number of years and this had led to intermingling of code for multiple architectures (e.g. in RuntimeDyldELF::processRelocationRef) in a way that makes the code more difficult to read, reason about, extend. JITLink is designed to isolate format and architecture specific code, while still sharing generic code. (2) Support for native code models. RuntimeDyld required the use of large code models (where calls to external functions are made indirectly via registers) for many of platforms due to its restrictive model for stub generation (one "stub" per symbol). JITLink allows arbitrary mutation of the atom graph, allowing both GOT and PLT atoms to be added naturally. (3) Native support for asynchronous linking. JITLink uses asynchronous calls for symbol resolution and finalization: these callbacks are passed a continuation function that they must call to complete the linker's work. This allows for cleaner interoperation with the new concurrent ORC JIT APIs, while still being easily implementable in synchronous style if asynchrony is not needed. To maximise sharing, the design has a hierarchy of common code: (1) Generic atom-graph data structure and algorithms (e.g. dead stripping and | memory allocation) that are intended to be shared by all architectures. | + -- (2) Shared per-format code that utilizes (1), e.g. Generic MachO to | atom-graph parsing. | + -- (3) Architecture specific code that uses (1) and (2). E.g. JITLinkerMachO_x86_64, which adds x86-64 specific relocation support to (2) to build and patch up the atom graph. To support asynchronous symbol resolution and finalization, the callbacks for these operations take continuations as arguments: using JITLinkAsyncLookupContinuation = std::function<void(Expected<AsyncLookupResult> LR)>; using JITLinkAsyncLookupFunction = std::function<void(const DenseSet<StringRef> &Symbols, JITLinkAsyncLookupContinuation LookupContinuation)>; using FinalizeContinuation = std::function<void(Error)>; virtual void finalizeAsync(FinalizeContinuation OnFinalize); In addition to its headline features, JITLink also makes other improvements: - Dead stripping support: symbols that are not used (e.g. redundant ODR definitions) are discarded, and take up no memory in the target process (In contrast, RuntimeDyld supported pointer equality for weak definitions, but the redundant definitions stayed resident in memory). - Improved exception handling support. JITLink provides a much more extensive eh-frame parser than RuntimeDyld, and is able to correctly fix up many eh-frame sections that RuntimeDyld currently (silently) fails on. - More extensive validation and error handling throughout. This initial patch supports linking MachO/x86-64 only. Work on support for other architectures and formats will happen in-tree. Differential Revision: https://reviews.llvm.org/D58704 llvm-svn: 358818
* Simplify decoupling between RuntimeDyld/RuntimeDyldChecker, add 'got_addr' util.Lang Hames2019-04-1212-134/+101
| | | | | | | | | | | | | | | | | | | | | | | | | This patch reduces the number of functions in the interface between RuntimeDyld and RuntimeDyldChecker by combining "GetXAddress" and "GetXContent" functions into "GetXInfo" functions that return a struct describing both the address and content. The GetStubOffset function is also replaced with a pair of utilities, GetStubInfo and GetGOTInfo, that fit the new scheme. For RuntimeDyld both of these functions will return the same result, but for the new JITLink linker (https://reviews.llvm.org/D58704) these will provide the addresses of PLT stubs and GOT entries respectively. For JITLink's use, a 'got_addr' utility has been added to the rtdyld-check language, and the syntax of 'got_addr' and 'stub_addr' has been changed: both functions now take two arguments, a 'stub container name' and a target symbol name. For llvm-rtdyld/RuntimeDyld the stub container name is the object file name and section name, separated by a slash. E.g.: rtdyld-check: *{8}(stub_addr(foo.o/__text, y)) = y For the upcoming llvm-jitlink utility, which creates stubs on a per-file basis rather than a per-section basis, the container name is just the file name. E.g.: jitlink-check: *{8}(got_addr(foo.o, y)) = y llvm-svn: 358295
* gn build: Fix Windows builds after r357797Nico Weber2019-04-091-1/+1
| | | | llvm-svn: 358004
* [RuntimeDyld] Fix an ambiguous make_unique call.Lang Hames2019-04-081-1/+1
| | | | llvm-svn: 357950
* [RuntimeDyld] Decouple RuntimeDyldChecker from RuntimeDyld.Lang Hames2019-04-085-283/+230
| | | | | | | This will allow RuntimeDyldChecker (and rtdyld-check tests) to test a new JIT linker: JITLink (https://reviews.llvm.org/D58704). llvm-svn: 357947
* Change some StringRef::data() reinterpret_cast to bytes_begin() or ↵Fangrui Song2019-04-071-3/+1
| | | | | | arrayRefFromStringRef() llvm-svn: 357852
* [DebugInfo] IntelJitEventListener follow up for "add SectionedAddress ..."Brock Wyma2019-03-251-3/+13
| | | | | | | | | | | | Following r354972 the Intel JIT Listener would not report line table information because the section indices did not match. There was a similar issue with the PerfJitEventListener. This change performs the section index lookup when building the object address used to query the line table information. Differential Revision: https://reviews.llvm.org/D59490 llvm-svn: 356895
* [perf][DebugInfo] follow up for "add SectionedAddress to DebugInfo interfaces"Sylvestre Ledru2019-03-201-4/+10
| | | | | | | | | | | | | | | | Summary: Fix the build failure when perf jit is enabled Reviewers: avl, dblaikie Reviewed By: avl Subscribers: modocache, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59189 llvm-svn: 356542
* Add newline to interpreter debugging outputKristof Beyls2019-03-071-1/+1
| | | | | | | | | | | When running lli --debug --force-interpreter=true the executed instructions are printed but are missing newlines. This commit adds the missing newlines. Patch by Andrew Brown. Differential Revision: https://reviews.llvm.org/D57806 llvm-svn: 355587
* Attempt to fix buildbot after r354972 [#1]. NFCI.Alexey Lapshin2019-02-271-1/+3
| | | | llvm-svn: 355013
* [opaque pointer types] Pass value type to LoadInst creation.James Y Knight2019-02-011-3/+2
| | | | | | | | | This cleans up all LoadInst creation in LLVM to explicitly pass the value type rather than deriving it from the pointer's element-type. Differential Revision: https://reviews.llvm.org/D57172 llvm-svn: 352911
* [opaque pointer types] Pass function types to CallInst creation.James Y Knight2019-02-011-1/+2
| | | | | | | | | This cleans up all CallInst creation in LLVM to explicitly pass a function type rather than deriving it from the pointer's element-type. Differential Revision: https://reviews.llvm.org/D57170 llvm-svn: 352909
* Add namespace to some types.Richard Trieu2019-01-313-18/+21
| | | | llvm-svn: 352725
* [RuntimeDyld] Don't try to allocate sections with align 0.Zachary Turner2019-01-301-0/+5
| | | | | | | | | | | | | ELF sections allow 0 for the alignment, which is specified to be the same as 1. However many clients do not expect this and will behave poorly in the presence of a 0-aligned section (for example by trying to modulo something by the section alignment). We can be more polite by making sure that we always pass a non-zero value to clients. Differential Revision: https://reviews.llvm.org/D57482 llvm-svn: 352694
* [RuntimeDyld] load all sections with ProcessAllSectionsYonghong Song2019-01-281-0/+19
| | | | | | | | | | | | | | | | | | | | | | | This patch tried to address the following use case. . bcc (https://github.com/iovisor/bcc) utilizes llvm JIT to compile for BTF target. . with -g, .BTF and .BTF.ext sections (BPF debug info) will be generated by LLVM. . .BTF does not have relocations and .BTF.ext has some relocations. . With ProcessAllSections, .BTF.ext is loaded by JIT dynamic linker and is available to application. But .BTF is not loaded. The bcc application needs both .BTF.ext and .BTF for debugging purpose, and .BTF is not loaded. This patch addressed this issue by iterating over all sections and loading any missing sections, after symbol/relocation processing in loadObjectImpl(). Signed-off-by: Yonghong Song <yhs@fb.com> Differential Revision: https://reviews.llvm.org/D55943 llvm-svn: 352432
* MemoryBlock: Do not automatically extend a given size to a multiple of page ↵Rui Ueyama2019-01-231-1/+5
| | | | | | | | | | | | | | | | | | | | | | | size. Previously, MemoryBlock automatically extends a requested buffer size to a multiple of page size because (I believe) doing it was thought to be harmless and with that you could get more memory (on average 2KiB on 4KiB-page systems) "for free". That programming interface turned out to be error-prone. If you request N bytes, you usually expect that a resulting object returns N for `size()`. That's not the case for MemoryBlock. Looks like there is only one place where we take the advantage of allocating more memory than the requested size. So, with this patch, I simply removed the automatic size expansion feature from MemoryBlock and do it on the caller side when needed. MemoryBlock now always returns a buffer whose size is equal to the requested size. Differential Revision: https://reviews.llvm.org/D56941 llvm-svn: 351916
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1971-284/+213
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Revert r351138 "[ORC] Move ORC Core symbol map and set types into their ownLang Hames2019-01-153-256/+233
| | | | | | | | header: CoreTypes.h." This commit broke some bots. Reverting while I investigate. llvm-svn: 351195
* [ORC] Move ORC Core symbol map and set types into their own header: CoreTypes.h.Lang Hames2019-01-143-233/+256
| | | | | | | This will allow other utilities (including a future RuntimeDyld replacement) to use these types without pulling in the major Core types (JITDylib, etc.). llvm-svn: 351138
* [ORC][MIPS] Fill delay-slot after `jr` instructionSimon Atanasyan2019-01-121-5/+5
| | | | | | | | | | MIPS `jr` instruction uses a delay-slot. To escape execution of arbitrary instruction we should either fill the delay-slot by `nop` instruction or swap `jr` instruction and logically preceding instruction. This fix implements the second method to generate a bit more effective code. llvm-svn: 351001
* [ORC][MIPS] Setup t9 register and call function through this registerSimon Atanasyan2019-01-121-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MIPS ABI states that every function must be called through jalr $t9. In other words, a function expect that t9 register points to the beginning of its code. A function uses this register to calculate offset to the Global Offset Table and save it to the `gp` register. ``` lui $gp, %hi(_gp_disp) addiu $gp, %lo(_gp_disp) addu $gp, $gp, $t9 ``` If `t9` and as a result `$gp` point to the wrong place the following code loads incorrect value from GOT and passes control to invalid code. ``` lw $v0,%call16(foo)($gp) jalr $t9 ``` OrcMips32 and OrcMips64 writeResolverCode methods pass control to the resolved address, but do not setup `$t9` before the call. The `t9` holds value of the beginning of `resolver` code so any attempts to call routines via GOT failed. This change fixes the problem. The `OrcLazy/hidden-visibility.ll` test starts to pass correctly. Before the change it fails on MIPS because the `exitOnLazyCallThroughFailure` called from the resolver code could not call libc routine `exit` via GOT. Differential Revision: http://reviews.llvm.org/D56058 llvm-svn: 351000
* [opaque pointer types] Remove some calls to generic Type subtype accessors.James Y Knight2019-01-102-11/+7
| | | | | | | | | | | | That is, remove many of the calls to Type::getNumContainedTypes(), Type::subtypes(), and Type::getContainedType(N). I'm not intending to remove these accessors -- they are useful/necessary in some cases. However, removing the pointee type from pointers would potentially break some uses, and reducing the number of calls makes it easier to audit. llvm-svn: 350835
* [ORC] Rename register in the OrcMips64 resolver code comments. NFCSimon Atanasyan2018-12-231-2/+2
| | | | | | | The `fp` and `s8` register names are synonyms. But `fp` better reflects a purpose of the register. llvm-svn: 350023
* [ORC] clang-format OrcMips32 and OrcMips64 code. NFCSimon Atanasyan2018-12-231-24/+16
| | | | llvm-svn: 350022
* [ORC] Remove redundant instruction from MIPS resolver code. NFCSimon Atanasyan2018-12-231-8/+7
| | | | | | It's redundant to restore the `$a3` register twice. llvm-svn: 350021
* Implement IMAGE_REL_AMD64_SECREL for RuntimeDyldCOFFX86_64Nathan Lanza2018-12-121-0/+7
| | | | | | | | lldb on Windows uses the ExecutionEngine for expression evaluation and hits the llvm_unreachable due to this relocation. Thus, implement the relocation and add a test to verify it's function. llvm-svn: 348904
* [ExecutionEngine] Change NotifyObjectEmitted/NotifyObjectFreed API.Lang Hames2018-12-047-61/+66
| | | | | | | | | | | | | This patch renames both methods (NotifyObjectEmitted -> notifyObjectLoaded, and NotifyObjectFreed -> notifyObjectFreed), adds an abstract "ObjectKey" (uint64_t) parameter to notifyObjectLoaded, and replaces the ObjectFile parameter for notifyObjectFreed with an ObjectKey. Using an ObjectKey to track identify events, rather than a reference to the ObjectFile, allows us to free the ObjectFile after notifyObjectLoaded is called, saving memory. https://reviews.llvm.org/D53773 llvm-svn: 348223
* [ExecutionEngine][Interpreter] Fix out-of-bounds array access.Lang Hames2018-11-201-1/+2
| | | | | | | | | | If args is empty then accesing element 0 is illegal. https://reviews.llvm.org/D53556 Patch by Eugene Sharygin. Thanks Eugene! llvm-svn: 347281
* [BuildingAJIT] Update chapter 2 to use the ORCv2 APIs.Lang Hames2018-11-131-1/+2
| | | | llvm-svn: 346726
* [Support] Make error banner optional in logAllUnhandledErrorsJonas Devlieghere2018-11-115-7/+7
| | | | | | | | In a lot of places an empty string was passed as the ErrorBanner to logAllUnhandledErrors. This patch makes that argument optional to simplify the call sites. llvm-svn: 346604
* [ORC] Fix hex printing of uint64_t values.Lang Hames2018-10-312-6/+6
| | | | | | | A plain "%x" format string will drop the high 32-bits. Use the PRIx64 macro instead. llvm-svn: 345696
OpenPOWER on IntegriCloud