mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user