Properly add out-of-module functions to the import list
authorHongtao Yu <hoy@fb.com>
Mon, 11 May 2020 16:38:29 +0000 (09:38 -0700)
committerHongtao Yu <hoy@fb.com>
Mon, 11 May 2020 17:00:14 +0000 (10:00 -0700)
commit47c1f2741fe7d24e02c3f54bcb723994292c54c3
tree642b9daafdaaa50b3e3329aa886eada0718365f9
parentf807d0b4acdb70c5a15919f6e9b02d8b212d1088
Properly add out-of-module functions to the import list

This patch addresses two issues related to adding inline functions to the import list while recursively going through the profiling data.
1. For callsite samples, only add an inlined function to the import list if it's from outside of the module (i.e. only has a declaration inside the module).
2. For body samples, add each target function to the import list if it's from outside of the module (i.e. only has a declaration inside the module). Previously we were using getSubProgram() to check whether it has dbg info, which is inaccurate. This fix properly add imports and could improve the quality of the pass.

Added a few changes to the test to catch these cases.

Differential Revision: https://reviews.llvm.org/D79379
llvm/include/llvm/ProfileData/SampleProf.h
llvm/test/Transforms/SampleProfile/Inputs/function_metadata.compact.afdo
llvm/test/Transforms/SampleProfile/Inputs/function_metadata.prof
llvm/test/Transforms/SampleProfile/function_metadata.ll