diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-04-10 06:54:49 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2013-04-10 06:54:49 +0000 |
commit | d03fdfb97c1a693101bfef5800c262237f5d382f (patch) | |
tree | d8331e82ac2367e07461dcefd301fae749024c12 /lib/Analysis | |
parent | 90dd7fd167b6d09e4a7f37e35dcbfdc492546a79 (diff) | |
download | external_llvm-d03fdfb97c1a693101bfef5800c262237f5d382f.zip external_llvm-d03fdfb97c1a693101bfef5800c262237f5d382f.tar.gz external_llvm-d03fdfb97c1a693101bfef5800c262237f5d382f.tar.bz2 |
RegionInfo: Add helpers to replace entry/exit recursively
Contributed by: Star Tan <tanmx_star@yeah.net>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/RegionInfo.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Analysis/RegionInfo.cpp b/lib/Analysis/RegionInfo.cpp index fad5074..81ef650 100644 --- a/lib/Analysis/RegionInfo.cpp +++ b/lib/Analysis/RegionInfo.cpp @@ -79,6 +79,38 @@ void Region::replaceExit(BasicBlock *BB) { exit = BB; } +void Region::replaceEntryRecursive(BasicBlock *NewEntry) { + std::vector<Region *> RegionQueue; + BasicBlock *OldEntry = getEntry(); + + RegionQueue.push_back(this); + while (!RegionQueue.empty()) { + Region *R = RegionQueue.back(); + RegionQueue.pop_back(); + + R->replaceEntry(NewEntry); + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI) + if ((*RI)->getEntry() == OldEntry) + RegionQueue.push_back(*RI); + } +} + +void Region::replaceExitRecursive(BasicBlock *NewExit) { + std::vector<Region *> RegionQueue; + BasicBlock *OldExit = getExit(); + + RegionQueue.push_back(this); + while (!RegionQueue.empty()) { + Region *R = RegionQueue.back(); + RegionQueue.pop_back(); + + R->replaceExit(NewExit); + for (Region::const_iterator RI = R->begin(), RE = R->end(); RI != RE; ++RI) + if ((*RI)->getExit() == OldExit) + RegionQueue.push_back(*RI); + } +} + bool Region::contains(const BasicBlock *B) const { BasicBlock *BB = const_cast<BasicBlock*>(B); |