diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-02-10 18:57:54 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-02-10 18:57:54 +0000 |
commit | 0919a84071e55190643eb6e833a51755692b0d29 (patch) | |
tree | defa683bb416a4a6ee5cb54564e29d96d99dd143 /llvm/lib/Transforms/IPO/FunctionImport.cpp | |
parent | ad7b6f5aeaaf9c8fbaad65f1e3a9e21ddb76d048 (diff) | |
download | bcm5719-llvm-0919a84071e55190643eb6e833a51755692b0d29.tar.gz bcm5719-llvm-0919a84071e55190643eb6e833a51755692b0d29.zip |
[ThinLTO] Use MD5 hash in function index.
Summary:
This patch uses the lower 64-bits of the MD5 hash of a function name as
a GUID in the function index, instead of storing function names. Any
local functions are first given a global name by prepending the original
source file name. This is the same naming scheme and GUID used by PGO in
the indexed profile format.
This change has a couple of benefits. The primary benefit is size
reduction in the combined index file, for example 483.xalancbmk's
combined index file was reduced by around 70%. It should also result in
memory savings for the index file in memory, as the in-memory map is
also indexed by the hash instead of the string.
Second, this enables integration with indirect call promotion, since the
indirect call profile targets are recorded using the same global naming
convention and hash. This will enable the function importer to easily
locate function summaries for indirect call profile targets to enable
their import and subsequent promotion.
The original source file name is recorded in the bitcode in a new
module-level record for use in the ThinLTO backend pipeline.
Reviewers: davidxl, joker.eph
Subscribers: llvm-commits, joker.eph
Differential Revision: http://reviews.llvm.org/D17028
llvm-svn: 260408
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionImport.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index e402f93ec17..a33216d1852 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -126,7 +126,11 @@ static void findExternalCalls(const Module &DestModule, Function &F, if (CalledFunction->hasInternalLinkage()) { ImportedName = Renamed; } - auto It = CalledFunctions.insert(ImportedName); + // Compute the global identifier used in the function index. + auto CalledFunctionGlobalID = Function::getGlobalIdentifier( + CalledFunction->getName(), CalledFunction->getLinkage(), + CalledFunction->getParent()->getSourceFileName()); + auto It = CalledFunctions.insert(CalledFunctionGlobalID); if (!It.second) { // This is a call to a function we already considered, skip. continue; @@ -213,14 +217,12 @@ static void GetImportList(Module &DestModule, GlobalValue *SGV = SrcModule.getNamedValue(CalledFunctionName); if (!SGV) { - // The destination module is referencing function using their renamed name - // when importing a function that was originally local in the source - // module. The source module we have might not have been renamed so we try - // to remove the suffix added during the renaming to recover the original + // The function is referenced by a global identifier, which has the + // source file name prepended for functions that were originally local + // in the source module. Strip any prepended name to recover the original // name in the source module. - std::pair<StringRef, StringRef> Split = - CalledFunctionName.split(".llvm."); - SGV = SrcModule.getNamedValue(Split.first); + std::pair<StringRef, StringRef> Split = CalledFunctionName.split(":"); + SGV = SrcModule.getNamedValue(Split.second); assert(SGV && "Can't find function to import in source module"); } if (!SGV) { |