Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions llvm/include/llvm/IR/BasicBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
const Instruction *getFirstNonPHI() const;
LLVM_DEPRECATED("Use iterators as instruction positions instead",
"getFirstNonPHIIt")
Instruction *getFirstNonPHI() {
return const_cast<Instruction *>(
static_cast<const BasicBlock *>(this)->getFirstNonPHI());
}
Instruction *getFirstNonPHI();

/// Returns an iterator to the first instruction in this block that is not a
/// PHINode instruction.
Expand Down
7 changes: 7 additions & 0 deletions llvm/lib/IR/BasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ const Instruction* BasicBlock::getFirstNonPHI() const {
return nullptr;
}

Instruction *BasicBlock::getFirstNonPHI() {
for (Instruction &I : *this)
if (!isa<PHINode>(I))
return &I;
return nullptr;
}

BasicBlock::const_iterator BasicBlock::getFirstNonPHIIt() const {
for (const Instruction &I : *this) {
if (isa<PHINode>(I))
Expand Down