[PATCH] D41418: IR: Fix BasicBlock::phis for empty blocks

Daniel Berlin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 28 18:26:38 PST 2017


dberlin accepted this revision.
dberlin added inline comments.
This revision is now accepted and ready to land.


================
Comment at: lib/IR/BasicBlock.cpp:267
 iterator_range<BasicBlock::phi_iterator> BasicBlock::phis() {
-  return make_range<phi_iterator>(dyn_cast<PHINode>(&front()), nullptr);
+  PHINode *P = nullptr;
+  auto I = begin();
----------------
I would just use 

```
// PHINodes, if they exist, come first in the block
PHINode *P = empty() ? nullptr : dyn_cast<PHINode>(&*begin())

```


https://reviews.llvm.org/D41418





More information about the llvm-commits mailing list