diff options
| author | Justin Bogner <mail@justinbogner.com> | 2013-12-20 08:21:30 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2013-12-20 08:21:30 +0000 |
| commit | 0ba3f211c426dd6ab2ad3f30053b65fe956ae508 (patch) | |
| tree | 7fd6e5e512dfce83fd403520d4e5d601bac8fcf0 /llvm/lib/Transforms | |
| parent | 668eb1f746433bf7686fb5eb98df6ea047a917b5 (diff) | |
| download | bcm5719-llvm-0ba3f211c426dd6ab2ad3f30053b65fe956ae508.tar.gz bcm5719-llvm-0ba3f211c426dd6ab2ad3f30053b65fe956ae508.zip | |
Transforms: Don't create bad weights when eliminating dead cases
If we happen to eliminate every case in a switch that has branch
weights, we currently try to create metadata for the one remaining
branch, triggering an assert. Instead, we need to check that the
metadata we're trying to create is sensible.
llvm-svn: 197791
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index ff50b12cdb3..0a458979615 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3222,7 +3222,7 @@ static bool EliminateDeadSwitchCases(SwitchInst *SI) { Case.getCaseSuccessor()->removePredecessor(SI->getParent()); SI->removeCase(Case); } - if (HasWeight) { + if (HasWeight && Weights.size() >= 2) { SmallVector<uint32_t, 8> MDWeights(Weights.begin(), Weights.end()); SI->setMetadata(LLVMContext::MD_prof, MDBuilder(SI->getParent()->getContext()). |

