Prevent duplicate inlining of the vectorized loop in WireFormatLite::VarintSize. `WireFormatLite::VarintSize` compiles into an ~850-byte SSE autovectorized loop (32 elements per iteration) plus a scalar tail. Because the template helper lacked `PROTOBUF_NOINLINE`, Clang inlined it into `Int32Size`, `UInt32Size`, `SInt32Size`, and `EnumSize`, which in turn are force-inlined (`PROTOBUF_ALWAYS_INLINE_CALL`) into their `*WithPackedTagSize` counterparts, emitting 8 copies of the vectorized loop per binary. Mark `VarintSize` `PROTOBUF_NOINLINE` so the outer `value.empty()` fast return and `CachedSize` store remain inlined at call sites while sharing the 3 unique template instantiations of `VarintSize`. PiperOrigin-RevId: 997663319
diff --git a/src/google/protobuf/wire_format_lite.cc b/src/google/protobuf/wire_format_lite.cc index cf81cee..d17ab19 100644 --- a/src/google/protobuf/wire_format_lite.cc +++ b/src/google/protobuf/wire_format_lite.cc
@@ -600,7 +600,7 @@ // this code is deliberately written such that clang makes it into really // efficient SSE code. template <bool ZigZag, bool SignExtended, typename T> -static size_t VarintSize(const T* data, const int n) { +PROTOBUF_NOINLINE static size_t VarintSize(const T* data, const int n) { static_assert(sizeof(T) == 4, "This routine only works for 32 bit integers"); // is_unsigned<T> => !ZigZag static_assert((std::is_unsigned_v<T> ^ ZigZag) || std::is_signed_v<T>,