summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-03-14 21:18:10 +0000
committerTeresa Johnson <tejohnson@google.com>2016-03-14 21:18:10 +0000
commitcec0cae31325ef45950d3a8d0c1f2702df04d689 (patch)
tree11a78eb4957d801e923aeb457789660798d1b89d /llvm/lib
parent9c6cd5df8c1d917084e2cbf8ec8eca6a3550a97e (diff)
downloadbcm5719-llvm-cec0cae31325ef45950d3a8d0c1f2702df04d689.tar.gz
bcm5719-llvm-cec0cae31325ef45950d3a8d0c1f2702df04d689.zip
Revert "[ThinLTO] Renaming of function index to module summary index (NFC)"
This reverts commit r263490. Missed a file. llvm-svn: 263493
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp133
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp14
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp15
-rw-r--r--llvm/lib/IR/CMakeLists.txt2
-rw-r--r--llvm/lib/IR/FunctionInfo.cpp68
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp32
-rw-r--r--llvm/lib/Linker/LinkModules.cpp14
-rw-r--r--llvm/lib/Object/CMakeLists.txt2
-rw-r--r--llvm/lib/Object/FunctionIndexObjectFile.cpp (renamed from llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp)72
-rw-r--r--llvm/lib/Transforms/IPO/FunctionImport.cpp39
-rw-r--r--llvm/lib/Transforms/IPO/PassManagerBuilder.cpp14
-rw-r--r--llvm/lib/Transforms/Utils/FunctionImportUtils.cpp8
12 files changed, 241 insertions, 172 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 69fb4ece9f3..4b1ccf85231 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -7,13 +7,13 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Bitcode/BitstreamReader.h"
#include "llvm/Bitcode/LLVMBitCodes.h"
-#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/AutoUpgrade.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfo.h"
@@ -25,9 +25,9 @@
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/IR/OperandTraits.h"
#include "llvm/IR/Operator.h"
+#include "llvm/IR/FunctionInfo.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Support/DataStream.h"
#include "llvm/Support/ManagedStatic.h"
@@ -413,11 +413,11 @@ private:
/// Class to manage reading and parsing function summary index bitcode
/// files/sections.
-class ModuleSummaryIndexBitcodeReader {
+class FunctionIndexBitcodeReader {
DiagnosticHandlerFunction DiagnosticHandler;
/// Eventually points to the module index built during parsing.
- ModuleSummaryIndex *TheIndex = nullptr;
+ FunctionInfoIndex *TheIndex = nullptr;
std::unique_ptr<MemoryBuffer> Buffer;
std::unique_ptr<BitstreamReader> StreamFile;
@@ -427,7 +427,7 @@ class ModuleSummaryIndexBitcodeReader {
///
/// If false, the summary section is fully parsed into the index during
/// the initial parse. Otherwise, if true, the caller is expected to
- /// invoke \a readGlobalValueSummary for each summary needed, and the summary
+ /// invoke \a readFunctionSummary for each summary needed, and the summary
/// section is thus parsed lazily.
bool IsLazy = false;
@@ -452,7 +452,7 @@ class ModuleSummaryIndexBitcodeReader {
// ValueSymbolTable. It is used after the VST is parsed to convert
// call graph edges read from the function summary from referencing
// callees by their ValueId to using the GUID instead, which is how
- // they are recorded in the summary index being built.
+ // they are recorded in the function index being built.
DenseMap<unsigned, uint64_t> ValueIdToCallGraphGUIDMap;
/// Map to save the association between summary offset in the VST to the
@@ -474,13 +474,14 @@ public:
std::error_code error(BitcodeError E);
std::error_code error(const Twine &Message);
- ModuleSummaryIndexBitcodeReader(
- MemoryBuffer *Buffer, DiagnosticHandlerFunction DiagnosticHandler,
- bool IsLazy = false, bool CheckGlobalValSummaryPresenceOnly = false);
- ModuleSummaryIndexBitcodeReader(
- DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy = false,
- bool CheckGlobalValSummaryPresenceOnly = false);
- ~ModuleSummaryIndexBitcodeReader() { freeState(); }
+ FunctionIndexBitcodeReader(MemoryBuffer *Buffer,
+ DiagnosticHandlerFunction DiagnosticHandler,
+ bool IsLazy = false,
+ bool CheckGlobalValSummaryPresenceOnly = false);
+ FunctionIndexBitcodeReader(DiagnosticHandlerFunction DiagnosticHandler,
+ bool IsLazy = false,
+ bool CheckGlobalValSummaryPresenceOnly = false);
+ ~FunctionIndexBitcodeReader() { freeState(); }
void freeState();
@@ -492,12 +493,12 @@ public:
/// \brief Main interface to parsing a bitcode buffer.
/// \returns true if an error occurred.
std::error_code parseSummaryIndexInto(std::unique_ptr<DataStreamer> Streamer,
- ModuleSummaryIndex *I);
+ FunctionInfoIndex *I);
/// \brief Interface for parsing a summary lazily.
- std::error_code
- parseGlobalValueSummary(std::unique_ptr<DataStreamer> Streamer,
- ModuleSummaryIndex *I, size_t SummaryOffset);
+ std::error_code parseFunctionSummary(std::unique_ptr<DataStreamer> Streamer,
+ FunctionInfoIndex *I,
+ size_t FunctionSummaryOffset);
private:
std::error_code parseModule();
@@ -5413,44 +5414,44 @@ BitcodeReader::initLazyStream(std::unique_ptr<DataStreamer> Streamer) {
return std::error_code();
}
-std::error_code ModuleSummaryIndexBitcodeReader::error(BitcodeError E,
- const Twine &Message) {
+std::error_code FunctionIndexBitcodeReader::error(BitcodeError E,
+ const Twine &Message) {
return ::error(DiagnosticHandler, make_error_code(E), Message);
}
-std::error_code ModuleSummaryIndexBitcodeReader::error(const Twine &Message) {
+std::error_code FunctionIndexBitcodeReader::error(const Twine &Message) {
return ::error(DiagnosticHandler,
make_error_code(BitcodeError::CorruptedBitcode), Message);
}
-std::error_code ModuleSummaryIndexBitcodeReader::error(BitcodeError E) {
+std::error_code FunctionIndexBitcodeReader::error(BitcodeError E) {
return ::error(DiagnosticHandler, make_error_code(E));
}
-ModuleSummaryIndexBitcodeReader::ModuleSummaryIndexBitcodeReader(
+FunctionIndexBitcodeReader::FunctionIndexBitcodeReader(
MemoryBuffer *Buffer, DiagnosticHandlerFunction DiagnosticHandler,
bool IsLazy, bool CheckGlobalValSummaryPresenceOnly)
: DiagnosticHandler(DiagnosticHandler), Buffer(Buffer), IsLazy(IsLazy),
CheckGlobalValSummaryPresenceOnly(CheckGlobalValSummaryPresenceOnly) {}
-ModuleSummaryIndexBitcodeReader::ModuleSummaryIndexBitcodeReader(
+FunctionIndexBitcodeReader::FunctionIndexBitcodeReader(
DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy,
bool CheckGlobalValSummaryPresenceOnly)
: DiagnosticHandler(DiagnosticHandler), Buffer(nullptr), IsLazy(IsLazy),
CheckGlobalValSummaryPresenceOnly(CheckGlobalValSummaryPresenceOnly) {}
-void ModuleSummaryIndexBitcodeReader::freeState() { Buffer = nullptr; }
+void FunctionIndexBitcodeReader::freeState() { Buffer = nullptr; }
-void ModuleSummaryIndexBitcodeReader::releaseBuffer() { Buffer.release(); }
+void FunctionIndexBitcodeReader::releaseBuffer() { Buffer.release(); }
-uint64_t ModuleSummaryIndexBitcodeReader::getGUIDFromValueId(unsigned ValueId) {
+uint64_t FunctionIndexBitcodeReader::getGUIDFromValueId(unsigned ValueId) {
auto VGI = ValueIdToCallGraphGUIDMap.find(ValueId);
assert(VGI != ValueIdToCallGraphGUIDMap.end());
return VGI->second;
}
GlobalValueInfo *
-ModuleSummaryIndexBitcodeReader::getInfoFromSummaryOffset(uint64_t Offset) {
+FunctionIndexBitcodeReader::getInfoFromSummaryOffset(uint64_t Offset) {
auto I = SummaryOffsetToInfoMap.find(Offset);
assert(I != SummaryOffsetToInfoMap.end());
return I->second;
@@ -5462,7 +5463,7 @@ ModuleSummaryIndexBitcodeReader::getInfoFromSummaryOffset(uint64_t Offset) {
// from global value name to GlobalValueInfo. The global value info contains
// the function block's bitcode offset (if applicable), or the offset into the
// summary section for the combined index.
-std::error_code ModuleSummaryIndexBitcodeReader::parseValueSymbolTable(
+std::error_code FunctionIndexBitcodeReader::parseValueSymbolTable(
uint64_t Offset,
DenseMap<unsigned, GlobalValue::LinkageTypes> &ValueIdToLinkageMap) {
assert(Offset > 0 && "Expected non-zero VST offset");
@@ -5563,7 +5564,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseValueSymbolTable(
// either the parsed summary information (when parsing summaries
// eagerly), or just to the summary record's offset
// if parsing lazily (IsLazy).
-std::error_code ModuleSummaryIndexBitcodeReader::parseModule() {
+std::error_code FunctionIndexBitcodeReader::parseModule() {
if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
return error("Invalid record");
@@ -5700,7 +5701,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseModule() {
// Eagerly parse the entire summary block. This populates the GlobalValueSummary
// objects in the index.
-std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
+std::error_code FunctionIndexBitcodeReader::parseEntireSummary() {
if (Stream.EnterSubBlock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID))
return error("Invalid record");
@@ -5882,7 +5883,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() {
// Parse the module string table block into the Index.
// This populates the ModulePathStringTable map in the index.
-std::error_code ModuleSummaryIndexBitcodeReader::parseModuleStringTable() {
+std::error_code FunctionIndexBitcodeReader::parseModuleStringTable() {
if (Stream.EnterSubBlock(bitc::MODULE_STRTAB_BLOCK_ID))
return error("Invalid record");
@@ -5923,8 +5924,8 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseModuleStringTable() {
}
// Parse the function info index from the bitcode streamer into the given index.
-std::error_code ModuleSummaryIndexBitcodeReader::parseSummaryIndexInto(
- std::unique_ptr<DataStreamer> Streamer, ModuleSummaryIndex *I) {
+std::error_code FunctionIndexBitcodeReader::parseSummaryIndexInto(
+ std::unique_ptr<DataStreamer> Streamer, FunctionInfoIndex *I) {
TheIndex = I;
if (std::error_code EC = initStream(std::move(Streamer)))
@@ -5958,14 +5959,14 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseSummaryIndexInto(
}
}
-// Parse the summary information at the given offset in the buffer into
-// the index. Used to support lazy parsing of summaries from the
+// Parse the function information at the given offset in the buffer into
+// the index. Used to support lazy parsing of function summaries from the
// combined index during importing.
// TODO: This function is not yet complete as it won't have a consumer
// until ThinLTO function importing is added.
-std::error_code ModuleSummaryIndexBitcodeReader::parseGlobalValueSummary(
- std::unique_ptr<DataStreamer> Streamer, ModuleSummaryIndex *I,
- size_t SummaryOffset) {
+std::error_code FunctionIndexBitcodeReader::parseFunctionSummary(
+ std::unique_ptr<DataStreamer> Streamer, FunctionInfoIndex *I,
+ size_t FunctionSummaryOffset) {
TheIndex = I;
if (std::error_code EC = initStream(std::move(Streamer)))
@@ -5975,7 +5976,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseGlobalValueSummary(
if (!hasValidBitcodeHeader(Stream))
return error("Invalid bitcode signature");
- Stream.JumpToBit(SummaryOffset);
+ Stream.JumpToBit(FunctionSummaryOffset);
BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
@@ -6001,14 +6002,14 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseGlobalValueSummary(
return std::error_code();
}
-std::error_code ModuleSummaryIndexBitcodeReader::initStream(
- std::unique_ptr<DataStreamer> Streamer) {
+std::error_code
+FunctionIndexBitcodeReader::initStream(std::unique_ptr<DataStreamer> Streamer) {
if (Streamer)
return initLazyStream(std::move(Streamer));
return initStreamFromBuffer();
}
-std::error_code ModuleSummaryIndexBitcodeReader::initStreamFromBuffer() {
+std::error_code FunctionIndexBitcodeReader::initStreamFromBuffer() {
const unsigned char *BufPtr = (const unsigned char *)Buffer->getBufferStart();
const unsigned char *BufEnd = BufPtr + Buffer->getBufferSize();
@@ -6027,7 +6028,7 @@ std::error_code ModuleSummaryIndexBitcodeReader::initStreamFromBuffer() {
return std::error_code();
}
-std::error_code ModuleSummaryIndexBitcodeReader::initLazyStream(
+std::error_code FunctionIndexBitcodeReader::initLazyStream(
std::unique_ptr<DataStreamer> Streamer) {
// Check and strip off the bitcode wrapper; BitstreamReader expects never to
// see it.
@@ -6186,14 +6187,14 @@ std::string llvm::getBitcodeProducerString(MemoryBufferRef Buffer,
// the index. Otherwise skip the function summary section, and only create
// an index object with a map from function name to function summary offset.
// The index is used to perform lazy function summary reading later.
-ErrorOr<std::unique_ptr<ModuleSummaryIndex>>
-llvm::getModuleSummaryIndex(MemoryBufferRef Buffer,
- DiagnosticHandlerFunction DiagnosticHandler,
- bool IsLazy) {
+ErrorOr<std::unique_ptr<FunctionInfoIndex>>
+llvm::getFunctionInfoIndex(MemoryBufferRef Buffer,
+ DiagnosticHandlerFunction DiagnosticHandler,
+ bool IsLazy) {
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
- ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler, IsLazy);
+ FunctionIndexBitcodeReader R(Buf.get(), DiagnosticHandler, IsLazy);
- auto Index = llvm::make_unique<ModuleSummaryIndex>();
+ auto Index = llvm::make_unique<FunctionInfoIndex>();
auto cleanupOnError = [&](std::error_code EC) {
R.releaseBuffer(); // Never take ownership on error.
@@ -6203,7 +6204,7 @@ llvm::getModuleSummaryIndex(MemoryBufferRef Buffer,
if (std::error_code EC = R.parseSummaryIndexInto(nullptr, Index.get()))
return cleanupOnError(EC);
- Buf.release(); // The ModuleSummaryIndexBitcodeReader owns it now.
+ Buf.release(); // The FunctionIndexBitcodeReader owns it now.
return std::move(Index);
}
@@ -6211,7 +6212,7 @@ llvm::getModuleSummaryIndex(MemoryBufferRef Buffer,
bool llvm::hasGlobalValueSummary(MemoryBufferRef Buffer,
DiagnosticHandlerFunction DiagnosticHandler) {
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
- ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler, false, true);
+ FunctionIndexBitcodeReader R(Buf.get(), DiagnosticHandler, false, true);
auto cleanupOnError = [&](std::error_code EC) {
R.releaseBuffer(); // Never take ownership on error.
@@ -6221,38 +6222,38 @@ bool llvm::hasGlobalValueSummary(MemoryBufferRef Buffer,
if (std::error_code EC = R.parseSummaryIndexInto(nullptr, nullptr))
return cleanupOnError(EC);
- Buf.release(); // The ModuleSummaryIndexBitcodeReader owns it now.
+ Buf.release(); // The FunctionIndexBitcodeReader owns it now.
return R.foundGlobalValSummary();
}
-// This method supports lazy reading of summary data from the combined
+// This method supports lazy reading of function summary data from the combined
// index during ThinLTO function importing. When reading the combined index
-// file, getModuleSummaryIndex is first invoked with IsLazy=true.
-// Then this method is called for each value considered for importing,
-// to parse the summary information for the given value name into
+// file, getFunctionInfoIndex is first invoked with IsLazy=true.
+// Then this method is called for each function considered for importing,
+// to parse the summary information for the given function name into
// the index.
-std::error_code llvm::readGlobalValueSummary(
+std::error_code llvm::readFunctionSummary(
MemoryBufferRef Buffer, DiagnosticHandlerFunction DiagnosticHandler,
- StringRef ValueName, std::unique_ptr<ModuleSummaryIndex> Index) {
+ StringRef FunctionName, std::unique_ptr<FunctionInfoIndex> Index) {
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
- ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler);
+ FunctionIndexBitcodeReader R(Buf.get(), DiagnosticHandler);
auto cleanupOnError = [&](std::error_code EC) {
R.releaseBuffer(); // Never take ownership on error.
return EC;
};
- // Lookup the given value name in the GlobalValueMap, which may
- // contain a list of global value infos in the case of a COMDAT. Walk through
- // and parse each summary info at the summary offset
+ // Lookup the given function name in the FunctionMap, which may
+ // contain a list of function infos in the case of a COMDAT. Walk through
+ // and parse each function summary info at the function summary offset
// recorded when parsing the value symbol table.
- for (const auto &FI : Index->getGlobalValueInfoList(ValueName)) {
- size_t SummaryOffset = FI->bitcodeIndex();
+ for (const auto &FI : Index->getGlobalValueInfoList(FunctionName)) {
+ size_t FunctionSummaryOffset = FI->bitcodeIndex();
if (std::error_code EC =
- R.parseGlobalValueSummary(nullptr, Index.get(), SummaryOffset))
+ R.parseFunctionSummary(nullptr, Index.get(), FunctionSummaryOffset))
return cleanupOnError(EC);
}
- Buf.release(); // The ModuleSummaryIndexBitcodeReader owns it now.
+ Buf.release(); // The FunctionIndexBitcodeReader owns it now.
return std::error_code();
}
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index de5aa73bd6d..2e13958fdb1 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -2245,7 +2245,7 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
}
/// Emit names for globals/functions etc. The VSTOffsetPlaceholder,
-/// BitcodeStartBit and ModuleSummaryIndex are only passed for the module-level
+/// BitcodeStartBit and FunctionIndex are only passed for the module-level
/// VST, where we are including a function bitcode index and need to
/// backpatch the VST forward declaration record.
static void WriteValueSymbolTable(
@@ -2347,6 +2347,7 @@ static void WriteValueSymbolTable(
// Save the word offset of the function (from the start of the
// actual bitcode written to the stream).
+ assert(FunctionIndex->count(F) == 1);
uint64_t BitcodeIndex =
(*FunctionIndex)[F]->bitcodeIndex() - BitcodeStartBit;
assert((BitcodeIndex & 31) == 0 && "function block not 32-bit aligned");
@@ -2379,7 +2380,7 @@ static void WriteValueSymbolTable(
/// Emit function names and summary offsets for the combined index
/// used by ThinLTO.
static void
-WriteCombinedValueSymbolTable(const ModuleSummaryIndex &Index,
+WriteCombinedValueSymbolTable(const FunctionInfoIndex &Index,
BitstreamWriter &Stream,
std::map<uint64_t, unsigned> &GUIDToValueIdMap,
uint64_t VSTOffsetPlaceholder) {
@@ -2809,7 +2810,7 @@ static void WriteBlockInfo(const ValueEnumerator &VE, BitstreamWriter &Stream) {
/// Write the module path strings, currently only used when generating
/// a combined index file.
-static void WriteModStrings(const ModuleSummaryIndex &I,
+static void WriteModStrings(const FunctionInfoIndex &I,
BitstreamWriter &Stream) {
Stream.EnterSubblock(bitc::MODULE_STRTAB_BLOCK_ID, 3);
@@ -3010,9 +3011,10 @@ static void WritePerModuleGlobalValueSummary(
Stream.ExitBlock();
}
-/// Emit the combined summary section into the combined index file.
+/// Emit the combined function summary section into the combined index
+/// file.
static void WriteCombinedGlobalValueSummary(
- const ModuleSummaryIndex &I, BitstreamWriter &Stream,
+ const FunctionInfoIndex &I, BitstreamWriter &Stream,
std::map<uint64_t, unsigned> &GUIDToValueIdMap, unsigned GlobalValueId) {
Stream.EnterSubblock(bitc::GLOBALVAL_SUMMARY_BLOCK_ID, 3);
@@ -3352,7 +3354,7 @@ void llvm::WriteBitcodeToFile(const Module *M, raw_ostream &Out,
// Write the specified module summary index to the given raw output stream,
// where it will be written in a new bitcode block. This is used when
// writing the combined index file for ThinLTO.
-void llvm::WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out) {
+void llvm::WriteIndexToFile(const FunctionInfoIndex &Index, raw_ostream &Out) {
SmallVector<char, 0> Buffer;
Buffer.reserve(256 * 1024);
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
index 85b9bd83c13..24de99a34d3 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
@@ -19,7 +19,7 @@
using namespace llvm;
PreservedAnalyses BitcodeWriterPass::run(Module &M) {
- WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, EmitSummaryIndex);
+ WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, EmitFunctionSummary);
return PreservedAnalyses::all();
}
@@ -27,20 +27,21 @@ namespace {
class WriteBitcodePass : public ModulePass {
raw_ostream &OS; // raw_ostream to print on
bool ShouldPreserveUseListOrder;
- bool EmitSummaryIndex;
+ bool EmitFunctionSummary;
public:
static char ID; // Pass identification, replacement for typeid
explicit WriteBitcodePass(raw_ostream &o, bool ShouldPreserveUseListOrder,
- bool EmitSummaryIndex)
+ bool EmitFunctionSummary)
: ModulePass(ID), OS(o),
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder),
- EmitSummaryIndex(EmitSummaryIndex) {}
+ EmitFunctionSummary(EmitFunctionSummary) {}
const char *getPassName() const override { return "Bitcode Writer"; }
bool runOnModule(Module &M) override {
- WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, EmitSummaryIndex);
+ WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder,
+ EmitFunctionSummary);
return false;
}
};
@@ -50,7 +51,7 @@ char WriteBitcodePass::ID = 0;
ModulePass *llvm::createBitcodeWriterPass(raw_ostream &Str,
bool ShouldPreserveUseListOrder,
- bool EmitSummaryIndex) {
+ bool EmitFunctionSummary) {
return new WriteBitcodePass(Str, ShouldPreserveUseListOrder,
- EmitSummaryIndex);
+ EmitFunctionSummary);
}
diff --git a/llvm/lib/IR/CMakeLists.txt b/llvm/lib/IR/CMakeLists.txt
index 554ea1422a1..45f7e31aa53 100644
--- a/llvm/lib/IR/CMakeLists.txt
+++ b/llvm/lib/IR/CMakeLists.txt
@@ -37,12 +37,12 @@ add_llvm_library(LLVMCore
Mangler.cpp
Metadata.cpp
Module.cpp
- ModuleSummaryIndex.cpp
Operator.cpp
Pass.cpp
PassManager.cpp
PassRegistry.cpp
Statepoint.cpp
+ FunctionInfo.cpp
Type.cpp
TypeFinder.cpp
Use.cpp
diff --git a/llvm/lib/IR/FunctionInfo.cpp b/llvm/lib/IR/FunctionInfo.cpp
new file mode 100644
index 00000000000..e9a598d1435
--- /dev/null
+++ b/llvm/lib/IR/FunctionInfo.cpp
@@ -0,0 +1,68 @@
+//===-- FunctionInfo.cpp - Function Info 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/FunctionInfo.h"
+#include "llvm/ADT/StringMap.h"
+using namespace llvm;
+
+// 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 &OtherGlobalValInfoLists : *Other) {
+ uint64_t ValueGUID = OtherGlobalValInfoLists.first;
+ GlobalValueInfoList &List = OtherGlobalValInfoLists.second;
+
+ // 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<GlobalValueInfo> Info = std::move(List.front());
+
+ // 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->summary()->modulePath(), NextModuleId);
+ else
+ 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->summary()->setModulePath(ModPath);
+
+ // 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;
+ }
+}
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index e364a2a4a34..2caf71ff330 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -14,21 +14,21 @@
#include "llvm/LTO/ThinLTOCodeGenerator.h"
-#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TargetTransformInfo.h"
-#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/ExecutionEngine/ObjectMemoryBuffer.h"
-#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Linker/Linker.h"
#include "llvm/MC/SubtargetFeature.h"
-#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
+#include "llvm/Object/FunctionIndexObjectFile.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/ThreadPool.h"
@@ -126,13 +126,13 @@ public:
}
};
-static void promoteModule(Module &TheModule, const ModuleSummaryIndex &Index) {
+static void promoteModule(Module &TheModule, const FunctionInfoIndex &Index) {
if (renameModuleForThinLTO(TheModule, Index))
report_fatal_error("renameModuleForThinLTO failed");
}
static void crossImportIntoModule(Module &TheModule,
- const ModuleSummaryIndex &Index,
+ const FunctionInfoIndex &Index,
StringMap<MemoryBufferRef> &ModuleMap) {
ModuleLoader Loader(TheModule.getContext(), ModuleMap);
FunctionImporter Importer(Index, Loader);
@@ -183,7 +183,7 @@ std::unique_ptr<MemoryBuffer> codegenModule(Module &TheModule,
}
static std::unique_ptr<MemoryBuffer>
-ProcessThinLTOModule(Module &TheModule, const ModuleSummaryIndex &Index,
+ProcessThinLTOModule(Module &TheModule, const FunctionInfoIndex &Index,
StringMap<MemoryBufferRef> &ModuleMap, TargetMachine &TM,
ThinLTOCodeGenerator::CachingOptions CacheOptions,
StringRef SaveTempsDir, unsigned count) {
@@ -277,19 +277,19 @@ std::unique_ptr<TargetMachine> TargetMachineBuilder::create() const {
}
/**
- * Produce the combined summary index from all the bitcode files:
+ * Produce the combined function index from all the bitcode files:
* "thin-link".
*/
-std::unique_ptr<ModuleSummaryIndex> ThinLTOCodeGenerator::linkCombinedIndex() {
- std::unique_ptr<ModuleSummaryIndex> CombinedIndex;
+std::unique_ptr<FunctionInfoIndex> ThinLTOCodeGenerator::linkCombinedIndex() {
+ std::unique_ptr<FunctionInfoIndex> CombinedIndex;
uint64_t NextModuleId = 0;
for (auto &ModuleBuffer : Modules) {
- ErrorOr<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
- object::ModuleSummaryIndexObjectFile::create(ModuleBuffer,
- diagnosticHandler, false);
+ ErrorOr<std::unique_ptr<object::FunctionIndexObjectFile>> ObjOrErr =
+ object::FunctionIndexObjectFile::create(ModuleBuffer, diagnosticHandler,
+ false);
if (std::error_code EC = ObjOrErr.getError()) {
// FIXME diagnose
- errs() << "error: can't create ModuleSummaryIndexObjectFile for buffer: "
+ errs() << "error: can't create FunctionIndexObjectFile for buffer: "
<< EC.message() << "\n";
return nullptr;
}
@@ -307,7 +307,7 @@ std::unique_ptr<ModuleSummaryIndex> ThinLTOCodeGenerator::linkCombinedIndex() {
* Perform promotion and renaming of exported internal functions.
*/
void ThinLTOCodeGenerator::promote(Module &TheModule,
- ModuleSummaryIndex &Index) {
+ FunctionInfoIndex &Index) {
promoteModule(TheModule, Index);
}
@@ -315,7 +315,7 @@ void ThinLTOCodeGenerator::promote(Module &TheModule,
* Perform cross-module importing for the module identified by ModuleIdentifier.
*/
void ThinLTOCodeGenerator::crossModuleImport(Module &TheModule,
- ModuleSummaryIndex &Index) {
+ FunctionInfoIndex &Index) {
auto ModuleMap = generateModuleMap(Modules);
crossImportIntoModule(TheModule, Index, ModuleMap);
}
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index eee1bb3ebb4..e3ad7bb7280 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -35,15 +35,15 @@ class ModuleLinker {
/// For symbol clashes, prefer those from Src.
unsigned Flags;
- /// Module summary index passed into ModuleLinker for using in function
+ /// Function index passed into ModuleLinker for using in function
/// importing/exporting handling.
- const ModuleSummaryIndex *ImportIndex;
+ const FunctionInfoIndex *ImportIndex;
/// Functions to import from source module, all other functions are
/// imported as declarations instead of definitions.
DenseSet<const GlobalValue *> *FunctionsToImport;
- /// Set to true if the given ModuleSummaryIndex contains any functions
+ /// Set to true if the given FunctionInfoIndex contains any functions
/// from this source module, in which case we must conservatively assume
/// that any of its functions may be imported into another module
/// as part of a different backend compilation process.
@@ -124,15 +124,15 @@ class ModuleLinker {
public:
ModuleLinker(IRMover &Mover, std::unique_ptr<Module> SrcM, unsigned Flags,
- const ModuleSummaryIndex *Index = nullptr,
+ const FunctionInfoIndex *Index = nullptr,
DenseSet<const GlobalValue *> *FunctionsToImport = nullptr,
DenseMap<unsigned, MDNode *> *ValIDToTempMDMap = nullptr)
: Mover(Mover), SrcM(std::move(SrcM)), Flags(Flags), ImportIndex(Index),
FunctionsToImport(FunctionsToImport),
ValIDToTempMDMap(ValIDToTempMDMap) {
assert((ImportIndex || !FunctionsToImport) &&
- "Expect a ModuleSummaryIndex when importing");
- // If we have a ModuleSummaryIndex but no function to import,
+ "Expect a FunctionInfoIndex when importing");
+ // If we have a FunctionInfoIndex but no function to import,
// then this is the primary module being compiled in a ThinLTO
// backend compilation, and we need to see if it has functions that
// may be exported to another backend compilation.
@@ -549,7 +549,7 @@ bool ModuleLinker::run() {
Linker::Linker(Module &M) : Mover(M) {}
bool Linker::linkInModule(std::unique_ptr<Module> Src, unsigned Flags,
- const ModuleSummaryIndex *Index,
+ const FunctionInfoIndex *Index,
DenseSet<const GlobalValue *> *FunctionsToImport,
DenseMap<unsigned, MDNode *> *ValIDToTempMDMap) {
ModuleLinker ModLinker(Mover, std::move(Src), Flags, Index, FunctionsToImport,
diff --git a/llvm/lib/Object/CMakeLists.txt b/llvm/lib/Object/CMakeLists.txt
index 0a37cc360fe..7993e751ec3 100644
--- a/llvm/lib/Object/CMakeLists.txt
+++ b/llvm/lib/Object/CMakeLists.txt
@@ -9,12 +9,12 @@ add_llvm_library(LLVMObject
IRObjectFile.cpp
MachOObjectFile.cpp
MachOUniversal.cpp
- ModuleSummaryIndexObjectFile.cpp
Object.cpp
ObjectFile.cpp
RecordStreamer.cpp
SymbolicFile.cpp
SymbolSize.cpp
+ FunctionIndexObjectFile.cpp
ADDITIONAL_HEADER_DIRS
${LLVM_MAIN_INCLUDE_DIR}/llvm/Object
diff --git a/llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp b/llvm/lib/Object/FunctionIndexObjectFile.cpp
index 53d3f8e61b5..9347988cf3d 100644
--- a/llvm/lib/Object/ModuleSummaryIndexObjectFile.cpp
+++ b/llvm/lib/Object/FunctionIndexObjectFile.cpp
@@ -1,4 +1,4 @@
-//===- ModuleSummaryIndexObjectFile.cpp - Summary index file implementation ==//
+//===- FunctionIndexObjectFile.cpp - Function index file implementation ---===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
//
-// Part of the ModuleSummaryIndexObjectFile class implementation.
+// Part of the FunctionIndexObjectFile class implementation.
//
//===----------------------------------------------------------------------===//
-#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
+#include "llvm/Object/FunctionIndexObjectFile.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/FunctionInfo.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -22,19 +22,18 @@
using namespace llvm;
using namespace object;
-ModuleSummaryIndexObjectFile::ModuleSummaryIndexObjectFile(
- MemoryBufferRef Object, std::unique_ptr<ModuleSummaryIndex> I)
- : SymbolicFile(Binary::ID_ModuleSummaryIndex, Object), Index(std::move(I)) {
-}
+FunctionIndexObjectFile::FunctionIndexObjectFile(
+ MemoryBufferRef Object, std::unique_ptr<FunctionInfoIndex> I)
+ : SymbolicFile(Binary::ID_FunctionIndex, Object), Index(std::move(I)) {}
-ModuleSummaryIndexObjectFile::~ModuleSummaryIndexObjectFile() {}
+FunctionIndexObjectFile::~FunctionIndexObjectFile() {}
-std::unique_ptr<ModuleSummaryIndex> ModuleSummaryIndexObjectFile::takeIndex() {
+std::unique_ptr<FunctionInfoIndex> FunctionIndexObjectFile::takeIndex() {
return std::move(Index);
}
ErrorOr<MemoryBufferRef>
-ModuleSummaryIndexObjectFile::findBitcodeInObject(const ObjectFile &Obj) {
+FunctionIndexObjectFile::findBitcodeInObject(const ObjectFile &Obj) {
for (const SectionRef &Sec : Obj.sections()) {
if (Sec.isBitcode()) {
StringRef SecContents;
@@ -48,7 +47,7 @@ ModuleSummaryIndexObjectFile::findBitcodeInObject(const ObjectFile &Obj) {
}
ErrorOr<MemoryBufferRef>
-ModuleSummaryIndexObjectFile::findBitcodeInMemBuffer(MemoryBufferRef Object) {
+FunctionIndexObjectFile::findBitcodeInMemBuffer(MemoryBufferRef Object) {
sys::fs::file_magic Type = sys::fs::identify_magic(Object.getBuffer());
switch (Type) {
case sys::fs::file_magic::bitcode:
@@ -69,7 +68,7 @@ ModuleSummaryIndexObjectFile::findBitcodeInMemBuffer(MemoryBufferRef Object) {
// Looks for module summary index in the given memory buffer.
// returns true if found, else false.
-bool ModuleSummaryIndexObjectFile::hasGlobalValueSummaryInMemBuffer(
+bool FunctionIndexObjectFile::hasGlobalValueSummaryInMemBuffer(
MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler) {
ErrorOr<MemoryBufferRef> BCOrErr = findBitcodeInMemBuffer(Object);
if (!BCOrErr)
@@ -78,65 +77,64 @@ bool ModuleSummaryIndexObjectFile::hasGlobalValueSummaryInMemBuffer(
return hasGlobalValueSummary(BCOrErr.get(), DiagnosticHandler);
}
-// Parse module summary index in the given memory buffer.
-// Return new ModuleSummaryIndexObjectFile instance containing parsed
-// module summary/index.
-ErrorOr<std::unique_ptr<ModuleSummaryIndexObjectFile>>
-ModuleSummaryIndexObjectFile::create(
- MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler,
- bool IsLazy) {
- std::unique_ptr<ModuleSummaryIndex> Index;
+// Parse function index in the given memory buffer.
+// Return new FunctionIndexObjectFile instance containing parsed
+// function summary/index.
+ErrorOr<std::unique_ptr<FunctionIndexObjectFile>>
+FunctionIndexObjectFile::create(MemoryBufferRef Object,
+ DiagnosticHandlerFunction DiagnosticHandler,
+ bool IsLazy) {
+ std::unique_ptr<FunctionInfoIndex> Index;
ErrorOr<MemoryBufferRef> BCOrErr = findBitcodeInMemBuffer(Object);
if (!BCOrErr)
return BCOrErr.getError();
- ErrorOr<std::unique_ptr<ModuleSummaryIndex>> IOrErr =
- getModuleSummaryIndex(BCOrErr.get(), DiagnosticHandler, IsLazy);
+ ErrorOr<std::unique_ptr<FunctionInfoIndex>> IOrErr = getFunctionInfoIndex(
+ BCOrErr.get(), DiagnosticHandler, IsLazy);
if (std::error_code EC = IOrErr.getError())
return EC;
Index = std::move(IOrErr.get());
- return llvm::make_unique<ModuleSummaryIndexObjectFile>(Object,
- std::move(Index));
+ return llvm::make_unique<FunctionIndexObjectFile>(Object, std::move(Index));
}
-// Parse the summary information for value with the
+// Parse the function summary information for function with the
// given name out of the given buffer. Parsed information is
// stored on the index object saved in this object.
-std::error_code ModuleSummaryIndexObjectFile::findGlobalValueSummaryInMemBuffer(
+std::error_code FunctionIndexObjectFile::findFunctionSummaryInMemBuffer(
MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler,
- StringRef ValueName) {
+ StringRef FunctionName) {
sys::fs::file_magic Type = sys::fs::identify_magic(Object.getBuffer());
switch (Type) {
case sys::fs::file_magic::bitcode: {
- return readGlobalValueSummary(Object, DiagnosticHandler, ValueName,
- std::move(Index));
+ return readFunctionSummary(Object, DiagnosticHandler, FunctionName,
+ std::move(Index));
}
default:
return object_error::invalid_file_type;
}
}
-// Parse the module summary index out of an IR file and return the summary
+// Parse the function index out of an IR file and return the function
// index object if found, or nullptr if not.
-ErrorOr<std::unique_ptr<ModuleSummaryIndex>> llvm::getModuleSummaryIndexForFile(
- StringRef Path, DiagnosticHandlerFunction DiagnosticHandler) {
+ErrorOr<std::unique_ptr<FunctionInfoIndex>>
+llvm::getFunctionIndexForFile(StringRef Path,
+ DiagnosticHandlerFunction DiagnosticHandler) {
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
MemoryBuffer::getFileOrSTDIN(Path);
std::error_code EC = FileOrErr.getError();
if (EC)
return EC;
MemoryBufferRef BufferRef = (FileOrErr.get())->getMemBufferRef();
- ErrorOr<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
- object::ModuleSummaryIndexObjectFile::create(BufferRef,
- DiagnosticHandler);
+ ErrorOr<std::unique_ptr<object::FunctionIndexObjectFile>> ObjOrErr =
+ object::FunctionIndexObjectFile::create(BufferRef, DiagnosticHandler);
EC = ObjOrErr.getError();
if (EC)
return EC;
- object::ModuleSummaryIndexObjectFile &Obj = **ObjOrErr;
+ object::FunctionIndexObjectFile &Obj = **ObjOrErr;
return Obj.takeIndex();
}
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 90b36aab363..8aa97535170 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -20,7 +20,7 @@
#include "llvm/IR/Module.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Linker/Linker.h"
-#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
+#include "llvm/Object/FunctionIndexObjectFile.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/SourceMgr.h"
@@ -111,7 +111,7 @@ Module &ModuleLazyLoaderCache::operator()(StringRef Identifier) {
/// calls not already in the \p VisitedFunctions map. If any are
/// found they are added to the \p Worklist for importing.
static void findExternalCalls(
- const Module &DestModule, Function &F, const ModuleSummaryIndex &Index,
+ const Module &DestModule, Function &F, const FunctionInfoIndex &Index,
VisitedFunctionTrackerTy &VisitedFunctions, unsigned Threshold,
SmallVectorImpl<std::pair<StringRef, unsigned>> &Worklist) {
// We need to suffix internal function calls imported from other modules,
@@ -141,7 +141,7 @@ static void findExternalCalls(
if (CalledFunction->hasInternalLinkage()) {
ImportedName = Renamed;
}
- // Compute the global identifier used in the summary index.
+ // Compute the global identifier used in the function index.
auto CalledFunctionGlobalID = Function::getGlobalIdentifier(
CalledFunction->getName(), CalledFunction->getLinkage(),
CalledFunction->getParent()->getSourceFileName());
@@ -192,9 +192,9 @@ static void
GetImportList(Module &DestModule,
SmallVectorImpl<std::pair<StringRef, unsigned>> &Worklist,
VisitedFunctionTrackerTy &VisitedFunctions,
- std::map<StringRef, DenseSet<const GlobalValue *>>
- &ModuleToFunctionsToImportMap,
- const ModuleSummaryIndex &Index,
+ std::map<StringRef, DenseSet<const GlobalValue *>> &
+ ModuleToFunctionsToImportMap,
+ const FunctionInfoIndex &Index,
ModuleLazyLoaderCache &ModuleLoaderCache) {
while (!Worklist.empty()) {
StringRef CalledFunctionName;
@@ -374,11 +374,11 @@ static void diagnosticHandler(const DiagnosticInfo &DI) {
OS << '\n';
}
-/// Parse the summary index out of an IR file and return the summary
+/// Parse the function index out of an IR file and return the function
/// index object if found, or nullptr if not.
-static std::unique_ptr<ModuleSummaryIndex>
-getModuleSummaryIndexForFile(StringRef Path, std::string &Error,
- DiagnosticHandlerFunction DiagnosticHandler) {
+static std::unique_ptr<FunctionInfoIndex>
+getFunctionIndexForFile(StringRef Path, std::string &Error,
+ DiagnosticHandlerFunction DiagnosticHandler) {
std::unique_ptr<MemoryBuffer> Buffer;
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getFile(Path);
@@ -387,9 +387,9 @@ getModuleSummaryIndexForFile(StringRef Path, std::string &Error,
return nullptr;
}
Buffer = std::move(BufferOrErr.get());
- ErrorOr<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
- object::ModuleSummaryIndexObjectFile::create(Buffer->getMemBufferRef(),
- DiagnosticHandler);
+ ErrorOr<std::unique_ptr<object::FunctionIndexObjectFile>> ObjOrErr =
+ object::FunctionIndexObjectFile::create(Buffer->getMemBufferRef(),
+ DiagnosticHandler);
if (std::error_code EC = ObjOrErr.getError()) {
Error = EC.message();
return nullptr;
@@ -400,9 +400,9 @@ getModuleSummaryIndexForFile(StringRef Path, std::string &Error,
namespace {
/// Pass that performs cross-module function import provided a summary file.
class FunctionImportPass : public ModulePass {
- /// Optional module summary index to use for importing, otherwise
+ /// Optional function summary index to use for importing, otherwise
/// the summary-file option must be specified.
- const ModuleSummaryIndex *Index;
+ const FunctionInfoIndex *Index;
public:
/// Pass identification, replacement for typeid
@@ -413,20 +413,19 @@ public:
return "Function Importing";
}
- explicit FunctionImportPass(const ModuleSummaryIndex *Index = nullptr)
+ explicit FunctionImportPass(const FunctionInfoIndex *Index = nullptr)
: ModulePass(ID), Index(Index) {}
bool runOnModule(Module &M) override {
if (SummaryFile.empty() && !Index)
report_fatal_error("error: -function-import requires -summary-file or "
"file from frontend\n");
- std::unique_ptr<ModuleSummaryIndex> IndexPtr;
+ std::unique_ptr<FunctionInfoIndex> IndexPtr;
if (!SummaryFile.empty()) {
if (Index)
report_fatal_error("error: -summary-file and index from frontend\n");
std::string Error;
- IndexPtr =
- getModuleSummaryIndexForFile(SummaryFile, Error, diagnosticHandler);
+ IndexPtr = getFunctionIndexForFile(SummaryFile, Error, diagnosticHandler);
if (!IndexPtr) {
errs() << "Error loading file '" << SummaryFile << "': " << Error
<< "\n";
@@ -459,7 +458,7 @@ INITIALIZE_PASS_END(FunctionImportPass, "function-import",
"Summary Based Function Import", false, false)
namespace llvm {
-Pass *createFunctionImportPass(const ModuleSummaryIndex *Index = nullptr) {
+Pass *createFunctionImportPass(const FunctionInfoIndex *Index = nullptr) {
return new FunctionImportPass(Index);
}
}
diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index a5399e5760e..3bc9cd51413 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -23,8 +23,8 @@
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/FunctionInfo.h"
#include "llvm/IR/LegacyPassManager.h"
-#include "llvm/IR/ModuleSummaryIndex.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
@@ -33,10 +33,10 @@
#include "llvm/Transforms/IPO/ForceFunctionAttrs.h"
#include "llvm/Transforms/IPO/FunctionAttrs.h"
#include "llvm/Transforms/IPO/InferFunctionAttrs.h"
-#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Vectorize.h"
+#include "llvm/Transforms/Instrumentation.h"
using namespace llvm;
@@ -127,7 +127,7 @@ PassManagerBuilder::PassManagerBuilder() {
SizeLevel = 0;
LibraryInfo = nullptr;
Inliner = nullptr;
- ModuleSummary = nullptr;
+ FunctionIndex = nullptr;
DisableUnitAtATime = false;
DisableUnrollLoops = false;
BBVectorize = RunBBVectorization;
@@ -572,8 +572,8 @@ void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
// Provide AliasAnalysis services for optimizations.
addInitialAliasAnalysisPasses(PM);
- if (ModuleSummary)
- PM.add(createFunctionImportPass(ModuleSummary));
+ if (FunctionIndex)
+ PM.add(createFunctionImportPass(FunctionIndex));
// Allow forcing function attributes as a debugging and tuning aid.
PM.add(createForceFunctionAttrsLegacyPass());
@@ -724,8 +724,8 @@ void PassManagerBuilder::populateThinLTOPassManager(
if (VerifyInput)
PM.add(createVerifierPass());
- if (ModuleSummary)
- PM.add(createFunctionImportPass(ModuleSummary));
+ if (FunctionIndex)
+ PM.add(createFunctionImportPass(FunctionIndex));
populateModulePassManager(PM);
diff --git a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
index eceb0850941..73069b2c742 100644
--- a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
+++ b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -68,7 +68,7 @@ bool FunctionImportGlobalProcessing::doPromoteLocalToGlobal(
// For now we are conservative in determining which variables are not
// address taken by checking the unnamed addr flag. To be more aggressive,
// the address taken information must be checked earlier during parsing
- // of the module and recorded in the summary index for use when importing
+ // of the module and recorded in the function index for use when importing
// from that module.
auto *GVar = dyn_cast<GlobalVariable>(SGV);
if (GVar && GVar->isConstant() && GVar->hasUnnamedAddr())
@@ -76,7 +76,7 @@ bool FunctionImportGlobalProcessing::doPromoteLocalToGlobal(
// Eventually we only need to promote functions in the exporting module that
// are referenced by a potentially exported function (i.e. one that is in the
- // summary index).
+ // function index).
return true;
}
@@ -88,7 +88,7 @@ std::string FunctionImportGlobalProcessing::getName(const GlobalValue *SGV) {
// avoid naming conflicts between locals imported from different modules.
if (SGV->hasLocalLinkage() &&
(doPromoteLocalToGlobal(SGV) || isPerformingImport()))
- return ModuleSummaryIndex::getGlobalNameForLocal(
+ return FunctionInfoIndex::getGlobalNameForLocal(
SGV->getName(),
ImportIndex.getModuleId(SGV->getParent()->getModuleIdentifier()));
return SGV->getName();
@@ -231,7 +231,7 @@ bool FunctionImportGlobalProcessing::run() {
return false;
}
-bool llvm::renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index) {
+bool llvm::renameModuleForThinLTO(Module &M, const FunctionInfoIndex &Index) {
FunctionImportGlobalProcessing ThinLTOProcessing(M, Index);
return ThinLTOProcessing.run();
}
OpenPOWER on IntegriCloud