[llvm-dev] Branch probabilities for invokes
Artur Pilipenko via llvm-dev
llvm-dev at lists.llvm.org
Thu Jun 28 05:39:14 PDT 2018
To represent branch probabilities we use branch_weight metadata which can be attached to branch, select or switch instruction. It can also be attached to call instruction, but in this case it would mean the invocation counter. Currently we don't have a way to express the branch probability information for invoke instructions, i.e. probabilty of the normal return edge vs unwind edge.
It looks like we only use a hard-coded heuristic that invokes unwind rarely (1024 * 1024 - 1 vs 1). In managed environment we can have a profile for normal and unwind returns and might benefit from this information being expressed in the IR.
However, I'm uncertaion what would be the best way to go about it. Allowing branch_weights on invoke instructions seems natural, but then it clashes with the existing branch_weights on calls which have a different meaning.
The existing branch_weights on calls is somewhat confusing, maybe we should introduce a separate metadata type for counters and use branch_weights only for relative weights as the name suggestes.
More information about the llvm-dev