diff --git a/include/boost/math/special_functions/detail/erf_inv.hpp b/include/boost/math/special_functions/detail/erf_inv.hpp index 94e36e385..ad6843e2a 100644 --- a/include/boost/math/special_functions/detail/erf_inv.hpp +++ b/include/boost/math/special_functions/detail/erf_inv.hpp @@ -384,7 +384,7 @@ template const typename erf_inv_initializer::init erf_inv_initializer::initializer; template -bool erf_inv_initializer::init::is_value_non_zero(T v) +BOOST_NOINLINE bool erf_inv_initializer::init::is_value_non_zero(T v) { // This needs to be non-inline to detect whether v is non zero at runtime // rather than at compile time, only relevant when running under valgrind diff --git a/include/boost/math/tools/config.hpp b/include/boost/math/tools/config.hpp index 09db298a8..035428c25 100644 --- a/include/boost/math/tools/config.hpp +++ b/include/boost/math/tools/config.hpp @@ -107,6 +107,26 @@ # endif #endif +#if !defined(BOOST_NOINLINE) +# if defined(_MSC_VER) +# define BOOST_NOINLINE __declspec(noinline) +# elif defined(__GNUC__) && __GNUC__ > 3 + // Clang also defines __GNUC__ (as 4) +# if defined(__CUDACC__) + // nvcc doesn't always parse __noinline__, + // see: https://svn.boost.org/trac/boost/ticket/9392 +# define BOOST_NOINLINE __attribute__ ((noinline)) +# elif defined(__HIP__) + // See https://github.com/boostorg/config/issues/392 +# define BOOST_NOINLINE __attribute__ ((noinline)) +# else +# define BOOST_NOINLINE __attribute__ ((__noinline__)) +# endif +# else +# define BOOST_NOINLINE +# endif +#endif + #endif // BOOST_MATH_STANDALONE // Support compilers with P0024R2 implemented without linking TBB