aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2013-06-25 23:32:10 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2013-06-25 23:32:10 +0000
commitb0f8341b3449623db80f1ac375e2dcfe4b1796e4 (patch)
tree13f4385d0cd793255cba6c8d2f267f44898aee13
parent805e8a01fe3b527edbad914636d55fd61d81e51c (diff)
downloadexternal_llvm-b0f8341b3449623db80f1ac375e2dcfe4b1796e4.zip
external_llvm-b0f8341b3449623db80f1ac375e2dcfe4b1796e4.tar.gz
external_llvm-b0f8341b3449623db80f1ac375e2dcfe4b1796e4.tar.bz2
Merge isReachable into isBackedge.
Prefer using RPO.lookup() instead of RPO[] which can mutate the map. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184891 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/BlockFrequencyImpl.h29
1 files changed, 10 insertions, 19 deletions
diff --git a/include/llvm/Analysis/BlockFrequencyImpl.h b/include/llvm/Analysis/BlockFrequencyImpl.h
index d555e0e..c4c1601 100644
--- a/include/llvm/Analysis/BlockFrequencyImpl.h
+++ b/include/llvm/Analysis/BlockFrequencyImpl.h
@@ -123,7 +123,7 @@ class BlockFrequencyImpl {
rpot_iterator rpot_at(BlockT *BB) {
rpot_iterator I = rpot_begin();
- unsigned idx = RPO[BB];
+ unsigned idx = RPO.lookup(BB);
assert(idx);
std::advance(I, idx - 1);
@@ -131,22 +131,14 @@ class BlockFrequencyImpl {
return I;
}
-
- /// isReachable - Returns if BB block is reachable from the entry.
- ///
- bool isReachable(BlockT *BB) {
- return RPO.count(BB);
- }
-
- /// isBackedge - Return if edge Src -> Dst is a backedge.
+ /// isBackedge - Return if edge Src -> Dst is a reachable backedge.
///
bool isBackedge(BlockT *Src, BlockT *Dst) {
- assert(isReachable(Src));
- assert(isReachable(Dst));
-
- unsigned a = RPO[Src];
- unsigned b = RPO[Dst];
-
+ unsigned a = RPO.lookup(Src);
+ if (!a)
+ return false;
+ unsigned b = RPO.lookup(Dst);
+ assert(b && "Destination block should be reachable");
return a >= b;
}
@@ -196,7 +188,7 @@ class BlockFrequencyImpl {
PI != PE; ++PI) {
BlockT *Pred = *PI;
- if (isReachable(Pred) && isBackedge(Pred, BB)) {
+ if (isBackedge(Pred, BB)) {
isLoopHead = true;
} else if (BlocksInLoop.count(Pred)) {
incBlockFreq(BB, getEdgeFreq(Pred, BB));
@@ -240,7 +232,7 @@ class BlockFrequencyImpl {
PI != PE; ++PI) {
BlockT *Pred = *PI;
assert(Pred);
- if (isReachable(Pred) && isBackedge(Pred, Head)) {
+ if (isBackedge(Pred, Head)) {
uint64_t N = getEdgeFreq(Pred, Head).getFrequency();
uint64_t D = getBlockFreq(Head).getFrequency();
assert(N <= EntryFreq && "Backedge frequency must be <= EntryFreq!");
@@ -292,8 +284,7 @@ class BlockFrequencyImpl {
PI != PE; ++PI) {
BlockT *Pred = *PI;
- if (isReachable(Pred) && isBackedge(Pred, BB)
- && (!LastTail || RPO[Pred] > RPO[LastTail]))
+ if (isBackedge(Pred, BB) && (!LastTail || RPO[Pred] > RPO[LastTail]))
LastTail = Pred;
}