# HG changeset patch # User Stefan Mahr # Date 1399768113 -7200 # Node ID 4a4edf0f2077451bdb7cb65fa13e9f58ee3fb84b # Parent 3af93835be561c80e2b454164e1ade921f97e87d fix LLVM 3.4 build (bug #41061) * configure.ac: Call new functions OCTAVE_LLVM_RAW_FD_OSTREAM_API and OCTAVE_LLVM_LEGACY_PASSMANAGER_API, check for Verifier.h header file * m4/acinclude.m4 (OCTAVE_LLVM_RAW_FD_OSTREAM_API): New function to detect correct raw_fd_ostream API * m4/acinclude.m4 (OCTAVE_LLVM_LEGACY_PASSMANAGER_API): New function to detect legacy passmanager API * libinterp/corefcn/jit-util.h: Use legacy passmanager namespace if necessary * libinterp/corefcn/pt-jit.h (class tree_jit): Use legacy passmanager class if necessary * libinterp/corefcn/pt-jit.cc: Include appropriate header files * libinterp/corefcn/pt-jit.cc (tree_jit::initialize): Use legacy passmanager if necessary * libinterp/corefcn/pt-jit.cc (tree_jit::optimize): Use correct API * libinterp/corefcn/jit-typeinfo.cc: Include appropriate header file diff -r 3af93835be56 -r 4a4edf0f2077 configure.ac --- a/configure.ac Sun Mar 16 23:33:49 2014 +0100 +++ b/configure.ac Sun May 11 02:28:33 2014 +0200 @@ -857,9 +857,13 @@ warn_llvm="Missing LLVM file TargetData.h. JIT compiler is disabled." fi + AC_CHECK_HEADERS([llvm/IR/Verifier.h]) + OCTAVE_LLVM_FUNCTION_ADDATTRIBUTE_API OCTAVE_LLVM_FUNCTION_ADDFNATTR_API OCTAVE_LLVM_CALLINST_ADDATTRIBUTE_API + OCTAVE_LLVM_RAW_FD_OSTREAM_API + OCTAVE_LLVM_LEGACY_PASSMANAGER_API AC_LANG_POP(C++) CPPFLAGS="$save_CPPFLAGS" CXXFLAGS="$save_CXXFLAGS" diff -r 3af93835be56 -r 4a4edf0f2077 libinterp/corefcn/jit-typeinfo.cc --- a/libinterp/corefcn/jit-typeinfo.cc Sun Mar 16 23:33:49 2014 +0100 +++ b/libinterp/corefcn/jit-typeinfo.cc Sun May 11 02:28:33 2014 +0200 @@ -34,7 +34,12 @@ #include "jit-typeinfo.h" +#ifdef HAVE_LLVM_IR_VERIFIER_H +#include +#else #include +#endif + #include #ifdef HAVE_LLVM_IR_FUNCTION_H diff -r 3af93835be56 -r 4a4edf0f2077 libinterp/corefcn/jit-util.h --- a/libinterp/corefcn/jit-util.h Sun Mar 16 23:33:49 2014 +0100 +++ b/libinterp/corefcn/jit-util.h Sun May 11 02:28:33 2014 +0200 @@ -42,8 +42,15 @@ { class Value; class Module; +#ifdef LEGACY_PASSMANAGER + namespace legacy { + class FunctionPassManager; + class PassManager; + } +#else class FunctionPassManager; class PassManager; +#endif class ExecutionEngine; class Function; class BasicBlock; diff -r 3af93835be56 -r 4a4edf0f2077 libinterp/corefcn/pt-jit.cc --- a/libinterp/corefcn/pt-jit.cc Sun Mar 16 23:33:49 2014 +0100 +++ b/libinterp/corefcn/pt-jit.cc Sun May 11 02:28:33 2014 +0200 @@ -50,11 +50,22 @@ #include #include + +#ifdef HAVE_LLVM_IR_VERIFIER_H +#include +#else #include +#endif + #include #include #include + +#ifdef LEGACY_PASSMANAGER +#include +#else #include +#endif #ifdef HAVE_LLVM_IR_FUNCTION_H #include @@ -2053,10 +2064,15 @@ if (! engine) return false; +#ifdef LEGACY_PASSMANAGER + module_pass_manager = new llvm::legacy::PassManager (); + pass_manager = new llvm::legacy::FunctionPassManager (module); +#else module_pass_manager = new llvm::PassManager (); + pass_manager = new llvm::FunctionPassManager (module); +#endif module_pass_manager->add (llvm::createAlwaysInlinerPass ()); - pass_manager = new llvm::FunctionPassManager (module); #ifdef HAVE_LLVM_DATALAYOUT pass_manager->add (new llvm::DataLayout (*engine->getDataLayout ())); #else @@ -2171,8 +2187,13 @@ if (Vdebug_jit) { std::string error; +#ifdef RAW_FD_OSTREAM_ARG_IS_LLVM_SYS_FS + llvm::raw_fd_ostream fout ("test.bc", error, + llvm::sys::fs::F_Binary); +#else llvm::raw_fd_ostream fout ("test.bc", error, llvm::raw_fd_ostream::F_Binary); +#endif llvm::WriteBitcodeToFile (module, fout); } } diff -r 3af93835be56 -r 4a4edf0f2077 libinterp/corefcn/pt-jit.h --- a/libinterp/corefcn/pt-jit.h Sun Mar 16 23:33:49 2014 +0100 +++ b/libinterp/corefcn/pt-jit.h Sun May 11 02:28:33 2014 +0200 @@ -386,8 +386,13 @@ size_t trip_count (const octave_value& bounds) const; llvm::Module *module; +#ifdef LEGACY_PASSMANAGER + llvm::legacy::PassManager *module_pass_manager; + llvm::legacy::FunctionPassManager *pass_manager; +#else llvm::PassManager *module_pass_manager; llvm::FunctionPassManager *pass_manager; +#endif llvm::ExecutionEngine *engine; }; diff -r 3af93835be56 -r 4a4edf0f2077 m4/acinclude.m4 --- a/m4/acinclude.m4 Sun Mar 16 23:33:49 2014 +0100 +++ b/m4/acinclude.m4 Sun May 11 02:28:33 2014 +0200 @@ -1744,6 +1744,58 @@ fi ]) dnl +dnl Check for raw_fd_ostream API +dnl +AC_DEFUN([OCTAVE_LLVM_RAW_FD_OSTREAM_API], [ + AC_CACHE_CHECK([check LLVM::raw_fd_ostream arg type is llvm::sys:fs], + [octave_cv_raw_fd_ostream_arg_is_llvm_sys_fs], + [AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include + ]], [[ + std::string str; + llvm::raw_fd_ostream fout ("", str, llvm::sys::fs::F_Binary); + ]])], + octave_cv_raw_fd_ostream_arg_is_llvm_sys_fs=yes, + octave_cv_raw_fd_ostream_arg_is_llvm_sys_fs=no) + AC_LANG_POP(C++) + ]) + if test $octave_cv_raw_fd_ostream_arg_is_llvm_sys_fs = yes; then + AC_DEFINE(RAW_FD_OSTREAM_ARG_IS_LLVM_SYS_FS, 1, + [Define to 1 if LLVM::raw_fd_ostream arg type is llvm::sys:fs.]) + fi +]) +dnl +dnl Check for legacy::PassManager API +dnl +AC_DEFUN([OCTAVE_LLVM_LEGACY_PASSMANAGER_API], [ + AC_CACHE_CHECK([check for LLVM::legacy::PassManager], + [octave_cv_legacy_passmanager], + [AC_LANG_PUSH(C++) + save_LIBS="$LIBS" + LIBS="$LLVM_LIBS $LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[ + #include + ]], [[ + llvm::Module *module; + llvm::legacy::PassManager *module_pass_manager; + llvm::legacy::FunctionPassManager *pass_manager; + module_pass_manager = new llvm::legacy::PassManager (); + pass_manager = new llvm::legacy::FunctionPassManager (module); + ]])], + octave_cv_legacy_passmanager=yes, + octave_cv_legacy_passmanager=no) + LIBS="$save_LIBS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_legacy_passmanager = yes; then + AC_DEFINE(LEGACY_PASSMANAGER, 1, + [Define to 1 if LLVM::legacy::PassManager exists.]) + fi +]) +dnl dnl Check for ar. dnl AC_DEFUN([OCTAVE_PROG_AR], [