[ThinLTO] Renaming of function index to module summary index (NFC)
(Resubmitting after fixing missing file issue)
With the changes in r263275, there are now more than just functions in
the summary. Completed the renaming of data structures (started in
r263275) to reflect the wider scope. In particular, changed the
FunctionIndex* data structures to ModuleIndex*, and renamed related
variables and comments. Also renamed the files to reflect the changes.
A companion clang patch will immediately succeed this patch to reflect
this renaming.
llvm-svn: 263513
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index fb283ad..369e2fb 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -31,7 +31,7 @@
#include "llvm/IR/Verifier.h"
#include "llvm/Linker/IRMover.h"
#include "llvm/MC/SubtargetFeature.h"
-#include "llvm/Object/FunctionIndexObjectFile.h"
+#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/ManagedStatic.h"
@@ -624,8 +624,8 @@
return View;
}
-static std::unique_ptr<FunctionInfoIndex>
-getFunctionIndexForFile(claimed_file &F, ld_plugin_input_file &Info) {
+static std::unique_ptr<ModuleSummaryIndex>
+getModuleSummaryIndexForFile(claimed_file &F, ld_plugin_input_file &Info) {
const void *View = getSymbolsAndView(F);
if (!View)
return nullptr;
@@ -635,18 +635,20 @@
// Don't bother trying to build an index if there is no summary information
// in this bitcode file.
- if (!object::FunctionIndexObjectFile::hasGlobalValueSummaryInMemBuffer(
+ if (!object::ModuleSummaryIndexObjectFile::hasGlobalValueSummaryInMemBuffer(
BufferRef, diagnosticHandler))
- return std::unique_ptr<FunctionInfoIndex>(nullptr);
+ return std::unique_ptr<ModuleSummaryIndex>(nullptr);
- ErrorOr<std::unique_ptr<object::FunctionIndexObjectFile>> ObjOrErr =
- object::FunctionIndexObjectFile::create(BufferRef, diagnosticHandler);
+ ErrorOr<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
+ object::ModuleSummaryIndexObjectFile::create(BufferRef,
+ diagnosticHandler);
if (std::error_code EC = ObjOrErr.getError())
- message(LDPL_FATAL, "Could not read function index bitcode from file : %s",
+ message(LDPL_FATAL,
+ "Could not read module summary index bitcode from file : %s",
EC.message().c_str());
- object::FunctionIndexObjectFile &Obj = **ObjOrErr;
+ object::ModuleSummaryIndexObjectFile &Obj = **ObjOrErr;
return Obj.takeIndex();
}
@@ -844,8 +846,8 @@
/// The task ID when this was invoked in a thread (ThinLTO).
int TaskID;
- /// The function index for ThinLTO tasks.
- const FunctionInfoIndex *CombinedIndex;
+ /// The module summary index for ThinLTO tasks.
+ const ModuleSummaryIndex *CombinedIndex;
/// The target machine for generating code for this module.
std::unique_ptr<TargetMachine> TM;
@@ -862,11 +864,11 @@
}
/// Constructor used by ThinLTO.
CodeGen(std::unique_ptr<llvm::Module> M, raw_fd_ostream *OS, int TaskID,
- const FunctionInfoIndex *CombinedIndex, std::string Filename)
+ const ModuleSummaryIndex *CombinedIndex, std::string Filename)
: M(std::move(M)), OS(OS), TaskID(TaskID), CombinedIndex(CombinedIndex),
SaveTempsFilename(Filename) {
assert(options::thinlto == !!CombinedIndex &&
- "Expected function index iff performing ThinLTO");
+ "Expected module summary index iff performing ThinLTO");
initTargetMachine();
}
@@ -951,7 +953,7 @@
PMB.LoopVectorize = true;
PMB.SLPVectorize = true;
PMB.OptLevel = options::OptLevel;
- PMB.FunctionIndex = CombinedIndex;
+ PMB.ModuleSummary = CombinedIndex;
PMB.populateLTOPassManager(passes);
passes.run(*M);
}
@@ -1094,7 +1096,7 @@
static void thinLTOBackendTask(claimed_file &F, const void *View,
ld_plugin_input_file &File,
raw_fd_ostream *ApiFile,
- const FunctionInfoIndex &CombinedIndex,
+ const ModuleSummaryIndex &CombinedIndex,
raw_fd_ostream *OS, unsigned TaskID) {
// Need to use a separate context for each task
LLVMContext Context;
@@ -1115,7 +1117,7 @@
/// Launch each module's backend pipeline in a separate task in a thread pool.
static void thinLTOBackends(raw_fd_ostream *ApiFile,
- const FunctionInfoIndex &CombinedIndex) {
+ const ModuleSummaryIndex &CombinedIndex) {
unsigned TaskCount = 0;
std::vector<ThinLTOTaskInfo> Tasks;
Tasks.reserve(Modules.size());
@@ -1184,18 +1186,18 @@
cl::ParseCommandLineOptions(NumOpts, &options::extra[0]);
// If we are doing ThinLTO compilation, simply build the combined
- // function index/summary and emit it. We don't need to parse the modules
+ // module index/summary and emit it. We don't need to parse the modules
// and link them in this case.
if (options::thinlto) {
- FunctionInfoIndex CombinedIndex;
+ ModuleSummaryIndex CombinedIndex;
uint64_t NextModuleId = 0;
for (claimed_file &F : Modules) {
PluginInputFile InputFile(F.handle);
- std::unique_ptr<FunctionInfoIndex> Index =
- getFunctionIndexForFile(F, InputFile.file());
+ std::unique_ptr<ModuleSummaryIndex> Index =
+ getModuleSummaryIndexForFile(F, InputFile.file());
- // Skip files without a function summary.
+ // Skip files without a module summary.
if (Index)
CombinedIndex.mergeFrom(std::move(Index), ++NextModuleId);
}
diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp
index d4e4d8d..7318bfe 100644
--- a/llvm/tools/llvm-as/llvm-as.cpp
+++ b/llvm/tools/llvm-as/llvm-as.cpp
@@ -44,9 +44,9 @@
static cl::opt<bool>
DisableOutput("disable-output", cl::desc("Disable output"), cl::init(false));
-static cl::opt<bool>
-EmitFunctionSummary("function-summary", cl::desc("Emit function summary index"),
- cl::init(false));
+static cl::opt<bool> EmitSummaryIndex("module-summary",
+ cl::desc("Emit module summary index"),
+ cl::init(false));
static cl::opt<bool>
DumpAsm("d", cl::desc("Print assembly as parsed"), cl::Hidden);
@@ -82,7 +82,7 @@
if (Force || !CheckBitcodeOutputToConsole(Out->os(), true))
WriteBitcodeToFile(M, Out->os(), PreserveBitcodeUseListOrder,
- EmitFunctionSummary);
+ EmitSummaryIndex);
// Declare success.
Out->keep();
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index cdf057f..d886bd1 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -12,18 +12,18 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/Linker/Linker.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/AutoUpgrade.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/IR/FunctionInfo.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/IR/Verifier.h"
#include "llvm/IRReader/IRReader.h"
-#include "llvm/Object/FunctionIndexObjectFile.h"
+#include "llvm/Linker/Linker.h"
+#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
@@ -52,15 +52,14 @@
cl::desc("Pair of function name and filename, where function should be "
"imported from bitcode in filename"));
-// Option to support testing of function importing. The function index
+// Option to support testing of function importing. The module summary
// must be specified in the case were we request imports via the -import
// option, as well as when compiling any module with functions that may be
// exported (imported by a different llvm-link -import invocation), to ensure
// consistent promotion and renaming of locals.
-static cl::opt<std::string> FunctionIndex("functionindex",
- cl::desc("Function index filename"),
- cl::init(""),
- cl::value_desc("filename"));
+static cl::opt<std::string>
+ SummaryIndex("summary-index", cl::desc("Module summary index filename"),
+ cl::init(""), cl::value_desc("filename"));
static cl::opt<std::string>
OutputFilename("o", cl::desc("Override output filename"), cl::init("-"),
@@ -192,10 +191,10 @@
if (Verbose)
errs() << "Importing " << FunctionName << " from " << FileName << "\n";
- std::unique_ptr<FunctionInfoIndex> Index;
- if (!FunctionIndex.empty()) {
- ErrorOr<std::unique_ptr<FunctionInfoIndex>> IndexOrErr =
- llvm::getFunctionIndexForFile(FunctionIndex, diagnosticHandler);
+ std::unique_ptr<ModuleSummaryIndex> Index;
+ if (!SummaryIndex.empty()) {
+ ErrorOr<std::unique_ptr<ModuleSummaryIndex>> IndexOrErr =
+ llvm::getModuleSummaryIndexForFile(SummaryIndex, diagnosticHandler);
std::error_code EC = IndexOrErr.getError();
if (EC) {
errs() << EC.message() << '\n';
@@ -259,12 +258,12 @@
return false;
}
- // If a function index is supplied, load it so linkInModule can treat
+ // If a module summary index is supplied, load it so linkInModule can treat
// local functions/variables as exported and promote if necessary.
- std::unique_ptr<FunctionInfoIndex> Index;
- if (!FunctionIndex.empty()) {
- ErrorOr<std::unique_ptr<FunctionInfoIndex>> IndexOrErr =
- llvm::getFunctionIndexForFile(FunctionIndex, diagnosticHandler);
+ std::unique_ptr<ModuleSummaryIndex> Index;
+ if (!SummaryIndex.empty()) {
+ ErrorOr<std::unique_ptr<ModuleSummaryIndex>> IndexOrErr =
+ llvm::getModuleSummaryIndexForFile(SummaryIndex, diagnosticHandler);
std::error_code EC = IndexOrErr.getError();
if (EC) {
errs() << EC.message() << '\n';
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index f241994..8aadc40 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -19,9 +19,9 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/LTO/LTOCodeGenerator.h"
-#include "llvm/LTO/ThinLTOCodeGenerator.h"
#include "llvm/LTO/LTOModule.h"
-#include "llvm/Object/FunctionIndexObjectFile.h"
+#include "llvm/LTO/ThinLTOCodeGenerator.h"
+#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/ManagedStatic.h"
@@ -251,16 +251,16 @@
///
/// This is meant to enable testing of ThinLTO combined index generation,
/// currently available via the gold plugin via -thinlto.
-static void createCombinedFunctionIndex() {
- FunctionInfoIndex CombinedIndex;
+static void createCombinedModuleSummaryIndex() {
+ ModuleSummaryIndex CombinedIndex;
uint64_t NextModuleId = 0;
for (auto &Filename : InputFilenames) {
CurrentActivity = "loading file '" + Filename + "'";
- ErrorOr<std::unique_ptr<FunctionInfoIndex>> IndexOrErr =
- llvm::getFunctionIndexForFile(Filename, diagnosticHandler);
- std::unique_ptr<FunctionInfoIndex> Index = std::move(IndexOrErr.get());
+ ErrorOr<std::unique_ptr<ModuleSummaryIndex>> IndexOrErr =
+ llvm::getModuleSummaryIndexForFile(Filename, diagnosticHandler);
+ std::unique_ptr<ModuleSummaryIndex> Index = std::move(IndexOrErr.get());
CurrentActivity = "";
- // Skip files without a function summary.
+ // Skip files without a module summary.
if (!Index)
continue;
CombinedIndex.mergeFrom(std::move(Index), ++NextModuleId);
@@ -277,7 +277,7 @@
namespace thinlto {
std::vector<std::unique_ptr<MemoryBuffer>>
-loadAllFilesForIndex(const FunctionInfoIndex &Index) {
+loadAllFilesForIndex(const ModuleSummaryIndex &Index) {
std::vector<std::unique_ptr<MemoryBuffer>> InputBuffers;
for (auto &ModPath : Index.modPathStringEntries()) {
@@ -290,12 +290,12 @@
return InputBuffers;
}
-std::unique_ptr<FunctionInfoIndex> loadCombinedIndex() {
+std::unique_ptr<ModuleSummaryIndex> loadCombinedIndex() {
if (ThinLTOIndex.empty())
report_fatal_error("Missing -thinlto-index for ThinLTO promotion stage");
auto CurrentActivity = "loading file '" + ThinLTOIndex + "'";
- ErrorOr<std::unique_ptr<FunctionInfoIndex>> IndexOrErr =
- llvm::getFunctionIndexForFile(ThinLTOIndex, diagnosticHandler);
+ ErrorOr<std::unique_ptr<ModuleSummaryIndex>> IndexOrErr =
+ llvm::getModuleSummaryIndexForFile(ThinLTOIndex, diagnosticHandler);
error(IndexOrErr, "error " + CurrentActivity);
return std::move(IndexOrErr.get());
}
@@ -557,7 +557,7 @@
}
if (ThinLTO) {
- createCombinedFunctionIndex();
+ createCombinedModuleSummaryIndex();
return 0;
}