[PATCH] D60604: [IR] Improve SwitchInst API to support prof branch_weights

Yevgeny Rouban via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 02:42:10 PDT 2019


yrouban added a comment.

In D60604#1464759 <https://reviews.llvm.org/D60604#1464759>, @reames wrote:

> I think that if we're going to add an API like this, it needs to be uniform across all the terminator instructios.  Having it otherwise is just too confusing.


Philip, as I see in the doc https://llvm.org/docs/BranchWeightMetadata.html#supported-instructions there are only 4 instructions allowed to have prof branch_weights: BranchInst, SwitchInst, IndirectBrInst and CallInst. CallInst is not a terminator instruction.
I'm proposing API changes for SwitchInst only. Very similar changes can be done to IndirectBrInst.
BranchInst and CallInst have fixed num of branch weight params so they do not need the changes in add/remove methods.
If you agree, I will prepare similar changes for all 4 instructions or just 2 (SwitchInst and IndirectBrInst).
The logic behind these changes is the following. I'd like to keep the prof branch_weights metadata to be kept correct through all passes that do not care about metadata and I do not want to change those passes. They add successors without specifying branch weights and remove successors disregarding the metadata consistency. On the other hand passes can explicitly specify the branch weights along with changed successors.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60604/new/

https://reviews.llvm.org/D60604





More information about the llvm-commits mailing list