]> granicus.if.org Git - llvm/commit
[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)
commita1a0cf0a7b784a2da4244304aa00a74d60159ca8
treed5600ebd21e1ca8f4fb4e276b1cbfaf807a9e412
parent55d0a522c4417e3f83e6e09be238a6518b45e2ed
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303964 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/IR/BasicBlock.h
lib/IR/BasicBlock.cpp
unittests/IR/BasicBlockTest.cpp [new file with mode: 0644]
unittests/IR/CMakeLists.txt