zig/lib/std/fmt/parse_float
Alex Kladov 772debb03a reduce AstGen.numberLiteral stack usage
At the moment, the LLVM IR we generate for this fn is

define internal fastcc void @AstGen.numberLiteral ...  {
Entry:
  ...
  %16 = alloca %"fmt.parse_float.decimal.Decimal(f128)", align 8
  ...

That `Decimal` is huuuge! It stores

    pub const max_digits =  11564;
    digits: [max_digits]u8,

on the stack.

It comes from `convertSlow` function, which LLVM happily inlined,
despite it being the cold path. Forbid inlining that to not penalize
callers with excessive stack usage.

Backstory: I was looking for needles memcpys in TigerBeetle, and came up
with this copyhound.zig tool for doing just that:

   ee67e2ab95/src/copyhound.zig

Got curious, run it on the Zig's own code base, and looked at some of
the worst offenders.

List of worst offenders:

warning: crypto.kyber_d00.Kyber.SecretKey.decaps: 7776 bytes memcpy
warning: crypto.ff.Modulus.powPublic: 8160 bytes memcpy
warning: AstGen.numberLiteral: 11584 bytes memcpy
warning: crypto.tls.Client.init__anon_133566: 13984 bytes memcpy
warning: http.Client.connectUnproxied: 16896 bytes memcpy
warning: crypto.tls.Client.init__anon_133566: 16904 bytes memcpy
warning: objcopy.ElfFileHelper.tryCompressSection: 32768 bytes memcpy

Note from Andrew: I removed `noinline` from this commit since it should
be enough to set it to be cold.
2023-07-20 12:51:18 -07:00
..
common.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
convert_eisel_lemire.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
convert_fast.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
convert_hex.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
convert_slow.zig reduce AstGen.numberLiteral stack usage 2023-07-20 12:51:18 -07:00
decimal.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
FloatInfo.zig add new float-parser based on eisel-lemire algorithm 2022-05-03 16:46:40 +12:00
FloatStream.zig add new float-parser based on eisel-lemire algorithm 2022-05-03 16:46:40 +12:00
parse.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
parse_float.zig parse_float: Error when a float is attempted to be parsed into an invalid type 2023-05-08 10:42:24 +00:00