SSA CFG: introduce projections for functions with multiple return values#16668
SSA CFG: introduce projections for functions with multiple return values#16668
Conversation
blishko
left a comment
There was a problem hiding this comment.
Looks good!
I have a few small comments.
| yulAssert(projectionInst.inputs.size() == 1); | ||
| InstId const producer = projectionInst.inputs.front(); | ||
| yulAssert(_id.value > producer.value); | ||
| std::size_t const offset = static_cast<std::size_t>(_id.value) - static_cast<std::size_t>(producer.value) - 1; |
There was a problem hiding this comment.
Is this assuming that the projections have ids immediately following the id of the function call instruction?
There was a problem hiding this comment.
Yeah exactly. I have elevated that to be an invariant of the SSA CFG. It's not like we can swap around projections and/or only extract a couple things anyways due to the stack nature of things. See here:
solidity/libyul/backends/evm/ssa/SSACFG.h
Lines 217 to 230 in 07053f4
There was a problem hiding this comment.
Hopefully. I guess it would be good to check this invariant somewhere.
We should eventually have something like a pass to check that the IR is well-formed, right?
blishko
left a comment
There was a problem hiding this comment.
LGTM!
I would like to have one more helper :)
ValueId = (InstId, outputPos)in favor of plainInstIdsInstfor the operation itselfInsts as they have outputsInstIdas value handle