Clang produces incorrect Thumb2 assembler when using alloca.

Don't define EIGEN_ALLOCA when generating Thumb with clang.
This commit is contained in:
Rasmus Munk Larsen 2018-07-13 11:03:04 -07:00
parent 20991c3203
commit 02a9443db9

View File

@ -588,6 +588,15 @@ template<typename T> struct smart_memmove_helper<T,false> {
#endif
#endif
// With clang -Oz -mthumb, alloca changes the stack pointer in a way that is
// not allowed in Thumb2. -DEIGEN_STACK_ALLOCATION_LIMIT=0 doesn't work because
// the compiler still emits bad code because stack allocation checks use "<=".
// TODO: Eliminate after https://bugs.llvm.org/show_bug.cgi?id=23772
// is fixed.
#if defined(__clang__) && defined(__ANDROID__) && defined(__thumb__)
#undef EIGEN_ALLOCA
#endif
// This helper class construct the allocated memory, and takes care of destructing and freeing the handled data
// at destruction time. In practice this helper class is mainly useful to avoid memory leak in case of exceptions.
template<typename T> class aligned_stack_memory_handler : noncopyable