summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2019-05-05 18:59:45 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2019-05-05 18:59:45 +0000
commit02569408efe0f30ce8ca6f1210e015162f880056 (patch)
tree563f1bbce262893caee49876d5a27150144e36a4 /llvm/lib
parent1a1b92217787842d06a1d9d68529763a11338a47 (diff)
downloadbcm5719-llvm-02569408efe0f30ce8ca6f1210e015162f880056.tar.gz
bcm5719-llvm-02569408efe0f30ce8ca6f1210e015162f880056.zip
[NFC] BasicBlock: generalize replaceSuccessorsPhiUsesWith(), take Old bb
Thus it does not assume that the old basic block is the basic block for which we are looking at successors. Not reviewed, but seems rather trivial, in line with the rest of previous few patches. llvm-svn: 359997
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/BasicBlock.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index b3980cf9c31..34410712645 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -425,11 +425,9 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
// Now we must loop through all of the successors of the New block (which
// _were_ the successors of the 'this' block), and update any PHI nodes in
// successors. If there were PHI nodes in the successors, then they need to
- // know that incoming branches will be from New, not from Old.
+ // know that incoming branches will be from New, not from Old (this).
//
- llvm::for_each(successors(New), [this, New](BasicBlock *Succ) {
- Succ->replacePhiUsesWith(this, New);
- });
+ New->replaceSuccessorsPhiUsesWith(this, New);
return New;
}
@@ -444,17 +442,22 @@ void BasicBlock::replacePhiUsesWith(BasicBlock *Old, BasicBlock *New) {
}
}
-void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) {
+void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *Old,
+ BasicBlock *New) {
Instruction *TI = getTerminator();
if (!TI)
// Cope with being called on a BasicBlock that doesn't have a terminator
// yet. Clang's CodeGenFunction::EmitReturnBlock() likes to do this.
return;
- llvm::for_each(successors(TI), [this, New](BasicBlock *Succ) {
- Succ->replacePhiUsesWith(this, New);
+ llvm::for_each(successors(TI), [Old, New](BasicBlock *Succ) {
+ Succ->replacePhiUsesWith(Old, New);
});
}
+void BasicBlock::replaceSuccessorsPhiUsesWith(BasicBlock *New) {
+ this->replaceSuccessorsPhiUsesWith(this, New);
+}
+
/// Return true if this basic block is a landing pad. I.e., it's
/// the destination of the 'unwind' edge of an invoke instruction.
bool BasicBlock::isLandingPad() const {
OpenPOWER on IntegriCloud