From 3e3d21164b66d8c9f04aac4326c6fd7d23b2ed98 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 17 Jun 2024 12:40:36 -0700 Subject: [PATCH] [optimization] Add support for `[[clang:always_inline]]` and similar attributes (#36948) We can demonstrably do a better job than compiler heuristics for large chunks of call-v3, so give ourselves that lever. Closes #36948 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36948 from ctiller:always-inline 315c77a272aa5ca8183163b6550d7f372c12dcd7 PiperOrigin-RevId: 644101013 --- include/grpc/support/port_platform.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index e261bb12421..04751ae8273 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -746,6 +746,17 @@ extern void gpr_unreachable_code(const char* reason, const char* file, #endif #endif /* GPR_ATTRIBUTE_NOINLINE */ +#ifndef GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION +#if GPR_HAS_CPP_ATTRIBUTE(clang::always_inline) +#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION [[clang::always_inline]] +#elif GPR_HAS_ATTRIBUTE(always_inline) +#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION __attribute__((always_inline)) +#else +// TODO(ctiller): add __forceinline for MSVC +#define GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION +#endif +#endif /* GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION */ + #ifndef GPR_NO_UNIQUE_ADDRESS #if GPR_HAS_CPP_ATTRIBUTE(no_unique_address) #define GPR_NO_UNIQUE_ADDRESS [[no_unique_address]]