summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine
Commit message (Collapse)AuthorAgeFilesLines
...
* Move JIT listener C binding fallbackks to ExecutionEngineBindings.cpp.Andres Freund2018-07-251-0/+24
| | | | | | | | | | | | | | | | | | | | | Initially, in https://reviews.llvm.org/D44890, I had these defined as empty functions inside the header when the respective event listener was not built in. As done in that commit, that wasn't correct, because it was a ODR violation. Krasimir hot-fixed that in r333265, but that wasn't quite right either, because it'd lead to the symbol not being available. Instead just move the fallbacksto ExecutionEngineBindings.cpp. Could define them as static inlines in the header too, but I don't think it matters. Reviewers: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49654 llvm-svn: 337930
* Add PerfJITEventListener for perf profiling support.Andres Freund2018-07-245-1/+529
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new JIT event listener supports generating profiling data for the linux 'perf' profiling tool, allowing it to generate function and instruction level profiles. Currently this functionality is not enabled by default, but must be enabled with LLVM_USE_PERF=yes. Given that the listener has no dependencies, it might be sensible to enable by default once the initial issues have been shaken out. I followed existing precedent in registering the listener by default in lli. Should there be a decision to enable this by default on linux, that should probably be changed. Please note that until https://reviews.llvm.org/D47343 is resolved, using this functionality with mcjit rather than orcjit will not reliably work. Disregarding the previous comment, here's an example: $ cat /tmp/expensive_loop.c bool stupid_isprime(uint64_t num) { if (num == 2) return true; if (num < 1 || num % 2 == 0) return false; for(uint64_t i = 3; i < num / 2; i+= 2) { if (num % i == 0) return false; } return true; } int main(int argc, char **argv) { int numprimes = 0; for (uint64_t num = argc; num < 100000; num++) { if (stupid_isprime(num)) numprimes++; } return numprimes; } $ clang -ggdb -S -c -emit-llvm /tmp/expensive_loop.c -o /tmp/expensive_loop.ll $ perf record -o perf.data -g -k 1 ./bin/lli -jit-kind=mcjit /tmp/expensive_loop.ll 1 $ perf inject --jit -i perf.data -o perf.jit.data $ perf report -i perf.jit.data - 92.59% lli jitted-5881-2.so [.] stupid_isprime stupid_isprime main llvm::MCJIT::runFunction llvm::ExecutionEngine::runFunctionAsMain main __libc_start_main 0x4bf6258d4c544155 + 0.85% lli ld-2.27.so [.] do_lookup_x And line-level annotations also work: │ for(uint64_t i = 3; i < num / 2; i+= 2) { │1 30: movq $0x3,-0x18(%rbp) 0.03 │1 38: mov -0x18(%rbp),%rax 0.03 │ mov -0x10(%rbp),%rcx │ shr $0x1,%rcx 3.63 │ ┌──cmp %rcx,%rax │ ├──jae 6f │ │ if (num % i == 0) 0.03 │ │ mov -0x10(%rbp),%rax │ │ xor %edx,%edx 89.00 │ │ divq -0x18(%rbp) │ │ cmp $0x0,%rdx 0.22 │ │↓ jne 5f │ │ return false; │ │ movb $0x0,-0x1(%rbp) │ │↓ jmp 73 │ │ } 3.22 │1 5f:│↓ jmp 61 │ │ for(uint64_t i = 3; i < num / 2; i+= 2) { Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D44892 llvm-svn: 337789
* [ORC] Re-apply r336760 with fixes.Lang Hames2018-07-213-4/+38
| | | | llvm-svn: 337637
* Re-apply r337595 with fix for LLVM_ENABLE_THREADS=Off.Lang Hames2018-07-205-281/+518
| | | | llvm-svn: 337626
* Revert r337595 "[ORC] Add new symbol lookup methods to ExecutionSessionBase ↵Reid Kleckner2018-07-205-518/+281
| | | | | | | | in preparation for" Breaks the build with LLVM_ENABLE_THREADS=OFF. llvm-svn: 337608
* [ORC] Add new symbol lookup methods to ExecutionSessionBase in preparation forLang Hames2018-07-205-281/+518
| | | | | | | | | | | | deprecating SymbolResolver and AsynchronousSymbolQuery. Both lookup overloads take a VSO search order to perform the lookup. The first overload is non-blocking and takes OnResolved and OnReady callbacks. The second is blocking, takes a boolean flag to indicate whether to wait until all symbols are ready, and returns a SymbolMap. Both overloads take a RegisterDependencies function to register symbol dependencies (if any) on the query. llvm-svn: 337595
* [ORC] Simplify VSO::lookupFlags to return the flags map.Lang Hames2018-07-206-31/+27
| | | | | | | | | | | This discards the unresolved symbols set and returns the flags map directly (rather than mutating it via the first argument). The unresolved symbols result made it easy to chain lookupFlags calls, but such chaining should be rare to non-existant (especially now that symbol resolvers are being deprecated) so the simpler method signature is preferable. llvm-svn: 337594
* [ORC] Replace SymbolResolvers in the new ORC layers with search orders on VSOs.Lang Hames2018-07-205-97/+148
| | | | | | | | | | | | | | | A search order is a list of VSOs to be searched linearly to find symbols. Each VSO now has a search order that will be used when fixing up definitions in that VSO. Each VSO's search order defaults to just that VSO itself. This is a first step towards removing symbol resolvers from ORC altogether. In practice symbol resolvers tended to be used to implement a search order anyway, sometimes with additional programatic generation of symbols. Now that VSOs support programmatic generation of definitions via fallback generators, search orders provide a cleaner way to achieve the desired effect (while removing a lot of boilerplate). llvm-svn: 337593
* Fix few typos in comments (write access test commit)Stefan Granitz2018-07-121-2/+2
| | | | llvm-svn: 336887
* Revert r336760: "[ORC] Add unit tests for the reexports utility that were..."Lang Hames2018-07-111-1/+1
| | | | | | | This patch broke a few buildbots. I will investigate and re-apply when I have a fix. llvm-svn: 336767
* [ORC] Add unit tests for the reexports utility that were left out of r336741,Lang Hames2018-07-111-1/+1
| | | | | | and fix a bug that these exposed. llvm-svn: 336760
* [ORC] Generalize alias materialization to support re-exports (i.e. aliasing ofLang Hames2018-07-101-40/+138
| | | | | | | | | symbols in another VSO). Also fixes a bug where chained aliases within a single VSO would deadlock on materialization. llvm-svn: 336741
* [ORC] Rename MaterializationResponsibility::delegate to replace and add a newLang Hames2018-07-092-3/+20
| | | | | | | | | | | | | delegate method (and unit test). The name 'replace' better captures what the old delegate method did: it returned materialization responsibility for a set of symbols to the VSO. The new delegate method delegates responsibility for a set of symbols to a new MaterializationResponsibility instance. This can be used to split responsibility between multiple threads, or multiple materialization methods. llvm-svn: 336603
* [ORC] Add BitReader/BitWriter to target_link_librariesHeejin Ahn2018-07-051-0/+6
| | | | | | | | | | | | | | Summary: CompileOnDemandLayer.cpp uses function in these libraries, and builds with `-DSHARED_LIB=ON` fail without this. Reviewers: lhames Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D48995 llvm-svn: 336389
* [ORC] In CompileOnDemandLayer2, clone modules on to different contexts byLang Hames2018-07-051-77/+79
| | | | | | | | | | | | | | | writing them to a buffer and re-loading them. Also introduces a multithreaded variant of SimpleCompiler (MultiThreadedSimpleCompiler) for compiling IR concurrently on multiple threads. These changes are required to JIT IR on multiple threads correctly. No test case yet. I will be looking at how to modify LLI / LLJIT to test multithreaded JIT support soon. llvm-svn: 336385
* [ORC] Verify modules when running LLLazyJIT in LLI, and deal with fallout.Lang Hames2018-07-021-3/+7
| | | | | | | | The verifier identified several modules that were broken due to incorrect linkage on declarations. To fix this, CompileOnDemandLayer2::extractFunction has been updated to change decls to external linkage. llvm-svn: 336150
* [ORC] Don't call isa<> on a null value.Lang Hames2018-06-261-1/+1
| | | | | | This should fix the recent builder failures in the test-global-ctors.ll testcase. llvm-svn: 335680
* [ORC] Fix a missing return value.Lang Hames2018-06-261-0/+2
| | | | llvm-svn: 335677
* [ORC] Add a dependence on MC to LLVMBuild.txtLang Hames2018-06-261-2/+2
| | | | llvm-svn: 335673
* [ORC] Add LLJIT and LLLazyJIT, and replace OrcLazyJIT in LLI with LLLazyJIT.Lang Hames2018-06-267-19/+402
| | | | | | | | | | | | | | | | | | | LLJIT is a prefabricated ORC based JIT class that is meant to be the go-to replacement for MCJIT. Unlike OrcMCJITReplacement (which will continue to be supported) it is not API or bug-for-bug compatible, but targets the same use cases: Simple, non-lazy compilation and execution of LLVM IR. LLLazyJIT extends LLJIT with support for function-at-a-time lazy compilation, similar to what was provided by LLVM's original (now long deprecated) JIT APIs. This commit also contains some simple utility classes (CtorDtorRunner2, LocalCXXRuntimeOverrides2, JITTargetMachineBuilder) to support LLJIT and LLLazyJIT. Both of these classes are works in progress. Feedback from JIT clients is very welcome! llvm-svn: 335670
* [ORC] Reset AsynchronousSymbolQuery's NotifySymbolsResolved callback on error.Lang Hames2018-06-261-3/+4
| | | | | | | | AsynchronousSymbolQuery::canStillFail checks the value of the callback to prevent sending it redundant error notifications, so we need to reset it after running it. llvm-svn: 335664
* [ORC] Move the VSOList typedef out of VSO.Lang Hames2018-06-261-3/+2
| | | | llvm-svn: 335663
* [ORC] Fix a FIXME by moving MangleAndInterner to Core.h.Lang Hames2018-06-262-12/+14
| | | | llvm-svn: 335661
* [ORC] Add a symbolAliases function to the Core APIs.Lang Hames2018-06-261-9/+80
| | | | | | symbolAliases can be used to define symbol aliases within a VSO. llvm-svn: 335565
* [ORC] Fix formatting and list pending queries in VSO::dump.Lang Hames2018-06-231-3/+7
| | | | llvm-svn: 335408
* [RuntimeDyld] Implement the ELF PIC large code model relocationsReid Kleckner2018-06-221-0/+43
| | | | | | | Prerequisite for https://reviews.llvm.org/D47211 which improves our ELF large PIC codegen. llvm-svn: 335402
* [ORC] Add an initial implementation of a replacement CompileOnDemandLayer.Lang Hames2018-06-183-1/+346
| | | | | | | | | CompileOnDemandLayer2 is a replacement for CompileOnDemandLayer built on the ORC Core APIs. Functions in added modules are extracted and compiled lazily. CompileOnDemandLayer2 supports multithreaded JIT'd code, and compilation on multiple threads. llvm-svn: 334967
* [ORC] Keep weak flag on VSO symbol tables during materialization, but treatLang Hames2018-06-181-8/+7
| | | | | | | | | | | | materializing weak symbols as strong. This removes some elaborate flag tweaking and plays nicer with RuntimeDyld, which relies of weak/common flags to determine whether it should emit a given weak definition. (Switching to strong up-front makes it appear as if there is already an overriding definition, which would require an extra back-channel to override). llvm-svn: 334966
* [ORC] Remove redundant conditionLang Hames2018-06-171-1/+1
| | | | llvm-svn: 334918
* [ORC] Only notify queries that they are resolved/ready when the query stateLang Hames2018-06-171-8/+30
| | | | | | | | changes. This guards against redundant notifications. llvm-svn: 334916
* [ORC] Suppress an unused variable warning for a debug-mode only use.Lang Hames2018-06-171-0/+1
| | | | llvm-svn: 334911
* [ORC] Erase empty dependence sets when adding new symbol dependencies.Lang Hames2018-06-171-0/+3
| | | | llvm-svn: 334910
* [ORC] In MaterializationResponsibility, only maintain the Materializing flag onLang Hames2018-06-171-2/+12
| | | | | | | | | | | symbols in debug mode. The MaterializationResponsibility class hijacks the Materializing flag to track symbols that have not yet been resolved in order to guard against redundant resolution. Since this is an API contract check and only enforced in debug mode there is no reason to maintain the flag state in release mode. llvm-svn: 334909
* [PPC64] Support "symbol@high" and "symbol@higha" symbol modifers.Sean Fertile2018-06-151-0/+2
| | | | | | | | | | Add support for the "@high" and "@higha" symbol modifiers in powerpc64 assembly. The modifiers represent accessing the segment consiting of bits 16-31 of a 64-bit address/offset. Differential Revision: https://reviews.llvm.org/D47729 llvm-svn: 334855
* Add debug info for OProfile profiling supportAndrew Kaylor2018-06-152-2/+26
| | | | | | | | Patch by Gaetano Priori Differential Revision: https://reviews.llvm.org/D47925 llvm-svn: 334782
* [ORC] Strip weak flags from a symbol once it is selected for materialization.Lang Hames2018-06-141-3/+4
| | | | | | | | | Once a symbol has been selected for materialization it can no longer be overridden. Stripping the weak flag guarantees this (override attempts will then be treated as duplicate definitions and result in a DuplicateDefinition error). llvm-svn: 334771
* [ORC] Filter out self-dependencies in VSO::addDependencies.Lang Hames2018-06-141-1/+1
| | | | llvm-svn: 334724
* [ORC] Assert that the query argument to VSO::lookup must be non-null.Lang Hames2018-06-141-0/+2
| | | | llvm-svn: 334723
* [ORC] Add a WaitUntilReady argument to blockingLookup.Lang Hames2018-06-142-24/+44
| | | | | | | | | | | If WaitUntilReady is set to true then blockingLookup will return once all requested symbols are ready. If WaitUntilReady is set to false then blockingLookup will return as soon as all requested symbols have been resolved. In the latter case, if any error occurs in finalizing the symbols it will be reported to the ExecutionSession, rather than returned by blockingLookup. llvm-svn: 334722
* [ORC] Strip the Materializing flag off finalized symbols in VSOs.Lang Hames2018-06-141-3/+6
| | | | | | Finalized symbols are no longer in the materializing state. llvm-svn: 334721
* Fix -DLLVM_ENABLE_THREADS=OFF build after r334537Hans Wennborg2018-06-131-1/+1
| | | | llvm-svn: 334582
* Remove malloc.h include from Intel JIT events codeReid Kleckner2018-06-121-1/+0
| | | | llvm-svn: 334547
* Add null check to Intel JIT event listenerReid Kleckner2018-06-121-4/+6
| | | | llvm-svn: 334544
* [ORC] Add a fallback definition generator for VSOs.Lang Hames2018-06-121-66/+100
| | | | | | | | | | | | If a VSO has a fallback definition generator attached it will be called during lookup (and lookupFlags) for any unresolved symbols. The definition generator can add new definitions to the VSO for any unresolved symbol. This allows VSOs to generate new definitions on demand. The immediate use case for this code is supporting VSOs that can import definitions found via dlsym on demand. llvm-svn: 334538
* [ORC] Refactor blocking lookup logic into the blockingLookup function, andLang Hames2018-06-124-60/+61
| | | | | | | implement existing blocking lookups (the lookup function) and JITSymbolResolverAdapter on top of that. llvm-svn: 334537
* [RuntimeDyld] Add an assert to catch misbehaving symbol resolvers.Lang Hames2018-06-121-0/+3
| | | | | | | | | Resolvers are required to find results for all requested symbols or return an error, but if a resolver fails to adhere to this contract (by returning results for only a subset of the requested symbols) then this code will infinite loop. This assertion catches resolvers that fail to adhere to the contract. llvm-svn: 334536
* [MCJIT] Call materializeAll on modules before compiling them in MCJIT.Lang Hames2018-06-121-0/+6
| | | | | | | | | This only affects modules with lazy GVMaterializers attached (usually modules read off disk using the lazy bitcode reader). For such modules, materializing before compiling prevents crashes due to missing function bodies / initializers. llvm-svn: 334535
* [ORC] Add a constructor to create an IRMaterializationUnit from a module andLang Hames2018-06-031-0/+6
| | | | | | | | | | pre-existing SymbolFlags and SymbolToDefinition maps. This constructor is useful when delegating work from an existing IRMaterialiaztionUnit to a new one, as it avoids the cost of re-computing these maps. llvm-svn: 333852
* [ORC] Add a getRequestedSymbols method to MaterializationResponsibility.Lang Hames2018-05-311-7/+37
| | | | | | | | | | | This method returns the set of symbols in the target VSO that have queries waiting on them. This can be used to make decisions about which symbols to delegate to another MaterializationUnit (typically this will involve delegating all symbols that have *not* been requested to another MaterializationUnit so that materialization of those symbols can be deferred until they are requested). llvm-svn: 333684
* [ORC] Rename IRMaterializationUnit's Discardable member to SymbolToDefinition,Lang Hames2018-05-311-4/+6
| | | | | | | | | | and make it protected rather than private. The new name reflects the actual information in the map, and this information can be useful to derived classes (for example, to quickly look up the IR definition of a requested symbol). llvm-svn: 333683
OpenPOWER on IntegriCloud