[SampleFDO] Stop repeated indirect call promotion for the same target.
authorWei Mi <wmi@google.com>
Sat, 13 Feb 2021 03:46:28 +0000 (19:46 -0800)
committerWei Mi <wmi@google.com>
Fri, 19 Feb 2021 01:01:32 +0000 (17:01 -0800)
commit5fb65c02ca5e91e7e1a00e0efdb8edc899f3e4b9
tree40c27599f56076e28804dd723001f88089744ac6
parentd690cbf821f1d4e13bdf97779ffb332624890fcb
[SampleFDO] Stop repeated indirect call promotion for the same target.

Found a problem in indirect call promotion in sample loader pass. Currently
if an indirect call is promoted for a target, and if the parent function is
inlined into some other function, the indirect call can be promoted for the
same target again. That is redundent which can harm performance and can cause
excessive compile time in some extreme case.

The patch fixes the issue. If a target is promoted for an indirect call, the
patch will write ICP metadata with the target call count being set to 0.
In the later ICP in sample profile loader, if it sees a target has 0 count
for an indirect call, it knows the target has been promoted and won't do
indirect call promotion for the indirect call.

The fix brings 0.1~0.2% performance on our search benchmark.

Differential Revision: https://reviews.llvm.org/D96806
llvm/include/llvm/ProfileData/InstrProf.h
llvm/lib/Analysis/IndirectCallPromotionAnalysis.cpp
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/test/Transforms/SampleProfile/Inputs/norepeated-icp.prof [new file with mode: 0644]
llvm/test/Transforms/SampleProfile/indirect-call.ll
llvm/test/Transforms/SampleProfile/norepeated-icp.ll [new file with mode: 0644]