summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorXin Tong <trent.xin.tong@gmail.com>2018-06-18 22:59:13 +0000
committerXin Tong <trent.xin.tong@gmail.com>2018-06-18 22:59:13 +0000
commitbfd8cfcb8dffbcf3b4ecdb5cad00d07fda4310f9 (patch)
tree4faa2fc4844a48e98aa3cce1ef287f9084f55def /llvm/lib
parentd9c3c1cd9d7bf5e58e4bd1ae15701c921acee3f3 (diff)
downloadbcm5719-llvm-bfd8cfcb8dffbcf3b4ecdb5cad00d07fda4310f9.tar.gz
bcm5719-llvm-bfd8cfcb8dffbcf3b4ecdb5cad00d07fda4310f9.zip
Simplify blockaddress usage before giving up in MergeBlockIntoPredecessor
Summary: Simplify blockaddress usage before giving up in MergeBlockIntoPredecessor This is a missing small optimization in MergeBlockIntoPredecessor. This helps with one simplifycfg test which expects this case to be handled. Reviewers: davide, spatel, brzycki, asbirlea Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48284 llvm-svn: 334992
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Utils/BasicBlockUtils.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
index 59837042550..4b89b0435e0 100644
--- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -119,7 +119,14 @@ bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, DominatorTree *DT,
LoopInfo *LI,
MemoryDependenceResults *MemDep) {
// Don't merge away blocks who have their address taken.
- if (BB->hasAddressTaken()) return false;
+ if (BB->hasAddressTaken()) {
+ // If the block has its address taken, it may be a tree of dead constants
+ // hanging off of it. These shouldn't keep the block alive.
+ BlockAddress *BA = BlockAddress::get(BB);
+ BA->removeDeadConstantUsers();
+ if (!BA->use_empty())
+ return false;
+ }
// Can't merge if there are multiple predecessors, or no predecessors.
BasicBlock *PredBB = BB->getUniquePredecessor();
OpenPOWER on IntegriCloud