From 97c1876256570b45cc2c789755132d6e384173aa Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Thu, 11 Oct 2012 22:28:34 +0000 Subject: 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 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index af8d1128523..5f8953abc07 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)); -- cgit v1.2.3