mirror of
https://github.com/apache/impala.git
synced 2026-01-06 06:01:03 -05:00
Adds support for communicating function-level symbols to perf by writing
/tmp/perf-<pid>.data if the --perf_map=true argument is set. Perf must
be run under the same user as Impala. I.e. 'sudo perf top' does not
work. To get perf to work under a non-root user you will probably need
to disable some kernel security features that perf complains about:
sudo bash -c 'echo -1 > /proc/sys/kernel/perf_event_paranoid'
sudo bash -c 'echo 0 > /proc/sys/kernel/kptr_restrict'
Once you get it working you should see IR function names concatenated with
the fragment instance id in 'perf top'. 'perf annotate' does not work.
Implements --asm_module_dir, analogous to --opt_module_dir. We dump
disassembly to files there. Debug symbols are interleaved with the
assembly if they are available. I enabled them for the debug
build, now that we have some purpose for them. In some cases
it would be useful to have them for the release build, but
they make the llvm module much larger so I haven't enabled them
there.
The asm dump for a random exception constructor looks like this:
Disassembly for __cxx_global_var_init.165:324bc8754182e7c6:22735c36d7a2bc0 (0x7f50f2140300):
date_facet.hpp:date_facet.hpp:<invalid>:363:0
date_facet.hpp:date_facet.hpp:<invalid>:363:58
0: movabsq $0, %rax
10: movb (%rax), %cl
12: cmpb $0, %cl
15: jne 17
date_facet.hpp:date_facet.hpp:<invalid>:363:58
17: movabsq $0, %rax
27: movq $1, (%rax)
date_facet.hpp:date_facet.hpp:<invalid>:363:58
34: retq
Change-Id: If25de61e46f4db005956686cddbd4d71a1424528
Reviewed-on: http://gerrit.cloudera.org:8080/2793
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Tested-by: Internal Jenkins
88 lines
2.8 KiB
CMake
88 lines
2.8 KiB
CMake
# Find the native LLVM includes and library
|
|
#
|
|
# LLVM_ROOT - hints the search path
|
|
# LLVM_INCLUDE_DIR - where to find llvm include files
|
|
# LLVM_LIBRARY_DIR - where to find llvm libs
|
|
# LLVM_LFLAGS - llvm linker flags
|
|
# LLVM_MODULE_LIBS - list of llvm libs for working with modules.
|
|
|
|
# First look in LLVM_ROOT then ENV{LLVM_HOME} then system path.
|
|
find_program(LLVM_CONFIG_EXECUTABLE llvm-config
|
|
PATHS
|
|
${LLVM_ROOT}/bin
|
|
$ENV{LLVM_HOME}
|
|
NO_DEFAULT_PATH
|
|
)
|
|
|
|
if (LLVM_CONFIG_EXECUTABLE STREQUAL "LLVM_CONFIG_EXECUTABLE-NOTFOUND")
|
|
message(FATAL_ERROR "Could not find llvm-config")
|
|
endif ()
|
|
|
|
# Check LLVM Version to be compatible
|
|
execute_process(
|
|
COMMAND ${LLVM_CONFIG_EXECUTABLE} --version
|
|
OUTPUT_VARIABLE LLVM_VERSION
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
if (NOT "${LLVM_VERSION}" VERSION_EQUAL "$ENV{IMPALA_LLVM_VERSION}")
|
|
message(FATAL_ERROR
|
|
"LLVM version must be $ENV{IMPALA_LLVM_VERSION}. Found version: ${LLVM_VERSION}")
|
|
endif()
|
|
|
|
message(STATUS "LLVM llvm-config found at: ${LLVM_CONFIG_EXECUTABLE}")
|
|
|
|
execute_process(
|
|
COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir
|
|
OUTPUT_VARIABLE LLVM_INCLUDE_DIR
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
execute_process(
|
|
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir
|
|
OUTPUT_VARIABLE LLVM_LIBRARY_DIR
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
execute_process(
|
|
COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags
|
|
OUTPUT_VARIABLE LLVM_LFLAGS
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
# TODO: this does not work well. the config file will output -I/<include path> and
|
|
# also -DNDEBUG. I've hard coded the #define that are necessary but we should make
|
|
# this better. The necesesary flags are only #defines so maybe just def/undef those
|
|
# around #include to llvm headers?
|
|
#execute_process(
|
|
# COMMAND ${LLVM_CONFIG_EXECUTABLE} --cxxflags
|
|
# OUTPUT_VARIABLE LLVM_CFLAGS
|
|
# OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
#)
|
|
set(LLVM_CFLAGS
|
|
"-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS")
|
|
|
|
|
|
# Get the link libs we need. llvm has many and we don't want to link all of the libs
|
|
# if we don't need them.
|
|
execute_process(
|
|
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libnames core mcjit native ipo bitreader target linker analysis debuginfodwarf
|
|
OUTPUT_VARIABLE LLVM_MODULE_LIBS
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
# CMake really doesn't like adding link directories and wants absolute paths
|
|
# Reconstruct it with LLVM_MODULE_LIBS and LLVM_LIBRARY_DIR
|
|
string(REPLACE " " ";" LIBS_LIST ${LLVM_MODULE_LIBS})
|
|
set (LLVM_MODULE_LIBS "")
|
|
foreach (LIB ${LIBS_LIST})
|
|
set(LLVM_MODULE_LIBS ${LLVM_MODULE_LIBS} "${LLVM_LIBRARY_DIR}/${LIB}")
|
|
endforeach(LIB)
|
|
|
|
message(STATUS "LLVM include dir: ${LLVM_INCLUDE_DIR}")
|
|
message(STATUS "LLVM lib dir: ${LLVM_LIBRARY_DIR}")
|
|
|
|
if (CMAKE_DEBUG)
|
|
message(STATUS "LLVM libs: ${LLVM_MODULE_LIBS}")
|
|
endif()
|