[RuntimeDyld] Add a notifyObjectLoaded method to RuntimeDyld::MemoryManager. This is a more generic version of the MCJITMemoryManager::notifyObjectLoaded method: It provides only a RuntimeDyld reference (rather than an ExecutionEngine), and so can be used with ORC JIT stacks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257296 91177308-0d34-0410-b5e6-96231b3b80d8
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257294 91177308-0d34-0410-b5e6-96231b3b80d8
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257263 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] DenseMap -> std::unordered_map DenseMap is most applicable when both keys and values are small. In this case, the value violates that assumption, causing quite significant memory overhead. A std::unordered_map is more appropriate in this case (or at least fixed the memory problems I was seeing). Differential Revision: http://reviews.llvm.org/D14910 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254651 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] Fix a class of arithmetic errors introduced in r253918 r253918 had refactored expressions like "A - B.Address + C" to "A - B.getAddressWithOffset(C)". This is incorrect, since the latter really computes "A - B.Address - C". None of the tests I can run locally on x86 broke due to this bug, but it is the current suspect for breakage on the AArch64 buildbots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254017 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] Don't allocate unnecessary stub buffer space Summary: For relocation types that are known to not require stub functions, there is no need to allocate extra space for the stub functions. Reviewers: lhames, reames, maksfb Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14676 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253920 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] Add bounds checking to SectionEntry::advanceStubOffset Summary: Change SectionEntry to keep track of the size of its underlying allocation, and use that to bounds check advanceStubOffset. Reviewers: lhames, andrew.w.kaylor, reames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14675 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253919 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] Add accessors to `SectionEntry`; NFC Summary: Remove naked access to the data members in `SectionEntry` and route accesses through accessor functions. This makes it obvious how the instances of the class are used, and will also facilitate adding bounds checking to `advanceStubOffset` in a later change. Reviewers: lhames, loladiro, andrew.w.kaylor Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14674 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253918 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] Fix resolving R_PPC64_REL24 relocations When resolving R_PPC64_REL24, code used to check for an address delta that fits in 24 bits, while the instructions that take this relocation actually can process address deltas that fit into *26* bits (as those instructions have a 24 bit field, but implicitly append two zero bits at the end since all instruction addresses are a multiple of 4). This means that code would signal overflow once a single object's text section exceeds 8 MB, while we can actually support up to 32 MB. Partially fixes PR25540. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253369 91177308-0d34-0410-b5e6-96231b3b80d8
RuntimeDyld: fix -Wtype-limits Adjust the casted type. By casting to the same size rather than just the signed-ness, we were asserting tautological statements. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252150 91177308-0d34-0410-b5e6-96231b3b80d8
RuntimeDyld: add COFF i386 support This adds support for COFF I386. This is sufficient for code execution in a 32-bit JIT, though, imported symbols need to custom lowered for the redirection. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251761 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] Ignore ST_FILE symbols when constructing GlobalSymbolTable Summary: ELF's STT_File symbols may overlap with regular globals in other files, so we should ignore them here in order to avoid having bogus entries in the symbol table that confuse us when resolving relocations. Reviewers: lhames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13888 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250942 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] Add support for absolute symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250639 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] Don't try to get the contents of sections that don't have any (e.g. bss sections). MachO and ELF have been silently letting this pass, but COFFObjectFile contains an assertion to catch this kind of (ab)use of the getSectionContents, and this was causing the JIT to crash on COFF objects with BSS sections. This patch should fix that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250371 91177308-0d34-0410-b5e6-96231b3b80d8
[RuntimeDyld] Fix performance problem in resolveRelocations with many sections Summary: Rather than just iterating over all sections and checking whether we have relocations for them, iterate over the relocation map instead. This showed up heavily in an artificial julia benchmark that does lots of compilation. On that particular benchmark, this patch gives ~15% performance improvements. As far as I can tell the primary reason why the original loop was so expensive is that Relocations[i] actually constructs a relocationList (allocating memory & doing lots of other unnecessary computing) if none is found. Reviewers: lhames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13545 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249942 91177308-0d34-0410-b5e6-96231b3b80d8