diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2019-05-05 18:59:22 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2019-05-05 18:59:22 +0000 |
commit | 7ad5d14f3a2c916277e25737de9ff3f605131d1a (patch) | |
tree | c497b184991fcdbe59583f27ad4847fe614f25f4 /llvm/lib/IR/Instruction.cpp | |
parent | e5be660e25774e4a769be52a9b7817a1917b7ff7 (diff) | |
download | bcm5719-llvm-7ad5d14f3a2c916277e25737de9ff3f605131d1a.tar.gz bcm5719-llvm-7ad5d14f3a2c916277e25737de9ff3f605131d1a.zip |
[NFC] Instruction: introduce replaceSuccessorWith() function, use it
Summary:
There is `Instruction::getNumSuccessors()`, `Instruction::getSuccessor()`
and `Instruction::setSuccessor()`, but no function to replace every
specified `BasicBlock*` successor with some other specified `BasicBlock*`.
I've found one place where it should clearly be used.
Reviewers: chandlerc, craig.topper, spatel, danielcdh
Reviewed By: craig.topper
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61010
llvm-svn: 359994
Diffstat (limited to 'llvm/lib/IR/Instruction.cpp')
-rw-r--r-- | llvm/lib/IR/Instruction.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp index f15bd601727..42a7a1cce7f 100644 --- a/llvm/lib/IR/Instruction.cpp +++ b/llvm/lib/IR/Instruction.cpp @@ -675,6 +675,13 @@ void Instruction::setSuccessor(unsigned idx, BasicBlock *B) { llvm_unreachable("not a terminator"); } +void Instruction::replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB) { + for (unsigned Idx = 0, NumSuccessors = Instruction::getNumSuccessors(); + Idx != NumSuccessors; ++Idx) + if (getSuccessor(Idx) == OldBB) + setSuccessor(Idx, NewBB); +} + Instruction *Instruction::cloneImpl() const { llvm_unreachable("Subclass of Instruction failed to implement cloneImpl"); } |