[SR-12773] cross module construction of an ExpressibleByArrayLiteral thing seems to always heap reify the array #55218
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
performance
Attachment: Download
Additional Detail from JIRA
md5: 97df26e87ca67dd66496b98d58ca76d2
Issue Description:
Consider the following basic
ExpressibleByArrayLiteral
data structure:basically a slightly fancier
OptionSet
. For a nice API, we could make thisExpressibleByArrayLiteral
withProblem
This all works totally fine but calling
public init(arrayLiteral things: FooElement...)
heap allocates (even when inlined) an array. The array doesn't escape so this should worst case stack allocate.So when driving this from an example function
from another module, we get the following code generated:
(CMO also doesn't help).
how to show the allocations
Test project attached, repro is
output is
which shows 1000 allocations from that stack (because I call
XXX_CHECK_XXX
1000 times).more info
This does not reproduce if everything's copied into one module. The code is then
which allocates the array on the stack. That's much better.
test environment
The text was updated successfully, but these errors were encountered: