aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-15 20:47:49 +0000
committerChris Lattner <sabre@nondot.org>2010-02-15 20:47:49 +0000
commitc2528024dc03fdf7a2a1510340b8bfb16b54e2ef (patch)
tree46ebaa0c7eee6d2c3f6922081b7414ae3984411b /lib/Transforms/Utils
parentf80681ead6c31677f300779fe356c77e34678396 (diff)
downloadexternal_llvm-c2528024dc03fdf7a2a1510340b8bfb16b54e2ef.zip
external_llvm-c2528024dc03fdf7a2a1510340b8bfb16b54e2ef.tar.gz
external_llvm-c2528024dc03fdf7a2a1510340b8bfb16b54e2ef.tar.bz2
fix PR6305 by handling BlockAddress in a helper function
called by jump threading. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96263 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/Local.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 7e7973a..57ad459 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -490,6 +490,17 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, Pass *P) {
// Splice all the instructions from PredBB to DestBB.
PredBB->getTerminator()->eraseFromParent();
DestBB->getInstList().splice(DestBB->begin(), PredBB->getInstList());
+
+ // Zap anything that took the address of DestBB. Not doing this will give the
+ // address an invalid value.
+ if (DestBB->hasAddressTaken()) {
+ BlockAddress *BA = BlockAddress::get(DestBB);
+ Constant *Replacement =
+ ConstantInt::get(llvm::Type::getInt32Ty(BA->getContext()), 1);
+ BA->replaceAllUsesWith(ConstantExpr::getIntToPtr(Replacement,
+ BA->getType()));
+ BA->destroyConstant();
+ }
// Anything that branched to PredBB now branches to DestBB.
PredBB->replaceAllUsesWith(DestBB);