mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
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
This commit is contained in:
@ -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()).
|
||||
|
Reference in New Issue
Block a user