<div dir="ltr">Today, the IR requires that if you have multiple edges from A to B (typically with a switch) any phi nodes in B must have an equal number of entries for A, but that all of them must have the same value.<div><br></div><div>This seems rather annoying....</div><div>1) It creates multiple uses of values in A for no apparently good reason</div><div>2) It makes updating PHI nodes using sets of predecessors incredibly hard</div><div>3) There is no correspondence between the edges and the PHI node entries other than number, making most of the code that does handle this very ad-hoc "count off N repetitions of the same thing" style code, which is brittle and hard to test effectively.</div><div>4) I suspect bugs are quite common given that PHINode::removeIncomingValue accepts a basic block but only removes the first incoming value, leaving the others in place.</div><div><br></div><div>I can't see any serious use case for this symmetry either. These aren't uses (and can't be), and there doesn't seem to be any lost functionality if we only have a single entry.</div><div><br></div><div>It also seems likely to open up more efficient in-memory representations if it is possible at some point to build maps of these things.</div><div><br></div><div>Thoughts? It appears entirely possible to change the verifier to check that we don't have duplicates, and to read bitcode with duplicates and merge them so that there is no backwards compatibility issue.</div><div><br></div><div>-Chandler</div></div>