diff options
author | Chris Lattner <sabre@nondot.org> | 2010-02-15 20:47:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-02-15 20:47:49 +0000 |
commit | 6fbfe5897c7b50fc209ceadf90b77d2de6ac5137 (patch) | |
tree | e24eefd0da36a3c3a21063f0c7af794a550dce33 /llvm/lib/Transforms/Utils/Local.cpp | |
parent | 5e73ff2e3a34a76ddd66b6b7439c77e43e3a0658 (diff) | |
download | bcm5719-llvm-6fbfe5897c7b50fc209ceadf90b77d2de6ac5137.tar.gz bcm5719-llvm-6fbfe5897c7b50fc209ceadf90b77d2de6ac5137.zip |
fix PR6305 by handling BlockAddress in a helper function
called by jump threading.
llvm-svn: 96263
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 7e7973ae0b7..57ad459c8e1 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/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); |