diff options
| author | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2013-08-21 07:28:24 +0000 |
|---|---|---|
| committer | Ahmed Bougacha <ahmed.bougacha@gmail.com> | 2013-08-21 07:28:24 +0000 |
| commit | ff12d02d5107f9e10a3879beab3ba91c4da66061 (patch) | |
| tree | 2bfe2e9415ef56d9db8c80989319446463f820b4 /llvm/lib/MC/MCModule.cpp | |
| parent | d3fc5b96481e2f769f1e83ea53c3fafe057f5582 (diff) | |
| download | bcm5719-llvm-ff12d02d5107f9e10a3879beab3ba91c4da66061.tar.gz bcm5719-llvm-ff12d02d5107f9e10a3879beab3ba91c4da66061.zip | |
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.
llvm-svn: 188881
Diffstat (limited to 'llvm/lib/MC/MCModule.cpp')
| -rw-r--r-- | llvm/lib/MC/MCModule.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCModule.cpp b/llvm/lib/MC/MCModule.cpp index bdd5cc6b1cd..7e9e18a5a91 100644 --- a/llvm/lib/MC/MCModule.cpp +++ b/llvm/lib/MC/MCModule.cpp @@ -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(); |

