aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SplitKit.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-15 17:49:52 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-15 17:49:52 +0000
commit28e769cc5469d50715fb241dc2d89cf24ff7a557 (patch)
tree8a2732f5a91ec96d224c8ad4ae69cd60d3bee60c /llvm/lib/CodeGen/SplitKit.cpp
parent4391f34abad97e505bfb8964cdf22575e0a72dbb (diff)
downloadllvm-28e769cc5469d50715fb241dc2d89cf24ff7a557.zip
llvm-28e769cc5469d50715fb241dc2d89cf24ff7a557.tar.gz
llvm-28e769cc5469d50715fb241dc2d89cf24ff7a557.tar.bz2
Detect and enumerate bypass loops.
Bypass loops have the current live range live through, but contain no uses or defs. Splitting around a bypass loop can free registers for other uses inside the loop by spilling the split range. llvm-svn: 121871
Diffstat (limited to 'llvm/lib/CodeGen/SplitKit.cpp')
-rw-r--r--llvm/lib/CodeGen/SplitKit.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SplitKit.cpp b/llvm/lib/CodeGen/SplitKit.cpp
index fd18729..e14251e 100644
--- a/llvm/lib/CodeGen/SplitKit.cpp
+++ b/llvm/lib/CodeGen/SplitKit.cpp
@@ -325,6 +325,36 @@ const MachineLoop *SplitAnalysis::getBestSplitLoop() {
return Best;
}
+/// isBypassLoop - Return true if curli is live through Loop and has no uses
+/// inside the loop. Bypass loops are candidates for splitting because it can
+/// prevent interference inside the loop.
+bool SplitAnalysis::isBypassLoop(const MachineLoop *Loop) {
+ // If curli is live into the loop header and there are no uses in the loop, it
+ // must be live in the entire loop and live on at least one exiting edge.
+ return !usingLoops_.count(Loop) &&
+ lis_.isLiveInToMBB(*curli_, Loop->getHeader());
+}
+
+/// getBypassLoops - Get all the maximal bypass loops. These are the bypass
+/// loops whose parent is not a bypass loop.
+void SplitAnalysis::getBypassLoops(LoopPtrSet &BypassLoops) {
+ SmallVector<MachineLoop*, 8> Todo(loops_.begin(), loops_.end());
+ while (!Todo.empty) {
+ MachineLoop *Loop = Todo.pop_back_val();
+ if (!usingLoops_.count(Loop)) {
+ // This is either a bypass loop or completely irrelevant.
+ if (lis_.isLiveInToMBB(*curli_, Loop->getHeader()))
+ BypassLoops.insert(Loop);
+ // Either way, skip the child loops.
+ continue;
+ }
+
+ // The child loops may be bypass loops.
+ Todo.append(Loop->begin(), Loop->end());
+ }
+}
+
+
//===----------------------------------------------------------------------===//
// LiveIntervalMap
//===----------------------------------------------------------------------===//