summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/FunctionInfo.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-03-11 18:52:24 +0000
committerTeresa Johnson <tejohnson@google.com>2016-03-11 18:52:24 +0000
commit76a1c1d0ba05993f3e57f935698ec0fd09b66c8c (patch)
treee89825099cc401c2546bbfa7e0ac83c2e1d98644 /llvm/lib/IR/FunctionInfo.cpp
parentc134810cfb91716554177992c4bbbf2543545a1a (diff)
downloadbcm5719-llvm-76a1c1d0ba05993f3e57f935698ec0fd09b66c8c.tar.gz
bcm5719-llvm-76a1c1d0ba05993f3e57f935698ec0fd09b66c8c.zip
[ThinLTO] Support for reference graph in per-module and combined summary.
Summary: This patch adds support for including a full reference graph including call graph edges and other GV references in the summary. The reference graph edges can be used to make importing decisions without materializing any source modules, can be used in the plugin to make file staging decisions for distributed build systems, and is expected to have other uses. The call graph edges are recorded in each function summary in the bitcode via a list of <CalleeValueIds, StaticCount> tuples when no PGO data exists, or <CalleeValueId, StaticCount, ProfileCount> pairs when there is PGO, where the ValueId can be mapped to the function GUID via the ValueSymbolTable. In the function index in memory, the call graph edges reference the target via the CalleeGUID instead of the CalleeValueId. The reference graph edges are recorded in each summary record with a list of referenced value IDs, which can be mapped to value GUID via the ValueSymbolTable. Addtionally, a new summary record type is added to record references from global variable initializers. A number of bitcode records and data structures have been renamed to reflect the newly expanded scope of the summary beyond functions. More cleanup will follow. Reviewers: joker.eph, davidxl Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D17212 llvm-svn: 263275
Diffstat (limited to 'llvm/lib/IR/FunctionInfo.cpp')
-rw-r--r--llvm/lib/IR/FunctionInfo.cpp45
1 files changed, 28 insertions, 17 deletions
diff --git a/llvm/lib/IR/FunctionInfo.cpp b/llvm/lib/IR/FunctionInfo.cpp
index 246023907f9..e9a598d1435 100644
--- a/llvm/lib/IR/FunctionInfo.cpp
+++ b/llvm/lib/IR/FunctionInfo.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the function info index and summary classes for the
+// This file implements the module index and summary classes for the
// IR library.
//
//===----------------------------------------------------------------------===//
@@ -16,42 +16,53 @@
#include "llvm/ADT/StringMap.h"
using namespace llvm;
-// Create the combined function index/summary from multiple
+// Create the combined module index/summary from multiple
// per-module instances.
void FunctionInfoIndex::mergeFrom(std::unique_ptr<FunctionInfoIndex> Other,
uint64_t NextModuleId) {
StringRef ModPath;
- for (auto &OtherFuncInfoLists : *Other) {
- uint64_t FuncGUID = OtherFuncInfoLists.first;
- FunctionInfoList &List = OtherFuncInfoLists.second;
+ for (auto &OtherGlobalValInfoLists : *Other) {
+ uint64_t ValueGUID = OtherGlobalValInfoLists.first;
+ GlobalValueInfoList &List = OtherGlobalValInfoLists.second;
- // Assert that the func info list only has one entry, since we shouldn't
+ // Assert that the value info list only has one entry, since we shouldn't
// have duplicate names within a single per-module index.
assert(List.size() == 1);
- std::unique_ptr<FunctionInfo> Info = std::move(List.front());
+ std::unique_ptr<GlobalValueInfo> Info = std::move(List.front());
- // Skip if there was no function summary section.
- if (!Info->functionSummary())
+ // Skip if there was no summary section.
+ if (!Info->summary())
continue;
// Add the module path string ref for this module if we haven't already
// saved a reference to it.
if (ModPath.empty())
- ModPath =
- addModulePath(Info->functionSummary()->modulePath(), NextModuleId);
+ ModPath = addModulePath(Info->summary()->modulePath(), NextModuleId);
else
- assert(ModPath == Info->functionSummary()->modulePath() &&
+ assert(ModPath == Info->summary()->modulePath() &&
"Each module in the combined map should have a unique ID");
// Note the module path string ref was copied above and is still owned by
// the original per-module index. Reset it to the new module path
// string reference owned by the combined index.
- Info->functionSummary()->setModulePath(ModPath);
+ Info->summary()->setModulePath(ModPath);
- // Add new function info to existing list. There may be duplicates when
- // combining FunctionMap entries, due to COMDAT functions. Any local
- // functions were given unique global IDs.
- addFunctionInfo(FuncGUID, std::move(Info));
+ // Add new value info to existing list. There may be duplicates when
+ // combining GlobalValueMap entries, due to COMDAT values. Any local
+ // values were given unique global IDs.
+ addGlobalValueInfo(ValueGUID, std::move(Info));
+ }
+}
+
+void FunctionInfoIndex::removeEmptySummaryEntries() {
+ for (auto MI = begin(), MIE = end(); MI != MIE;) {
+ // Only expect this to be called on a per-module index, which has a single
+ // entry per value entry list.
+ assert(MI->second.size() == 1);
+ if (!MI->second[0]->summary())
+ MI = GlobalValueMap.erase(MI);
+ else
+ ++MI;
}
}
OpenPOWER on IntegriCloud