mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-07 18:21:58 +00:00

When profiling a no-op incremental link of Chromium I found that the functions computeImportForFunction and computeDeadSymbols were consuming roughly 10% of the profile. The goal of this change is to improve the performance of those functions by changing the map lookups that they were previously doing into pointer dereferences. This is achieved by changing the ValueInfo data structure to be a pointer to an element of the global value map owned by ModuleSummaryIndex, and changing reference lists in the GlobalValueSummary to hold ValueInfos instead of GUIDs. This means that a ValueInfo will take a client directly to the summary list for a given GUID. Differential Revision: https://reviews.llvm.org/D32471 llvm-svn: 302108
59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
//===-- ModuleSummaryIndex.cpp - Module Summary Index ---------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the module index and summary classes for the
|
|
// IR library.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/IR/ModuleSummaryIndex.h"
|
|
#include "llvm/ADT/StringMap.h"
|
|
using namespace llvm;
|
|
|
|
// Collect for the given module the list of function it defines
|
|
// (GUID -> Summary).
|
|
void ModuleSummaryIndex::collectDefinedFunctionsForModule(
|
|
StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const {
|
|
for (auto &GlobalList : *this) {
|
|
auto GUID = GlobalList.first;
|
|
for (auto &GlobSummary : GlobalList.second.SummaryList) {
|
|
auto *Summary = dyn_cast_or_null<FunctionSummary>(GlobSummary.get());
|
|
if (!Summary)
|
|
// Ignore global variable, focus on functions
|
|
continue;
|
|
// Ignore summaries from other modules.
|
|
if (Summary->modulePath() != ModulePath)
|
|
continue;
|
|
GVSummaryMap[GUID] = Summary;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Collect for each module the list of function it defines (GUID -> Summary).
|
|
void ModuleSummaryIndex::collectDefinedGVSummariesPerModule(
|
|
StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries) const {
|
|
for (auto &GlobalList : *this) {
|
|
auto GUID = GlobalList.first;
|
|
for (auto &Summary : GlobalList.second.SummaryList) {
|
|
ModuleToDefinedGVSummaries[Summary->modulePath()][GUID] = Summary.get();
|
|
}
|
|
}
|
|
}
|
|
|
|
GlobalValueSummary *
|
|
ModuleSummaryIndex::getGlobalValueSummary(uint64_t ValueGUID,
|
|
bool PerModuleIndex) const {
|
|
auto VI = getValueInfo(ValueGUID);
|
|
assert(VI && "GlobalValue not found in index");
|
|
assert((!PerModuleIndex || VI.getSummaryList().size() == 1) &&
|
|
"Expected a single entry per global value in per-module index");
|
|
auto &Summary = VI.getSummaryList()[0];
|
|
return Summary.get();
|
|
}
|