Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: https://github.com/tigerbeetle/tigerbeetle/blob/ee67e2ab95ed7ccf909be377dc613869738d48b4/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
- Loading branch information