Using the new SwitchInst handler introduced in D62122 this patch simplifies 3 places of prof branch_weights handling.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Done early return in eliminateDeadSwitchCases as suggested.
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
3632 ↗ | (On Diff #200208) | I think it does not look like a frequently used routine which is worth a separate method. |
LGTM w/two required changes. (If you want to just make the changes, you can submit without further review. )
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
867 ↗ | (On Diff #200411) | SwitchInstProfBranchWeightsWrapper SI(*cast<SwitchInst>(TI)); (i.e. avoid a default init and copy construct) |
879 ↗ | (On Diff #200411) | This HasWeight check doesn't appear to have a corresponding bit of code inside the wrapper class. In particular, this means that the old code handles malformed metadata and the new one does not. I know you want to disallow this case, but for the moment, as a practical migration, please add the bailout inside the wrapper. That would make this change obviously NFC (which it isn't right now.) |
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
879 ↗ | (On Diff #200411) | HasWeight is equivalent to the condition SI.State == Invalid. |
Again, LGTM.
llvm/lib/Transforms/Utils/SimplifyCFG.cpp | ||
---|---|---|
879 ↗ | (On Diff #200411) | Yep, I see it now. I must have been looking at a stale checkout or something when I commented originally. Feel free to ignore this thread. |