[swift-dev] SIL proposal: remove multiple results from SILValue
jgroff at apple.com
Fri Dec 4 12:19:50 CST 2015
> On Dec 4, 2015, at 9:06 AM, Erik Eckstein <eeckstein at apple.com> wrote:
> currently some instructions, like alloc_stack and alloc_box (I think they are the only ones) return 2 values. For this we have the "result number" in SILValue, e.g. %3#0, %3#1
> We could represent the same by using a projection instruction, e.g.
> %3 = alloc_stack $Type // == the old %3#0
> %4 = project_stack %1 // == the old %3#1
> And actually we already have the project_box instruction.
> This would simplify SILValues and many places in optimization passes/analysis. Yesterday I spent several hours to debug a problem where in some pass the wrong result number was used.
> What do you think?
Like John said, this would cause us to generate a lot more SIL IR, and potentially more LLVM IR as well, since the projected address is produced as part of the lowering of alloc_stack and alloc_box. Multiple values are handy for things like alloc_stack and alloc_box where both values are immediately used in the common case. Looking forward, I think we'd also like function applications to be able to produce arbitrarily many values at the SIL level, which would save a bunch of tuple imploding and exploding that's currently necessary.
More information about the swift-dev