mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-20 11:26:35 +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:
@@ -103,6 +103,33 @@ MCFunction *MCModule::createFunction(StringRef Name) {
|
||||
return Functions.back();
|
||||
}
|
||||
|
||||
static bool CompBBToAtom(MCBasicBlock *BB, const MCTextAtom *Atom) {
|
||||
return BB->getInsts() < Atom;
|
||||
}
|
||||
|
||||
void MCModule::splitBasicBlocksForAtom(const MCTextAtom *TA,
|
||||
const MCTextAtom *NewTA) {
|
||||
BBsByAtomTy::iterator
|
||||
I = std::lower_bound(BBsByAtom.begin(), BBsByAtom.end(),
|
||||
TA, CompBBToAtom);
|
||||
for (; I != BBsByAtom.end() && (*I)->getInsts() == TA; ++I) {
|
||||
MCBasicBlock *BB = *I;
|
||||
MCBasicBlock *NewBB = &BB->getParent()->createBlock(*NewTA);
|
||||
BB->splitBasicBlock(NewBB);
|
||||
}
|
||||
}
|
||||
|
||||
void MCModule::trackBBForAtom(const MCTextAtom *Atom, MCBasicBlock *BB) {
|
||||
assert(Atom == BB->getInsts() && "Text atom doesn't back the basic block!");
|
||||
BBsByAtomTy::iterator I = std::lower_bound(BBsByAtom.begin(),
|
||||
BBsByAtom.end(),
|
||||
Atom, CompBBToAtom);
|
||||
for (; I != BBsByAtom.end() && (*I)->getInsts() == Atom; ++I)
|
||||
if (*I == BB)
|
||||
return;
|
||||
BBsByAtom.insert(I, BB);
|
||||
}
|
||||
|
||||
MCModule::~MCModule() {
|
||||
for (AtomListTy::iterator AI = atom_begin(),
|
||||
AE = atom_end();
|
||||
|
Reference in New Issue
Block a user