[IR] Add an iterator and range accessor for the PHI nodes of a basic
authorChandler Carruth <chandlerc@gmail.com>
Fri, 26 May 2017 03:10:00 +0000 (03:10 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Fri, 26 May 2017 03:10:00 +0000 (03:10 +0000)
commit8fa1e3734267a71b8bca39e6d3fa42516a1da924
tree4255c461b4f504e82c37e710611d48ad0fffda6f
parent997a391466504e5d40929b6e8af88a054f44ab3d
[IR] Add an iterator and range accessor for the PHI nodes of a basic
block.

This allows writing much more natural and readable range based for loops
directly over the PHI nodes. It also takes advantage of the same tricks
for terminating the sequence as the hand coded versions.

I've replaced one example of this mostly to showcase the difference and
I've added a unit test to make sure the facilities really work the way
they're intended. I want to use this inside of SimpleLoopUnswitch but it
seems generally nice.

Differential Revision: https://reviews.llvm.org/D33533

llvm-svn: 303964
llvm/include/llvm/IR/BasicBlock.h
llvm/lib/IR/BasicBlock.cpp
llvm/unittests/IR/BasicBlockTest.cpp [new file with mode: 0644]
llvm/unittests/IR/CMakeLists.txt