The SSAUpdater is already implemented as a template so that we can reuse it for both IR-level and Machine-level updates. This simple change adds a new PhiItT typedef to the traits so that it can also be used for Swift's SIL representation, where phis are separate from other instructions.
The interface is somehow lying: PhiItT_end is not the end of the PHIs list.
Could you add a unit test (with comments describing the use case) so this
isn't accidentally broken later?
Would it be possible to refactor the begin/end as ADL begin/end so they'd
work with range-based for? (Or I guess that doesn't work - iteration over
the basic block's phis is a separate range from iterating over the basic
block's instructions? (so there's no authoritative begin/end to provide))
Perhaps it could be refactored as a range type/functor/function instead?
(not sure if that's better)
At least it wouldn't be a lie :)
I wonder if it would be useful to have real Phi iterator in LLVM though?
I don't see a reasonable way to write a unit test without either creating a stub IR or making the typedef typename Traits::PhiItT public and then just testing the presence.
I think swift users will notice when this breaks and complain.
Chandler came up with a much better solution for phi iterators in r303964.
I have proposed a similar change for machine-level IR in https://reviews.llvm.org/D41672
Abandoning this one.