From 61b1851a205cb8dd29c1d3d4231efb8f8f7da283 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Tue, 13 Mar 2012 08:33:15 +0000 Subject: Add profiling support for Intel Parallel Amplifier XE (VTune) for JITted code in LLVM. Also refactor the existing OProfile profiling code to reuse the same interfaces with the VTune profiling code. In addition, unit tests for the profiling interfaces were added. This patch was prepared by Andrew Kaylor and Daniel Malea, and reviewed in the llvm-commits list by Jim Grosbach git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152620 91177308-0d34-0410-b5e6-96231b3b80d8 --- configure | 363 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 350 insertions(+), 13 deletions(-) (limited to 'configure') diff --git a/configure b/configure index 00f49dff84..b7e42a706d 100755 --- a/configure +++ b/configure @@ -766,6 +766,9 @@ NO_MISSING_FIELD_INITIALIZERS COVERED_SWITCH_DEFAULT USE_UDIS86 USE_OPROFILE +USE_INTEL_JITEVENTS +INTEL_JITEVENTS_INCDIR +INTEL_JITEVENTS_LIBDIR HAVE_PTHREAD HUGE_VAL_SANITY MMAP_FILE @@ -1451,6 +1454,10 @@ Optional Packages: --with-udis86= Use udis86 external x86 disassembler library --with-oprofile= Tell OProfile >= 0.9.4 how to symbolize JIT output + --with-intel-jitevents= + Specify location of run-time support library for + Intel JIT API + (default=/opt/intel/vtune_amplifier_xe_2011) Some influential environment variables: CC C compiler command @@ -10395,7 +10402,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5 + case $llvm_cv_os_type in + Linux) + if test -n "$llvm_cv_oppath" ; then + LIBS="$LIBS -lopagent -L${llvm_cv_oppath} -Wl,-rpath,${llvm_cv_oppath}" + { echo "$as_me:$LINENO: checking for library containing bfd_init" >&5 echo $ECHO_N "checking for library containing bfd_init... $ECHO_C" >&6; } if test "${ac_cv_search_bfd_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -13361,7 +13370,7 @@ if test "$ac_res" != no; then fi - { echo "$as_me:$LINENO: checking for library containing op_open_agent" >&5 + { echo "$as_me:$LINENO: checking for library containing op_open_agent" >&5 echo $ECHO_N "checking for library containing op_open_agent... $ECHO_C" >&6; } if test "${ac_cv_search_op_open_agent+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -13460,12 +13469,12 @@ if test "$ac_res" != no; then else - echo "Error! You need to have libopagent around." - exit -1 + echo "Error! You need to have libopagent around." + exit -1 fi - if test "${ac_cv_header_opagent_h+set}" = set; then + if test "${ac_cv_header_opagent_h+set}" = set; then { echo "$as_me:$LINENO: checking for opagent.h" >&5 echo $ECHO_N "checking for opagent.h... $ECHO_C" >&6; } if test "${ac_cv_header_opagent_h+set}" = set; then @@ -13623,13 +13632,18 @@ if test $ac_cv_header_opagent_h = yes; then : else - echo "Error! You need to have opagent.h around." - exit -1 + echo "Error! You need to have opagent.h around." + exit -1 fi - fi + fi ;; + *) + { { echo "$as_me:$LINENO: error: OProfile support is available on Linux only." >&5 +echo "$as_me: error: OProfile support is available on Linux only." >&2;} + { (exit 1); exit 1; }; } ;; + esac else @@ -13640,7 +13654,327 @@ fi cat >>confdefs.h <<_ACEOF -#define USE_OPROFILE $USE_OPROFILE +#define LLVM_USE_OPROFILE $USE_OPROFILE +_ACEOF + + + +# Check whether --with-intel-jitevents was given. +if test "${with_intel_jitevents+set}" = set; then + withval=$with_intel_jitevents; + case $llvm_cv_os_type in + Linux|Win32|Cygwin|MingW) ;; + *) + { { echo "$as_me:$LINENO: error: + Intel JIT API support is available on Linux and Windows only.\"" >&5 +echo "$as_me: error: + Intel JIT API support is available on Linux and Windows only.\"" >&2;} + { (exit 1); exit 1; }; } ;; + esac + + USE_INTEL_JITEVENTS=1 + + case "$llvm_cv_target_arch" in + x86) llvm_intel_jitevents_archdir="lib32";; + x86_64) llvm_intel_jitevents_archdir="lib64";; + *) echo "Target architecture $llvm_cv_target_arch does not support Intel JIT Events API" + exit -1;; + esac + INTEL_JITEVENTS_INCDIR="/opt/intel/vtune_amplifier_xe_2011/include" + INTEL_JITEVENTS_LIBDIR="/opt/intel/vtune_amplifier_xe_2011/$llvm_intel_jitevents_archdir" + case "$withval" in + /* | [A-Za-z]:[\\/]*) INTEL_JITEVENTS_INCDIR=$withval/include + INTEL_JITEVENTS_LIBDIR=$withval/$llvm_intel_jitevents_archdir ;; + *) ;; + + esac + + + + + LIBS="$LIBS -L${INTEL_JITEVENTS_LIBDIR}" + CPPFLAGS="$CPPFLAGS -I$INTEL_JITEVENTS_INCDIR" + + { echo "$as_me:$LINENO: checking for library containing iJIT_IsProfilingActive" >&5 +echo $ECHO_N "checking for library containing iJIT_IsProfilingActive... $ECHO_C" >&6; } +if test "${ac_cv_search_iJIT_IsProfilingActive+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char iJIT_IsProfilingActive (); +int +main () +{ +return iJIT_IsProfilingActive (); + ; + return 0; +} +_ACEOF +for ac_lib in '' jitprofiling; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_search_iJIT_IsProfilingActive=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_iJIT_IsProfilingActive+set}" = set; then + break +fi +done +if test "${ac_cv_search_iJIT_IsProfilingActive+set}" = set; then + : +else + ac_cv_search_iJIT_IsProfilingActive=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_iJIT_IsProfilingActive" >&5 +echo "${ECHO_T}$ac_cv_search_iJIT_IsProfilingActive" >&6; } +ac_res=$ac_cv_search_iJIT_IsProfilingActive +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +else + + echo "Error! Cannot find libjitprofiling.a. Please check path specified in flag --with-intel-jitevents" + exit -1 + +fi + + if test "${ac_cv_header_jitprofiling_h+set}" = set; then + { echo "$as_me:$LINENO: checking for jitprofiling.h" >&5 +echo $ECHO_N "checking for jitprofiling.h... $ECHO_C" >&6; } +if test "${ac_cv_header_jitprofiling_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_jitprofiling_h" >&5 +echo "${ECHO_T}$ac_cv_header_jitprofiling_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking jitprofiling.h usability" >&5 +echo $ECHO_N "checking jitprofiling.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking jitprofiling.h presence" >&5 +echo $ECHO_N "checking jitprofiling.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: jitprofiling.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: jitprofiling.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: jitprofiling.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: jitprofiling.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: jitprofiling.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: jitprofiling.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: jitprofiling.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: jitprofiling.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: jitprofiling.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: jitprofiling.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: jitprofiling.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: jitprofiling.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: jitprofiling.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: jitprofiling.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: jitprofiling.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: jitprofiling.h: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## ------------------------------------ ## +## Report this to http://llvm.org/bugs/ ## +## ------------------------------------ ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for jitprofiling.h" >&5 +echo $ECHO_N "checking for jitprofiling.h... $ECHO_C" >&6; } +if test "${ac_cv_header_jitprofiling_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_jitprofiling_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_jitprofiling_h" >&5 +echo "${ECHO_T}$ac_cv_header_jitprofiling_h" >&6; } + +fi +if test $ac_cv_header_jitprofiling_h = yes; then + : +else + + echo "Error! Cannot find jitprofiling.h. Please check path specified in flag --with-intel-jitevents" + exit -1 + +fi + + + + +else + + USE_INTEL_JITEVENTS=0 + + +fi + + +cat >>confdefs.h <<_ACEOF +#define LLVM_USE_INTEL_JITEVENTS $USE_INTEL_JITEVENTS _ACEOF @@ -21913,6 +22247,9 @@ NO_MISSING_FIELD_INITIALIZERS!$NO_MISSING_FIELD_INITIALIZERS$ac_delim COVERED_SWITCH_DEFAULT!$COVERED_SWITCH_DEFAULT$ac_delim USE_UDIS86!$USE_UDIS86$ac_delim USE_OPROFILE!$USE_OPROFILE$ac_delim +USE_INTEL_JITEVENTS!$USE_INTEL_JITEVENTS$ac_delim +INTEL_JITEVENTS_INCDIR!$INTEL_JITEVENTS_INCDIR$ac_delim +INTEL_JITEVENTS_LIBDIR!$INTEL_JITEVENTS_LIBDIR$ac_delim HAVE_PTHREAD!$HAVE_PTHREAD$ac_delim HUGE_VAL_SANITY!$HUGE_VAL_SANITY$ac_delim MMAP_FILE!$MMAP_FILE$ac_delim @@ -21938,7 +22275,7 @@ LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 90; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 93; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -- cgit v1.2.3