Files
clang-p2996/llvm/test/Transforms/SampleProfile/Inputs/indirect-call.prof
Wei Mi 154cd6de51 [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
2020-01-15 18:36:06 -08:00

37 lines
698 B
Plaintext

test:63067:0
1: 3345 _Z3barv:1398 _Z3foov:2059
test_inline:3000:0
1: 1000 foo_inline3:1000
1: foo_inline1:3000
11: 3000
1: foo_inline2:4000
19: 4000
test_noinline:3000:0
1: foo_noinline:3000
20: 3000
test_direct:3000:0
1: foo_direct:3000
21: 3000
test_inline_strip:3000:0
1: foo_inline_strip:3000
1: 3000
test_inline_strip_conflict:3000:0
1: foo_inline_strip_conflict:3000
1: 3000
test_norecursive_inline:3000:0
1: test_norecursive_inline:3000
20: 3000
test_noinline_bitcast:3000:0
1: foo_direct_i32:3000
1: 3000
return_arg_caller:3000:0
1: foo_inline1:3000
11: 3000
2: return_arg:3000
1: 3000
branch_prof_valid:4000:0
1: 1000
2: foo_inline3:3000
1: 0
2: 3000