[PATCH] Add iterator for PHINode value/BB pair
peter_cooper at apple.com
Tue Jul 21 18:55:26 PDT 2015
Hi David, Duncan
This is another iterator which i’d like to use to enable more foreach loops in LLVM.
This time its for returning both the value and basic block from a phi node. Its very common to need both of these together, but currently involves a manual loop to do so.
The code here is similar to generic_gep_type_iterator where i’m wrapping an iterator (in this case 2) and on updates to the iterators I update the ‘Pair’ field. operator* then returns the Pair when requested.
An alternative would be to only update Pair in operator*, but that would require making the field mutable.
I’ve added a single use of this in BasicAliasAnalysis. A grep of the code finds 47 total loops over PN[.,->]getNumIncomingValues(), of which around 40 look eligible to use this.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4407 bytes
Desc: not available
More information about the llvm-commits