2016-07-10 10:43:50 +08:00
|
|
|
if ( LLVM_INCLUDE_UTILS )
|
|
|
|
add_subdirectory(ChildTarget)
|
|
|
|
endif()
|
2012-03-13 16:33:15 +08:00
|
|
|
|
2013-12-10 19:13:32 +08:00
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
CodeGen
|
|
|
|
Core
|
|
|
|
ExecutionEngine
|
|
|
|
IRReader
|
|
|
|
Interpreter
|
2014-07-14 13:01:53 +08:00
|
|
|
MC
|
2013-12-10 19:13:32 +08:00
|
|
|
MCJIT
|
2014-07-14 13:01:53 +08:00
|
|
|
Object
|
[Orc] New JIT APIs.
This patch adds a new set of JIT APIs to LLVM. The aim of these new APIs is to
cleanly support a wider range of JIT use cases in LLVM, and encourage the
development and contribution of re-usable infrastructure for LLVM JIT use-cases.
These APIs are intended to live alongside the MCJIT APIs, and should not affect
existing clients.
Included in this patch:
1) New headers in include/llvm/ExecutionEngine/Orc that provide a set of
components for building JIT infrastructure.
Implementation code for these headers lives in lib/ExecutionEngine/Orc.
2) A prototype re-implementation of MCJIT (OrcMCJITReplacement) built out of the
new components.
3) Minor changes to RTDyldMemoryManager needed to support the new components.
These changes should not impact existing clients.
4) A new flag for lli, -use-orcmcjit, which will cause lli to use the
OrcMCJITReplacement class as its underlying execution engine, rather than
MCJIT itself.
Tests to follow shortly.
Special thanks to Michael Ilseman, Pete Cooper, David Blaikie, Eric Christopher,
Justin Bogner, and Jim Grosbach for extensive feedback and discussion.
llvm-svn: 226940
2015-01-24 05:25:00 +08:00
|
|
|
OrcJIT
|
2015-02-16 10:13:30 +08:00
|
|
|
RuntimeDyld
|
2013-12-10 19:13:32 +08:00
|
|
|
SelectionDAG
|
|
|
|
Support
|
2015-06-04 03:07:51 +08:00
|
|
|
Target
|
2015-05-05 06:33:39 +08:00
|
|
|
TransformUtils
|
2013-12-10 19:13:32 +08:00
|
|
|
native
|
|
|
|
)
|
2010-09-14 07:59:48 +08:00
|
|
|
|
2012-03-13 16:33:15 +08:00
|
|
|
if( LLVM_USE_OPROFILE )
|
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
${LLVM_LINK_COMPONENTS}
|
|
|
|
OProfileJIT
|
|
|
|
)
|
|
|
|
endif( LLVM_USE_OPROFILE )
|
|
|
|
|
|
|
|
if( LLVM_USE_INTEL_JITEVENTS )
|
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
${LLVM_LINK_COMPONENTS}
|
2015-01-31 02:07:45 +08:00
|
|
|
DebugInfoDWARF
|
2012-03-13 16:33:15 +08:00
|
|
|
IntelJITEvents
|
2013-01-29 03:52:37 +08:00
|
|
|
Object
|
2012-03-13 16:33:15 +08:00
|
|
|
)
|
|
|
|
endif( LLVM_USE_INTEL_JITEVENTS )
|
|
|
|
|
Add PerfJITEventListener for perf profiling support.
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
2018-07-24 08:54:06 +08:00
|
|
|
if( LLVM_USE_PERF )
|
|
|
|
set(LLVM_LINK_COMPONENTS
|
|
|
|
${LLVM_LINK_COMPONENTS}
|
|
|
|
DebugInfoDWARF
|
|
|
|
PerfJITEvents
|
|
|
|
Object
|
|
|
|
)
|
|
|
|
endif( LLVM_USE_PERF )
|
|
|
|
|
2008-09-22 09:08:49 +08:00
|
|
|
add_llvm_tool(lli
|
|
|
|
lli.cpp
|
2016-11-19 10:05:19 +08:00
|
|
|
|
|
|
|
DEPENDS
|
|
|
|
intrinsics_gen
|
2008-09-22 09:08:49 +08:00
|
|
|
)
|
2015-03-19 04:21:06 +08:00
|
|
|
export_executable_symbols(lli)
|