aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-11-01 04:57:33 +0000
committerChris Lattner <sabre@nondot.org>2009-11-01 04:57:33 +0000
commitcab3885bac1d1f297b73a1ea491eeeb870758b27 (patch)
treed3b74b401df67a4290ff795948a1662e2a817b3d /lib/Transforms/Utils
parentb2b693f125e133847bd713d09e6d3894dbabe0cb (diff)
downloadexternal_llvm-cab3885bac1d1f297b73a1ea491eeeb870758b27.zip
external_llvm-cab3885bac1d1f297b73a1ea491eeeb870758b27.tar.gz
external_llvm-cab3885bac1d1f297b73a1ea491eeeb870758b27.tar.bz2
change llvm::MergeBlockIntoPredecessor to not merge two blocks BB1->BB2
when BB2 has its address taken. Since it ends up doing BB2->rauw(BB1), this can cause the address of the entry block to be taken. Since it is generally undesirable to nuke blocks whose address is taken, even when we can, just unconditionally stop this xform. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85708 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index 1f9a203..c728c0b 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -94,10 +94,14 @@ void llvm::DeleteDeadPHIs(BasicBlock *BB) {
/// MergeBlockIntoPredecessor - Attempts to merge a block into its predecessor,
/// if possible. The return value indicates success or failure.
-bool llvm::MergeBlockIntoPredecessor(BasicBlock* BB, Pass* P) {
+bool llvm::MergeBlockIntoPredecessor(BasicBlock *BB, Pass *P) {
pred_iterator PI(pred_begin(BB)), PE(pred_end(BB));
- // Can't merge the entry block.
- if (pred_begin(BB) == pred_end(BB)) return false;
+ // Can't merge the entry block. Don't merge away blocks who have their
+ // address taken: this is a bug if the predecessor block is the entry node
+ // (because we'd end up taking the address of the entry) and undesirable in
+ // any case.
+ if (pred_begin(BB) == pred_end(BB) ||
+ BB->hasAddressTaken()) return false;
BasicBlock *PredBB = *PI++;
for (; PI != PE; ++PI) // Search all predecessors, see if they are all same