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 | bcb726dc8addb8155a722a43898af872532b317a (patch) | |
tree | 7570f2c60efb598e7facf42218bb0c1d397b4c23 /lib/Transforms | |
parent | 35c913b5b1916e747c86a24997f63e7d5dedf5d3 (diff) | |
download | llvm-bcb726dc8addb8155a722a43898af872532b317a.tar.gz llvm-bcb726dc8addb8155a722a43898af872532b317a.tar.bz2 llvm-bcb726dc8addb8155a722a43898af872532b317a.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index ff50b12cdb..0a45897961 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/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()). |