[all-commits] [llvm/llvm-project] 154cd6: [SampleFDO] Fix invalid branch profile generated b...

wmi-11 via All-commits all-commits at lists.llvm.org
Wed Jan 15 18:37:14 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 154cd6de513e1e9ce794ba2d1eae1647c873f812
      https://github.com/llvm/llvm-project/commit/154cd6de513e1e9ce794ba2d1eae1647c873f812
  Author: Wei Mi <wmi at google.com>
  Date:   2020-01-15 (Wed, 15 Jan 2020)

  Changed paths:
    M llvm/include/llvm/ProfileData/SampleProf.h
    M llvm/test/Transforms/SampleProfile/Inputs/indirect-call.compact.afdo
    M llvm/test/Transforms/SampleProfile/Inputs/indirect-call.prof
    M llvm/test/Transforms/SampleProfile/indirect-call.ll
    M llvm/test/Transforms/SampleProfile/inline-callee-update.ll

  Log Message:
  -----------
  [SampleFDO] Fix invalid branch profile generated by indirect call promotion.

Suppose an inline instance has hot total sample count but 0 entry count, and
it is an indirect call target. If the indirect call has no other call target
and inline instance associated with it and it is promoted, currently the
conditional branch generated by indirect call promotion will have invalid
branch profile which is !{!"branch_weights", i32 0, i32 0} -- because the
entry count of the promoted target is 0 and the total entry count of all
targets is also 0. This caused a SEGV in Control Height Reduction and may
cause problem in other passes.

Function entry count of an inline instance is computed by a heuristic --
using either the sample of the starting line or starting inner inline
instance. The patch changes the heuristic a little bit so that when total
sample count is larger than 0, the computed entry count will be at least 1.
Then the new branch profile will be !{!"branch_weights", i32 1, i32 0}.

Differential Revision: https://reviews.llvm.org/D72790




More information about the All-commits mailing list