Yeah, so this case looks like a phase ordering issue in the Swift compiler. In SIL, since should_be_as_fast
is non-mutating, the function will be modeled as taking self by value as if in a register, and as part of the withUnsafePointer
call a stack buffer is allocated and the value is copied into it. It's only later right before we lower to LLVM IR that we see, due to the size of the RT
struct, it's really passed by reference in the machine calling convention, so we convert the virtual register into a separate memory location, but we don't subsequently coalesce the memory with other temporary allocations that we formed in the original SIL to hold the value.
@Michael_Gottesman Is this something the large loadable types pass could conceivably do? Maybe we could look for alloc_stack
s that are dominated by a definition we're making indirect and initialized to the same value and combine them together.