summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
Commit message (Collapse)AuthorAgeFilesLines
* [ORC] Fix a missing move in ce2207abaf9.Lang Hames2020-01-291-1/+1
| | | | | | | | This should fix the build failure at http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/32524 and others. (cherry picked from commit e0a6093a744d16c90eafa62d7143ce41806b2466)
* [ORC] Add support for emulated TLS to ORCv2.Lang Hames2020-01-296-50/+96
| | | | | | | | | | | | | | | | | | | | | | | This commit adds a ManglingOptions struct to IRMaterializationUnit, and replaces IRCompileLayer::CompileFunction with a new IRCompileLayer::IRCompiler class. The ManglingOptions struct defines the emulated-TLS state (via a bool member, EmulatedTLS, which is true if emulated-TLS is enabled and false otherwise). The IRCompileLayer::IRCompiler class wraps an IRCompiler (the same way that the CompileFunction typedef used to), but adds a method to return the IRCompileLayer::ManglingOptions that the compiler will use. These changes allow us to correctly determine the symbols that will be produced when a thread local global variable defined at the IR level is compiled with or without emulated TLS. This is required for ORCv2, where MaterializationUnits must declare their interface up-front. Most ORCv2 clients should not require any changes. Clients writing custom IR compilers will need to wrap their compiler in an IRCompileLayer::IRCompiler, rather than an IRCompileLayer::CompileFunction, however this should be a straightforward change (see modifications to CompileUtils.* in this patch for an example). (cherry picked from commit ce2207abaf9a925b35f15ef92aaff6b301ba6d22)
* [ORC] Add weak symbol support to defineMaterializing, fix for PR40074.Lang Hames2020-01-293-28/+96
| | | | | | | | | | | | | | | | | | The MaterializationResponsibility::defineMaterializing method allows clients to add new definitions that are in the process of being materialized to the JIT. This patch adds support to defineMaterializing for symbols with weak linkage where the new definitions may be rejected if another materializer concurrently defines the same symbol. If a weak symbol is rejected it will not be added to the MaterializationResponsibility's responsibility set. Clients can check for membership in the responsibility set via the MaterializationResponsibility::getSymbols() method before resolving any such weak symbols. This patch also adds code to RTDyldObjectLinkingLayer to tag COFF comdat symbols introduced during codegen as weak, on the assumption that these are COFF comdat constants. This fixes http://llvm.org/PR40074. (cherry picked from commit 84217ad66115cc31b184374a03c8333e4578996f)
* [Disassembler] Delete the VStream parameter of MCDisassembler::getInstruction()Fangrui Song2020-01-111-1/+1
| | | | | | | | | | The argument is llvm::null() everywhere except llvm::errs() in llvm-objdump in -DLLVM_ENABLE_ASSERTIONS=On builds. It is used by no target but X86 in -DLLVM_ENABLE_ASSERTIONS=On builds. If we ever have the needs to add verbose log to disassemblers, we can record log with a member function, instead of passing it around as an argument.
* [ORC] Fix argv handling in runAsMain / lli.Lang Hames2020-01-111-1/+1
| | | | | | | | This fixes an off-by-one error in the argc value computed by runAsMain, and switches lli back to using the input bitcode (rather than the string "lli") as the effective program name. Thanks to Stefan Graenitz for spotting the bug.
* [ExecutionEngine] Re-enable FastISel for non-iOS arm targets.Lang Hames2020-01-111-7/+0
| | | | | | Patch by Nicolas Capens. Thanks Nicolas! https://reviews.llvm.org/D65015
* [NFC][ORC] Fix typos and whitespaces in commentsStefan Gränitz2020-01-031-1/+1
|
* [NFC] Fixes -Wrange-loop-analysis warningsMark de Wever2020-01-011-1/+1
| | | | | | This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71857
* [MCJIT] Migrate function attribute "no-frame-pointer-elim" to "frame-pointer"Fangrui Song2019-12-241-3/+3
|
* [ORC] De-register eh-frames in the RTDyldObjectLinkingLayer destructor.Lang Hames2019-12-201-0/+6
| | | | | This matches the behavior of the legacy layer, which automatically deregistered frames.
* [Orc][LLJIT] Re-apply 298e183e813 (use JITLink for LLJIT where supported).Lang Hames2019-12-191-3/+7
| | | | Patch d9220b580b3 fixed the underlying issue that casued 298e183e813 to fail.
* [JITLink][MachO] Fix common symbol size plumbing.Lang Hames2019-12-191-1/+1
| | | | This fixes the underlying bug that was exposed by 298e183e813.
* Revert "[Orc][LLJIT] Use JITLink even if a custom JITTargetMachineBuilder is ↵Lang Hames2019-12-181-7/+3
| | | | | | | | supplied." This reverts commit 298e183e813c884dd22816383405bae3ef9ef278. This commit caused some build failures -- reverting while I investigate.
* [Orc][LLJIT] Use JITLink even if a custom JITTargetMachineBuilder is supplied.Lang Hames2019-12-181-3/+7
| | | | | | LLJITBuilder will now use JITLink on supported platforms even if a custom JITTargetMachineBuilder is supplied, provided that neither the code model, nor the relocation model, nor the ObjectLinkingLayerCreator is set.
* [Orc][LLJIT] Automatically use JITLink for LLJIT on supported platforms.Lang Hames2019-12-151-0/+18
| | | | | | | | | JITLink (which underlies ObjectLinkingLayer) is a replacement for RuntimeDyld. It supports the native code model, and linker plugins that enable a wider range of features than RuntimeDyld. Currently only enabled for MachO/x86-64 and MachO/arm64. New architectures will be added as JITLink support for them is developed.
* [ORC] Make ObjectLinkingLayer own its jitlink::MemoryManager.Lang Hames2019-12-151-4/+4
| | | | | | | | This relieves ObjectLinkingLayer clients of the responsibility of holding the memory manager. This makes it easier to select between RTDyldObjectLinkingLayer (which already owned its memory manager factory) and ObjectLinkingLayer at runtime as clients aren't required to hold a jitlink::MemoryManager field just in case ObjectLinkingLayer is selected.
* [ORC] Remove the automagic Main JITDylib fram ExecutionSession.Lang Hames2019-12-053-13/+4
| | | | | | | | | | | | This patch removes the magic "main" JITDylib from ExecutionEngine. The main JITDylib was created automatically at ExecutionSession construction time, and all subsequently created JITDylibs were added to the main JITDylib's links-against list by default. This saves a couple of lines of boilerplate for simple JIT setups, but this isn't worth introducing magical behavior for. ORCv2 clients should now construct their own main JITDylib using ExecutionSession::createJITDylib and set up its linkages manually using JITDylib::setSearchOrder (or related methods in JITDylib).
* [ORC] Add a runAsMain utility function to ExecutionUtils.Lang Hames2019-12-021-0/+26
| | | | | | | | | | | The runAsMain function takes a pointer to a function with a standard C main signature, int(*)(int, char*[]), and invokes it using the given arguments and program name. The arguments are copied into writable temporary storage as required by the C and C++ specifications, so runAsMain safe to use when calling main functions that modify their arguments in-place. This patch also uses the new runAsMain function to replace hand-rolled versions in lli, llvm-jitlink, and the SpeculativeJIT example.
* [Orc] Add setters for target options and features to JITTargetMachineBuilder.Lang Hames2019-12-021-3/+1
| | | | Also remove redundant feature initialization steps from the detectHost method.
* [ORC][JITLink] Add support for weak references, and improve handling of staticLang Hames2019-11-2813-388/+461
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | libraries. This patch substantially updates ORCv2's lookup API in order to support weak references, and to better support static archives. Key changes: -- Each symbol being looked for is now associated with a SymbolLookupFlags value. If the associated value is SymbolLookupFlags::RequiredSymbol then the symbol must be defined in one of the JITDylibs being searched (or be able to be generated in one of these JITDylibs via an attached definition generator) or the lookup will fail with an error. If the associated value is SymbolLookupFlags::WeaklyReferencedSymbol then the symbol is permitted to be undefined, in which case it will simply not appear in the resulting SymbolMap if the rest of the lookup succeeds. Since lookup now requires these flags for each symbol, the lookup method now takes an instance of a new SymbolLookupSet type rather than a SymbolNameSet. SymbolLookupSet is a vector-backed set of (name, flags) pairs. Clients are responsible for ensuring that the set property (i.e. unique elements) holds, though this is usually simple and SymbolLookupSet provides convenience methods to support this. -- Lookups now have an associated LookupKind value, which is either LookupKind::Static or LookupKind::DLSym. Definition generators can inspect the lookup kind when determining whether or not to generate new definitions. The StaticLibraryDefinitionGenerator is updated to only pull in new objects from the archive if the lookup kind is Static. This allows lookup to be re-used to emulate dlsym for JIT'd symbols without pulling in new objects from archives (which would not happen in a normal dlsym call). -- JITLink is updated to allow externals to be assigned weak linkage, and weak externals now use the SymbolLookupFlags::WeaklyReferencedSymbol value for lookups. Unresolved weak references will be assigned the default value of zero. Since this patch was modifying the lookup API anyway, it alo replaces all of the "MatchNonExported" boolean arguments with a "JITDylibLookupFlags" enum for readability. If a JITDylib's associated value is JITDylibLookupFlags::MatchExportedSymbolsOnly then the lookup will only match against exported (non-hidden) symbols in that JITDylib. If a JITDylib's associated value is JITDylibLookupFlags::MatchAllSymbols then the lookup will match against any symbol defined in the JITDylib.
* [JITLink] Make sure MachO/x86-64 handles 32-bit signed addends correctly.Lang Hames2019-11-271-4/+4
| | | | These need to be sign extended when loading into Edge addends.
* [cmake] Explicitly mark libraries defined in lib/ as "Component Libraries"Tom Stellard2019-11-2110-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Most libraries are defined in the lib/ directory but there are also a few libraries defined in tools/ e.g. libLLVM, libLTO. I'm defining "Component Libraries" as libraries defined in lib/ that may be included in libLLVM.so. Explicitly marking the libraries in lib/ as component libraries allows us to remove some fragile checks that attempt to differentiate between lib/ libraries and tools/ libraires: 1. In tools/llvm-shlib, because llvm_map_components_to_libnames(LIB_NAMES "all") returned a list of all libraries defined in the whole project, there was custom code needed to filter out libraries defined in tools/, none of which should be included in libLLVM.so. This code assumed that any library defined as static was from lib/ and everything else should be excluded. With this change, llvm_map_components_to_libnames(LIB_NAMES, "all") only returns libraries that have been added to the LLVM_COMPONENT_LIBS global cmake property, so this custom filtering logic can be removed. Doing this also fixes the build with BUILD_SHARED_LIBS=ON and LLVM_BUILD_LLVM_DYLIB=ON. 2. There was some code in llvm_add_library that assumed that libraries defined in lib/ would not have LLVM_LINK_COMPONENTS or ARG_LINK_COMPONENTS set. This is only true because libraries defined lib lib/ use LLVMBuild.txt and don't set these values. This code has been fixed now to check if the library has been explicitly marked as a component library, which should now make it easier to remove LLVMBuild at some point in the future. I have tested this patch on Windows, MacOS and Linux with release builds and the following combinations of CMake options: - "" (No options) - -DLLVM_BUILD_LLVM_DYLIB=ON - -DLLVM_LINK_LLVM_DYLIB=ON - -DBUILD_SHARED_LIBS=ON - -DBUILD_SHARED_LIBS=ON -DLLVM_BUILD_LLVM_DYLIB=ON - -DBUILD_SHARED_LIBS=ON -DLLVM_LINK_LLVM_DYLIB=ON Reviewers: beanz, smeenai, compnerd, phosek Reviewed By: beanz Subscribers: wuzish, jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, mgorny, mehdi_amini, sbc100, jgravelle-google, hiraditya, aheejin, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, steven_wu, rogfer01, MartinMosbeck, brucehoult, the_o, dexonsmith, PkmX, jocewei, jsji, dang, Jim, lenary, s.egerton, pzheng, sameer.abuasal, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70179
* [Orc][Modules] Fix Modules build fallout from a34680a33eb.Lang Hames2019-11-202-0/+7
| | | | | | | | | | | | In a34680a33eb OrcError.h and Orc/RPC/*.h were split out from the rest of ExecutionEngine in order to eliminate false dependencies for remote JIT targets (see https://reviews.llvm.org/D68732), however this broke modules builds (see https://reviews.llvm.org/D69817). This patch splits these headers out into a separate module, LLVM_OrcSupport, in order to fix the modules build. Fixes <rdar://56377508>.
* [ExecutionEngine] Add a missing break to avoid warningsMartin Storsjö2019-11-201-0/+1
| | | | This fixes buildbot errors since dc3ee330891c2.
* ExecutionEngine: add preliminary support for COFF ARM64Adam Kallai2019-11-202-0/+367
| | | | Differential Revision: https://reviews.llvm.org/D69434
* Fix a build failure with perf: Add a missing include to ↵Sylvestre Ledru2019-11-161-0/+1
| | | | | | | | llvm/Support/ManagedStatic.h It was failing with PerfJITEventListener.cpp:489:7: error: 'ManagedStatic' in namespace 'llvm' does not name a template type llvm::ManagedStatic<PerfJITEventListener> PerfListener;
* Fix GCC -Wcast-qual warningsHans Wennborg2019-11-151-2/+2
|
* GCC 5.3 build fixHans Wennborg2019-11-151-1/+1
| | | | | | | | | | It was failing with llvm/lib/ExecutionEngine/Orc/DebugUtils.cpp:56:10: error: could not convert ‘Obj’ from ‘std::unique_ptr<llvm::MemoryBuffer>’ to ‘llvm::Expected<std::unique_ptr<llvm::MemoryBuffer> >’ return Obj; ^
* [ORC] Add a utility to support dumping JIT'd objects to disk for debugging.Lang Hames2019-11-145-12/+86
| | | | | | | | | Adds a DumpObjects utility that can be used to dump JIT'd objects to disk. Instances of DebugObjects may be used by ObjectTransformLayer as no-op transforms. This patch also adds an ObjectTransformLayer to LLJIT and an example of how to use this utility to dump JIT'd objects in LLJIT.
* [JITLink] Refactor EH-frame handling to support eh-frames with existing relocs.Lang Hames2019-11-066-320/+537
| | | | | | | | | | | | | | | | | | Some targets (E.g. MachO/arm64) use relocations to fix some CFI record fields in the eh-frame section. When relocations are used the initial (pre-relocation) content of the eh-frame section can no longer be interpreted by following the eh-frame specification. This causes errors in the existing eh-frame parser. This patch moves eh-frame handling into two LinkGraph passes that are run after relocations have been parsed (but before they are applied). The first] pass breaks up blocks in the eh-frame section into per-CFI-record blocks, and the second parses blocks of (potentially multiple) CFI records and adds the appropriate edges to any CFI fields that do not have existing relocations. These passes can be run independently of one another. By handling eh-frame splitting/fixing with LinkGraph passes we can both re-use existing relocations for CFI record fields and avoid applying eh-frame fixups before parsing the section (which would complicate the linker and require extra temporary allocations of working memory).
* [Orc] Fix iterator usage after removeAlexandre Ganea2019-11-061-1/+4
| | | | Differential Revision: https://reviews.llvm.org/D69805
* [JITLink] Move block ownership from LinkGraph to Section.Lang Hames2019-10-301-4/+0
| | | | This enables easy iteration over blocks in a specific section.
* [JITLink] Add a utility for splitting blocks at a given index.Lang Hames2019-10-301-0/+79
| | | | | | | | LinkGraph::splitBlock will split a block at a given index, returning a new block covering the range [ 0, index ) and modifying the original block to cover the range [ index, original-block-size ). Block addresses, content, edges and symbols will be updated as necessary. This utility will be used in upcoming improvements to JITLink's eh-frame support.
* Break out OrcError and RPCChris Bieneman2019-10-298-8/+34
| | | | | | | | | | | | | | | | | | | Summary: When createing an ORC remote JIT target the current library split forces the target process to link large portions of LLVM (Core, Execution Engine, JITLink, Object, MC, Passes, RuntimeDyld, Support, Target, and TransformUtils). This occurs because the ORC RPC interfaces rely on the static globals the ORC Error types require, which starts a cycle of pulling in more and more. This patch breaks the ORC RPC Error implementations out into an "OrcError" library which only depends on LLVM Support. It also pulls the ORC RPC headers into their own subdirectory. With this patch code can include the Orc/RPC/*.h headers and will only incur link dependencies on LLVMOrcError and LLVMSupport. Reviewers: lhames Reviewed By: lhames Subscribers: mgorny, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68732
* [JITLink] Tighten section sorting criteria to fix a flaky test case.Lang Hames2019-10-281-1/+3
| | | | | | | | | | Sections may have zero size and zero-sized sections may share a start address with other zero-sized sections. For the section overlap test to function correctly zero-sized sections must be ordered before any non-zero sized ones. This should fix the intermittent failures in the test/ExecutionEngine/JITLink/X86/MachO_zero_fill_alignment.s test case that have been observed on some builders.
* [llvm/Object] - Make ELFObjectFile::getRelocatedSection return ↵George Rimar2019-10-212-4/+23
| | | | | | | | | | | | | Expected<section_iterator> It returns just a section_iterator currently and have a report_fatal_error call inside. This change adds a way to return errors and handle them on caller sides. The patch also changes/improves current users and adds test cases. Differential revision: https://reviews.llvm.org/D69167 llvm-svn: 375408
* Move endian constant from Host.h to SwapByteOrder.h, prune includeReid Kleckner2019-10-191-0/+1
| | | | | | | | | | | | | | Works on this dependency chain: ArrayRef.h -> Hashing.h -> --CUT-- Host.h -> StringMap.h / StringRef.h ArrayRef is very popular, but Host.h is rarely needed. Move the IsBigEndianHost constant to SwapByteOrder.h. Clients of that header are more likely to need it. llvm-svn: 375316
* [Orc] Add a method for ObjectLinkingLayer to return ownership of object buffers.Lang Hames2019-10-151-0/+7
| | | | | | | | | | | | | | | | RTDyldObjectLinkingLayer allowed clients to register a NotifyEmitted function to reclaim ownership of object buffers once they had been linked. This patch adds similar functionality to ObjectLinkingLayer: Clients can now optionally call the ObjectLinkingLayer::setReturnObjectBuffer method to register a function that will be called when discarding object buffers. If set, this function will be called to return ownership of the object regardless of whether the link succeeded or failed. Use cases for this function include debug dumping (it provides a way to dump all objects linked into JIT'd code) and object re-use (e.g. storing an object in a cache). llvm-svn: 374951
* [JITLink] Switch to slab allocation for InProcessMemoryManager, re-enable test.Lang Hames2019-10-151-10/+40
| | | | | | | | | | | | | | InProcessMemoryManager used to make separate memory allocation calls for each permission level (RW, RX, RO), which could lead to target-out-of-range errors if data and code were placed too far apart (this was the source of failures in the JITLink/AArch64 testcase when it was first landed). This patch updates InProcessMemoryManager to allocate a single slab which is subdivided between text and data. This should guarantee that accesses remain in-range provided that individual object files do not exceed 1Mb in size. This patch also re-enables the JITLink/AArch64 testcase. llvm-svn: 374948
* [Alignment][NFC] Remove dependency on GlobalObject::setAlignment(unsigned)Guillaume Chatelet2019-10-151-1/+1
| | | | | | | | | | | | | | | | | Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet Subscribers: arsenm, mehdi_amini, jvesely, nhaehnle, hiraditya, steven_wu, dexonsmith, dang, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68944 llvm-svn: 374880
* [JITLink] Fix MachO/arm64 GOTPAGEOFF encoding.Lang Hames2019-10-111-2/+5
| | | | | | | | The original implementation failed to shift the immediate down. This should fix some of the bot failures due to r374476. llvm-svn: 374499
* Fix compilation warning due to typo.Michael Liao2019-10-101-1/+1
| | | | llvm-svn: 374479
* [JITLink] Add an initial implementation of JITLink for MachO/AArch64.Lang Hames2019-10-103-0/+737
| | | | | | | | | This implementation has support for all relocation types except TLV. Compact unwind sections are not yet supported, so exceptions/unwinding will not work. llvm-svn: 374476
* Second attempt to add iterator_range::empty()Jordan Rose2019-10-071-1/+1
| | | | | | | | | | | | Doing this makes MSVC complain that `empty(someRange)` could refer to either C++17's std::empty or LLVM's llvm::empty, which previously we avoided via SFINAE because std::empty is defined in terms of an empty member rather than begin and end. So, switch callers over to the new method as it is added. https://reviews.llvm.org/D68439 llvm-svn: 373935
* [JITLink] Silence GCC warnings. NFC.Martin Storsjo2019-10-041-1/+1
| | | | | | | | Use parentheses in an expression with mixed && and ||. Differential Revision: https://reviews.llvm.org/D68447 llvm-svn: 373779
* Fix MSVC "not all control paths return a value" warning. NFCI.Simon Pilgrim2019-10-041-0/+2
| | | | llvm-svn: 373730
* Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.Simon Pilgrim2019-10-041-1/+1
| | | | llvm-svn: 373729
* [JITLink] Explicitly destroy bumpptr-allocated blocks to avoid a memory leak.Lang Hames2019-10-041-0/+6
| | | | llvm-svn: 373693
* [JITLink] Fix an unused variable warning.Lang Hames2019-10-041-3/+2
| | | | llvm-svn: 373692
* [JITLink] Switch from an atom-based model to a "blocks and symbols" model.Lang Hames2019-10-0415-1328/+1488
| | | | | | | | | | | | | | | | | | | | | | | | In the Atom model the symbols, content and relocations of a relocatable object file are represented as a graph of atoms, where each Atom represents a contiguous block of content with a single name (or no name at all if the content is anonymous), and where edges between Atoms represent relocations. If more than one symbol is associated with a contiguous block of content then the content is broken into multiple atoms and layout constraints (represented by edges) are introduced to ensure that the content remains effectively contiguous. These layout constraints must be kept in mind when examining the content associated with a symbol (it may be spread over multiple atoms) or when applying certain relocation types (e.g. MachO subtractors). This patch replaces the Atom model in JITLink with a blocks-and-symbols model. The blocks-and-symbols model represents relocatable object files as bipartite graphs, with one set of nodes representing contiguous content (Blocks) and another representing named or anonymous locations (Symbols) within a Block. Relocations are represented as edges from Blocks to Symbols. This scheme removes layout constraints (simplifying handling of MachO alt-entry symbols, and hopefully ELF sections at some point in the future) and simplifies some relocation logic. llvm-svn: 373689
OpenPOWER on IntegriCloud