aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorYevgeny Rouban <yevgeny.rouban@azul.com>2019-06-17 05:55:12 +0000
committerYevgeny Rouban <yevgeny.rouban@azul.com>2019-06-17 05:55:12 +0000
commitee62c40eae93c180d29e94841fbeb280ee737d26 (patch)
treefdbbcb0883b4bdaabddb64c70309b9f0e8f46c96 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp
parent1d1cf30b738b88a58919221cc419109ba9519a61 (diff)
downloadllvm-ee62c40eae93c180d29e94841fbeb280ee737d26.zip
llvm-ee62c40eae93c180d29e94841fbeb280ee737d26.tar.gz
llvm-ee62c40eae93c180d29e94841fbeb280ee737d26.tar.bz2
[SimplifyCFG] Fix prof branch_weights MD while removing unreachable switch cases
SimplifyCFG has a bug that results in inconsistent prof branch_weights metadata if unreachable switch cases are removed. This patch fixes this bug by making use of the newly introduced SwitchInstProfUpdateWrapper class (see patch D62122). A new test is created. Differential Revision: https://reviews.llvm.org/D62186 llvm-svn: 363527
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index ec574ea..a8d2437 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4218,14 +4218,15 @@ bool SimplifyCFGOpt::SimplifyUnreachable(UnreachableInst *UI) {
}
}
} else if (auto *SI = dyn_cast<SwitchInst>(TI)) {
- for (auto i = SI->case_begin(), e = SI->case_end(); i != e;) {
+ SwitchInstProfUpdateWrapper SU(*SI);
+ for (auto i = SU->case_begin(), e = SU->case_end(); i != e;) {
if (i->getCaseSuccessor() != BB) {
++i;
continue;
}
- BB->removePredecessor(SI->getParent());
- i = SI->removeCase(i);
- e = SI->case_end();
+ BB->removePredecessor(SU->getParent());
+ i = SU.removeCase(i);
+ e = SU->case_end();
Changed = true;
}
} else if (auto *II = dyn_cast<InvokeInst>(TI)) {