From 50695d07f83272bc25e02deb1b02310d424f4183 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Fri, 5 Jul 2019 11:39:14 +0100 Subject: [PATCH] Disable an always_inline with GCC in debug mode. Most compilers are happy if you say always-inline but they can't. GCC will complain. Here, we have two mutually recursive functions that are marked as always inline. In an optimised build, one is inlined into the other and then becomes a tail-recursive function that should inline the tail call. Inlining the tail call can be done by simply jumping to the start of the function and so everything is fine. In a debug build, the second transform doesn't happen and so we're left with a call to an always-inline function. --- src/mem/alloc.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/mem/alloc.h b/src/mem/alloc.h index f5f3fe3..94d209d 100644 --- a/src/mem/alloc.h +++ b/src/mem/alloc.h @@ -1366,8 +1366,15 @@ namespace snmalloc large_allocator.dealloc(slab, large_class); } - SNMALLOC_FAST_PATH void - remote_dealloc(RemoteAllocator* target, void* p, sizeclass_t sizeclass) +#if defined(__GNUC__) && !defined(__clang__) && !defined(__OPTIMIZE__) + // Don't force this to be always inlined in debug builds with GCC, because + // it will fail and then raise an error. + inline +#else + SNMALLOC_FAST_PATH +#endif + void + remote_dealloc(RemoteAllocator* target, void* p, sizeclass_t sizeclass) { MEASURE_TIME(remote_dealloc, 4, 16); assert(target->id() != id());