mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
MC CFG: Split MCBasicBlocks to mirror atom splitting.
When an MCTextAtom is split, all MCBasicBlocks backed by it are automatically split, with a fallthrough between both blocks, and the successors moved to the second block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188881 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -46,8 +46,9 @@ MCBasicBlock *MCFunction::find(uint64_t StartAddr) {
|
||||
// MCBasicBlock
|
||||
|
||||
MCBasicBlock::MCBasicBlock(const MCTextAtom &Insts, MCFunction *Parent)
|
||||
: Insts(&Insts), Parent(Parent)
|
||||
{}
|
||||
: Insts(&Insts), Parent(Parent) {
|
||||
getParent()->getParent()->trackBBForAtom(&Insts, this);
|
||||
}
|
||||
|
||||
void MCBasicBlock::addSuccessor(const MCBasicBlock *MCBB) {
|
||||
if (!isSuccessor(MCBB))
|
||||
@ -68,3 +69,14 @@ bool MCBasicBlock::isPredecessor(const MCBasicBlock *MCBB) const {
|
||||
return std::find(Predecessors.begin(), Predecessors.end(),
|
||||
MCBB) != Predecessors.end();
|
||||
}
|
||||
|
||||
void MCBasicBlock::splitBasicBlock(MCBasicBlock *SplitBB) {
|
||||
assert(Insts->getEndAddr() + 1 == SplitBB->Insts->getBeginAddr() &&
|
||||
"Splitting unrelated basic blocks!");
|
||||
SplitBB->addPredecessor(this);
|
||||
assert(SplitBB->Successors.empty() &&
|
||||
"Split basic block shouldn't already have successors!");
|
||||
SplitBB->Successors = Successors;
|
||||
Successors.clear();
|
||||
addSuccessor(SplitBB);
|
||||
}
|
||||
|
Reference in New Issue
Block a user