OSDN Git Service

Extend InvokeInst !prof branch_weights metadata to unwind branches
authorYevgeny Rouban <yrouban@azul.com>
Thu, 4 Jun 2020 08:34:14 +0000 (15:34 +0700)
committerYevgeny Rouban <yrouban@azul.com>
Thu, 4 Jun 2020 08:37:15 +0000 (15:37 +0700)
commitdcfa78a4ccec9772d9ff7fea536f81717cf30b24
treec173f15bc333238cf81218129df7c6f990a3d1f1
parent2ebe30c6e4ab1d65fc8605051eb528fc26ffc621
Extend InvokeInst !prof branch_weights metadata to unwind branches

Allow InvokeInst to have the second optional prof branch weight for
its unwind branch. InvokeInst is a terminator with two successors.
It might have its unwind branch taken many times. If so
the BranchProbabilityInfo unwind branch heuristic can be inaccurate.
This patch allows a higher accuracy calculated with both branch
weights set.

Changes:
 - A new section about InvokeInst is added to
   the BranchWeightMetadata page. It states the old information that
   missed in the doc and adds new about the second branch weight.
 - Verifier is changed to allow either 1 or 2 branch weights
   for InvokeInst.
 - A new test is written for BranchProbabilityInfo to demonstrate
   the main improvement of the simple fix in calcMetadataWeights().
 - Several new testcases are created for Inliner. Those check that
    both weights are accounted for invoke instruction weight
    calculation.
 - PGOUseFunc::setBranchWeights() is fixed to be applicable to
   InvokeInst.

Reviewers: davidxl, reames, xur, yamauchi
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D80618
llvm/docs/BranchWeightMetadata.rst
llvm/lib/Analysis/BranchProbabilityInfo.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Analysis/BranchProbabilityInfo/basic.ll
llvm/test/Transforms/Inline/inline-hot-callsite.ll