[AutoFDO] Avoid merging inlinee samples multiple times
authorHongtao Yu <hoy@fb.com>
Fri, 31 Jul 2020 01:22:50 +0000 (18:22 -0700)
committerHongtao Yu <hoy@fb.com>
Fri, 31 Jul 2020 16:30:05 +0000 (09:30 -0700)
commitd23c1d6a8dddf0e1b9b9fa64726941e402ede8af
treec8832d056885bb70ea271bb9b08672afdb0f03eb
parentc75c7d51968d397e5521c8b6c1e906bde1245af6
[AutoFDO] Avoid merging inlinee samples multiple times

A function call can be replicated by optimizations like loop unroll and jump threading and the replicates end up sharing the sample nested callee profile. Therefore when it comes to merging samples for uninlined callees in the sample profile inliner, a callee profile can be merged multiple times which will cause an assert to fire.

This change avoids merging same callee profile for duplicate callsites by filtering out callee profiles with a non-zero head sample count.

Reviewed By: wenlei, wmi

Differential Revision: https://reviews.llvm.org/D84997
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/test/Transforms/SampleProfile/inline-mergeprof-dup.ll [new file with mode: 0644]