aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-09-14 19:05:19 +0000
committerManman Ren <mren@apple.com>2012-09-14 19:05:19 +0000
commit796d945d54f9fe9dd55da2bfa23cbcaabcbc6dc1 (patch)
treea4652c5d037183833a87f0a3e9ccc0abd666253b /lib/Transforms/Utils/SimplifyCFG.cpp
parent9eed53379f19f836769a0c4a14042eeb1b587769 (diff)
Try to fix the bots by detecting inconsistant branch-weight metadata.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 2591dbf726..551df00a1d 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -830,18 +830,24 @@ bool SimplifyCFGOpt::FoldValueComparisonIntoPredecessors(TerminatorInst *TI,
bool PredHasWeights = HasBranchWeights(PTI);
bool SuccHasWeights = HasBranchWeights(TI);
- if (PredHasWeights)
+ if (PredHasWeights) {
GetBranchWeights(PTI, Weights);
- else if (SuccHasWeights)
+ // branch-weight metadata is inconsistant here.
+ if (Weights.size() != 1 + PredCases.size())
+ PredHasWeights = SuccHasWeights = false;
+ } else if (SuccHasWeights)
// If there are no predecessor weights but there are successor weights,
// populate Weights with 1, which will later be scaled to the sum of
// successor's weights
Weights.assign(1 + PredCases.size(), 1);
SmallVector<uint64_t, 8> SuccWeights;
- if (SuccHasWeights)
+ if (SuccHasWeights) {
GetBranchWeights(TI, SuccWeights);
- else if (PredHasWeights)
+ // branch-weight metadata is inconsistant here.
+ if (SuccWeights.size() != 1 + BBCases.size())
+ PredHasWeights = SuccHasWeights = false;
+ } else if (PredHasWeights)
SuccWeights.assign(1 + BBCases.size(), 1);
if (PredDefault == BB) {