llvm/lib/ProfileData
Dehao Chen cd2a5b62d1 SamplePGO ThinLTO ICP fix for local functions.
Summary:
In SamplePGO, if the profile is collected from non-LTO binary, and used to drive ThinLTO, the indirect call promotion may fail because ThinLTO adjusts local function names to avoid conflicts. There are two places of where the mismatch can happen:

1. thin-link prepends SourceFileName to front of FuncName to build the GUID (GlobalValue::getGlobalIdentifier). Unlike instrumentation FDO, SamplePGO does not use the PGOFuncName scheme and therefore the indirect call target profile data contains a hash of the OriginalName.
2. backend compiler promotes some local functions to global and appends .llvm.{$ModuleHash} to the end of the FuncName to derive PromotedFunctionName

This patch tries at the best effort to find the GUID from the original local function name (in profile), and use that in ICP promotion, and in SamplePGO matching that happens in the backend after importing/inlining:

1. in thin-link, it builds the map from OriginalName to GUID so that when thin-link reads in indirect call target profile (represented by OriginalName), it knows which GUID to import.
2. in backend compiler, if sample profile reader cannot find a profile match for PromotedFunctionName, it will try to find if there is a match for OriginalFunctionName.
3. in backend compiler, we build symbol table entry for OriginalFunctionName and pointer to the same symbol of PromotedFunctionName, so that ICP can find the correct target to promote.

Reviewers: mehdi_amini, tejohnson

Reviewed By: tejohnson

Subscribers: llvm-commits, Prazek

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297757 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-14 17:33:01 +00:00
..
Coverage [ProfileData] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-03-03 01:07:34 +00:00
CMakeLists.txt Move ProfileSummary to IR. 2016-05-19 21:07:12 +00:00
InstrProf.cpp SamplePGO ThinLTO ICP fix for local functions. 2017-03-14 17:33:01 +00:00
InstrProfReader.cpp [PGO] Text format profile reader needs to clear the value profile 2017-03-03 21:56:34 +00:00
InstrProfWriter.cpp [ProfileData] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-03-03 01:07:34 +00:00
LLVMBuild.txt Move coverage related code into a separate library. 2016-04-29 18:53:05 +00:00
ProfileSummaryBuilder.cpp NFC Add const 2016-09-30 21:05:55 +00:00
SampleProf.cpp [ProfileData] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-03-03 01:07:34 +00:00
SampleProfReader.cpp [ProfileData] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-03-03 01:07:34 +00:00
SampleProfWriter.cpp [ProfileData] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-03-03 01:07:34 +00:00