aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-10-11 22:28:34 +0000
committerManman Ren <mren@apple.com>2012-10-11 22:28:34 +0000
commit97c1876256570b45cc2c789755132d6e384173aa (patch)
tree4c4278e7a7390bfd7f9797f7c0464e666e8466ca /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent959c71a6854b5776b350d256885b2a81d6da52db (diff)
downloadllvm-97c1876256570b45cc2c789755132d6e384173aa.zip
llvm-97c1876256570b45cc2c789755132d6e384173aa.tar.gz
llvm-97c1876256570b45cc2c789755132d6e384173aa.tar.bz2
PGO: create metadata for switch only if it has more than one targets.
When all cases of a switch statement are dead, the weights vector only has one element, and we will get an ssertion failure when calling createBranchWeights. llvm-svn: 165759
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index af8d112..5f8953ab 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -695,7 +695,7 @@ SimplifyEqualityComparisonWithOnlyPredecessor(TerminatorInst *TI,
SI->removeCase(i);
}
}
- if (HasWeight)
+ if (HasWeight && Weights.size() >= 2)
SI->setMetadata(LLVMContext::MD_prof,
MDBuilder(SI->getParent()->getContext()).
createBranchWeights(Weights));