mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
Teach SplitBlockPredecessors how to handle landingpad blocks.
Patch by: Igor Laevsky <igor@azulsystems.com> "Currently SplitBlockPredecessors generates incorrect code in case if basic block we are going to split has a landingpad. Also seems like it is fairly common case among it's users to conditionally call either SplitBlockPredecessors or SplitLandingPadPredecessors. Because of this I think it is reasonable to add this condition directly into SplitBlockPredecessors." Differential Revision: http://reviews.llvm.org/D7157 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227390 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -454,11 +454,15 @@ static void UpdatePHINodes(BasicBlock *OrigBB, BasicBlock *NewBB,
|
||||
}
|
||||
}
|
||||
|
||||
/// SplitBlockPredecessors - This method transforms BB by introducing a new
|
||||
/// basic block into the function, and moving some of the predecessors of BB to
|
||||
/// be predecessors of the new block. The new predecessors are indicated by the
|
||||
/// Preds array, which has NumPreds elements in it. The new block is given a
|
||||
/// suffix of 'Suffix'.
|
||||
/// SplitBlockPredecessors - This method introduces at least one new basic block
|
||||
/// into the function and moves some of the predecessors of BB to be
|
||||
/// predecessors of the new block. The new predecessors are indicated by the
|
||||
/// Preds array. The new block is given a suffix of 'Suffix'. Returns new basic
|
||||
/// block to which predecessors from Preds are now pointing.
|
||||
///
|
||||
/// If BB is a landingpad block then additional basicblock might be introduced.
|
||||
/// It will have suffix of 'Suffix'+".split_lp".
|
||||
/// See SplitLandingPadPredecessors for more details on this case.
|
||||
///
|
||||
/// This currently updates the LLVM IR, AliasAnalysis, DominatorTree,
|
||||
/// LoopInfo, and LCCSA but no other analyses. In particular, it does not
|
||||
@ -470,6 +474,17 @@ BasicBlock *llvm::SplitBlockPredecessors(BasicBlock *BB,
|
||||
const char *Suffix, AliasAnalysis *AA,
|
||||
DominatorTree *DT, LoopInfo *LI,
|
||||
bool PreserveLCSSA) {
|
||||
// For the landingpads we need to act a bit differently.
|
||||
// Delegate this work to the SplitLandingPadPredecessors.
|
||||
if (BB->isLandingPad()) {
|
||||
SmallVector<BasicBlock*, 2> NewBBs;
|
||||
std::string NewName = std::string(Suffix) + ".split-lp";
|
||||
|
||||
SplitLandingPadPredecessors(BB, Preds, Suffix, NewName.c_str(),
|
||||
NewBBs, AA, DT, LI, PreserveLCSSA);
|
||||
return NewBBs[0];
|
||||
}
|
||||
|
||||
// Create new basic block, insert right before the original block.
|
||||
BasicBlock *NewBB = BasicBlock::Create(BB->getContext(), BB->getName()+Suffix,
|
||||
BB->getParent(), BB);
|
||||
|
Reference in New Issue
Block a user