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 SwitchInstProfBranchWeightsWrapper class (see D62122).
A new test is created.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
LGTM w/two required changes.
The second is that the updater itself should check for the right number of metadata nodes and do nothing if already corrupt (as mentioned in another review thread).
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
4217 ↗ | (On Diff #200455) | Naming here is non-idiomatic. Please leave SI for the SwitchInst and use SU or something for the updater class. |
4219 ↗ | (On Diff #200455) | Not related to your change, but there's no reason a switch can't have several cases leading to the same unreachable block. A separate change to handle that would be nice if you wanted. |