llvm-project/llvm/lib/Transforms
Dehao Chen 4a435e0896 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

llvm-svn: 297757
2017-03-14 17:33:01 +00:00
..
Coroutines [coroutines] Add handling for unwind coro.ends 2017-03-07 21:00:54 +00:00
Hello Add auto-exporting of symbols from tools so that plugins work on Windows 2016-05-26 11:16:43 +00:00
IPO SamplePGO ThinLTO ICP fix for local functions. 2017-03-14 17:33:01 +00:00
InstCombine [InstCombine] improve readability; NFCI 2017-03-14 17:27:27 +00:00
Instrumentation Minor format change. nfc. 2017-03-09 19:08:55 +00:00
ObjCARC Remove redundant code. NFC. 2017-02-25 00:59:49 +00:00
Scalar Fix typos in ADCE comments 2017-03-14 10:18:11 +00:00
Utils API gardening: Rename FindAllocaDbgValue to findDbgValue (NFC) 2017-03-13 17:20:47 +00:00
Vectorize [LV] Refactor cross-iteration phi's back-patching; NFC 2017-03-14 13:50:47 +00:00
CMakeLists.txt [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes 2016-07-28 21:04:31 +00:00
LLVMBuild.txt [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes 2016-07-28 21:04:31 +00:00