[llvm] r267097 - [ThinLTO] Remove unused/incomplete lazy summary reading support (NFC)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed May 4 16:18:04 PDT 2016
Teresa Johnson via llvm-commits <llvm-commits at lists.llvm.org> writes:
> Author: tejohnson
> Date: Thu Apr 21 20:52:00 2016
> New Revision: 267097
>
> URL: http://llvm.org/viewvc/llvm-project?rev=267097&view=rev
> Log:
> [ThinLTO] Remove unused/incomplete lazy summary reading support (NFC)
>
> This removes the interfaces added (and not yet complete) to support
> lazy reading of summaries. This support is not expected to be needed
> since we are moving to a model where the full index is only being
> traversed in the thin link step, instead of the back ends.
This leaves ModuleSummaryIndexBitcodeReader::parseGlobalValueSummary
unused. Should it be removed too?
> (The second part of this that I plan to do next is remove the
> GlobalValueInfo from the ModuleSummaryIndex - it was mostly needed to
> support lazy parsing of summaries. The index can instead reference the
> summary structures directly.)
>
> Modified:
> llvm/trunk/include/llvm/Bitcode/ReaderWriter.h
> llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h
> llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
> llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp
>
> Modified: llvm/trunk/include/llvm/Bitcode/ReaderWriter.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/ReaderWriter.h?rev=267097&r1=267096&r2=267097&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Bitcode/ReaderWriter.h (original)
> +++ llvm/trunk/include/llvm/Bitcode/ReaderWriter.h Thu Apr 21 20:52:00 2016
> @@ -75,24 +75,9 @@ namespace llvm {
> DiagnosticHandlerFunction DiagnosticHandler);
>
> /// Parse the specified bitcode buffer, returning the module summary index.
> - /// If IsLazy is true, parse the entire module summary into
> - /// the index. Otherwise skip the module summary section, and only create
> - /// an index object with a map from value name to the value's summary offset.
> - /// The index is used to perform lazy summary reading later.
> ErrorOr<std::unique_ptr<ModuleSummaryIndex>>
> getModuleSummaryIndex(MemoryBufferRef Buffer,
> - DiagnosticHandlerFunction DiagnosticHandler,
> - bool IsLazy = false);
> -
> - /// This method supports lazy reading of summary data from the
> - /// combined index during 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
> - /// the index.
> - std::error_code readGlobalValueSummary(
> - MemoryBufferRef Buffer, DiagnosticHandlerFunction DiagnosticHandler,
> - StringRef ValueName, std::unique_ptr<ModuleSummaryIndex> Index);
> + DiagnosticHandlerFunction DiagnosticHandler);
>
> /// \brief Write the specified module to the specified raw output stream.
> ///
>
> Modified: llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h?rev=267097&r1=267096&r2=267097&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h (original)
> +++ llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h Thu Apr 21 20:52:00 2016
> @@ -89,16 +89,7 @@ public:
> /// Return new ModuleSummaryIndexObjectFile instance containing parsed module
> /// summary/index.
> static ErrorOr<std::unique_ptr<ModuleSummaryIndexObjectFile>>
> - create(MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler,
> - bool IsLazy = false);
> -
> - /// \brief Parse the summary information for global value with the
> - /// given name out of the given buffer. Parsed information is
> - /// stored on the index object saved in this object.
> - std::error_code
> - findGlobalValueSummaryInMemBuffer(MemoryBufferRef Object,
> - DiagnosticHandlerFunction DiagnosticHandler,
> - StringRef ValueName);
> + create(MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler);
> };
> }
>
>
> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=267097&r1=267096&r2=267097&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu Apr 21 20:52:00 2016
> @@ -430,14 +430,6 @@ class ModuleSummaryIndexBitcodeReader {
> std::unique_ptr<BitstreamReader> StreamFile;
> BitstreamCursor Stream;
>
> - /// \brief Used to indicate whether we are doing lazy parsing of summary data.
> - ///
> - /// 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
> - /// section is thus parsed lazily.
> - bool IsLazy = false;
> -
> /// Used to indicate whether caller only wants to check for the presence
> /// of the global value summary bitcode section. All blocks are skipped,
> /// but the SeenGlobalValSummary boolean is set.
> @@ -483,9 +475,9 @@ public:
>
> ModuleSummaryIndexBitcodeReader(
> MemoryBuffer *Buffer, DiagnosticHandlerFunction DiagnosticHandler,
> - bool IsLazy = false, bool CheckGlobalValSummaryPresenceOnly = false);
> + bool CheckGlobalValSummaryPresenceOnly = false);
> ModuleSummaryIndexBitcodeReader(
> - DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy = false,
> + DiagnosticHandlerFunction DiagnosticHandler,
> bool CheckGlobalValSummaryPresenceOnly = false);
> ~ModuleSummaryIndexBitcodeReader() { freeState(); }
>
> @@ -5512,14 +5504,14 @@ std::error_code ModuleSummaryIndexBitcod
>
> ModuleSummaryIndexBitcodeReader::ModuleSummaryIndexBitcodeReader(
> MemoryBuffer *Buffer, DiagnosticHandlerFunction DiagnosticHandler,
> - bool IsLazy, bool CheckGlobalValSummaryPresenceOnly)
> - : DiagnosticHandler(DiagnosticHandler), Buffer(Buffer), IsLazy(IsLazy),
> + bool CheckGlobalValSummaryPresenceOnly)
> + : DiagnosticHandler(DiagnosticHandler), Buffer(Buffer),
> CheckGlobalValSummaryPresenceOnly(CheckGlobalValSummaryPresenceOnly) {}
>
> ModuleSummaryIndexBitcodeReader::ModuleSummaryIndexBitcodeReader(
> - DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy,
> + DiagnosticHandlerFunction DiagnosticHandler,
> bool CheckGlobalValSummaryPresenceOnly)
> - : DiagnosticHandler(DiagnosticHandler), Buffer(nullptr), IsLazy(IsLazy),
> + : DiagnosticHandler(DiagnosticHandler), Buffer(nullptr),
> CheckGlobalValSummaryPresenceOnly(CheckGlobalValSummaryPresenceOnly) {}
>
> void ModuleSummaryIndexBitcodeReader::freeState() { Buffer = nullptr; }
> @@ -5606,7 +5598,6 @@ std::error_code ModuleSummaryIndexBitcod
> return error("Invalid record");
> unsigned ValueID = Record[0];
> uint64_t FuncOffset = Record[1];
> - assert(!IsLazy && "Lazy summary read only supported for combined index");
> std::unique_ptr<GlobalValueInfo> FuncInfo =
> llvm::make_unique<GlobalValueInfo>(FuncOffset);
> assert(!SourceFileName.empty());
> @@ -5650,9 +5641,7 @@ std::error_code ModuleSummaryIndexBitcod
> // Parse just the blocks needed for building the index out of the module.
> // At the end of this routine the module Index is populated with a map
> // from global value name to GlobalValueInfo. The global value info contains
> -// either the parsed summary information (when parsing summaries
> -// eagerly), or just to the summary record's offset
> -// if parsing lazily (IsLazy).
> +// the parsed summary information (when parsing summaries eagerly).
> std::error_code ModuleSummaryIndexBitcodeReader::parseModule() {
> if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
> return error("Invalid record");
> @@ -5710,11 +5699,7 @@ std::error_code ModuleSummaryIndexBitcod
> return EC;
> SeenValueSymbolTable = true;
> SeenGlobalValSummary = true;
> - if (IsLazy) {
> - // Lazy parsing of summary info, skip it.
> - if (Stream.SkipBlock())
> - return error("Invalid record");
> - } else if (std::error_code EC = parseEntireSummary())
> + if (std::error_code EC = parseEntireSummary())
> return EC;
> break;
> case bitc::MODULE_STRTAB_BLOCK_ID:
> @@ -6347,16 +6332,11 @@ std::string llvm::getBitcodeProducerStri
> }
>
> // Parse the specified bitcode buffer, returning the function info index.
> -// If IsLazy is false, parse the entire function summary into
> -// 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) {
> + DiagnosticHandlerFunction DiagnosticHandler) {
> std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
> - ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler, IsLazy);
> + ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler);
>
> auto Index = llvm::make_unique<ModuleSummaryIndex>();
>
> @@ -6376,7 +6356,7 @@ llvm::getModuleSummaryIndex(MemoryBuffer
> bool llvm::hasGlobalValueSummary(MemoryBufferRef Buffer,
> DiagnosticHandlerFunction DiagnosticHandler) {
> std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
> - ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler, false, true);
> + ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler, true);
>
> auto cleanupOnError = [&](std::error_code EC) {
> R.releaseBuffer(); // Never take ownership on error.
> @@ -6389,35 +6369,3 @@ bool llvm::hasGlobalValueSummary(MemoryB
> Buf.release(); // The ModuleSummaryIndexBitcodeReader owns it now.
> return R.foundGlobalValSummary();
> }
> -
> -// This method supports lazy reading of 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
> -// the index.
> -std::error_code llvm::readGlobalValueSummary(
> - MemoryBufferRef Buffer, DiagnosticHandlerFunction DiagnosticHandler,
> - StringRef ValueName, std::unique_ptr<ModuleSummaryIndex> Index) {
> - std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);
> - ModuleSummaryIndexBitcodeReader 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
> - // recorded when parsing the value symbol table.
> - for (const auto &FI : Index->getGlobalValueInfoList(ValueName)) {
> - size_t SummaryOffset = FI->bitcodeIndex();
> - if (std::error_code EC =
> - R.parseGlobalValueSummary(nullptr, Index.get(), SummaryOffset))
> - return cleanupOnError(EC);
> - }
> -
> - Buf.release(); // The ModuleSummaryIndexBitcodeReader owns it now.
> - return std::error_code();
> -}
>
> Modified: llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp?rev=267097&r1=267096&r2=267097&view=diff
> ==============================================================================
> --- llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp (original)
> +++ llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp Thu Apr 21 20:52:00 2016
> @@ -547,7 +547,7 @@ std::unique_ptr<ModuleSummaryIndex> Thin
> for (auto &ModuleBuffer : Modules) {
> ErrorOr<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
> object::ModuleSummaryIndexObjectFile::create(ModuleBuffer,
> - diagnosticHandler, false);
> + diagnosticHandler);
> if (std::error_code EC = ObjOrErr.getError()) {
> // FIXME diagnose
> errs() << "error: can't create ModuleSummaryIndexObjectFile for buffer: "
>
> Modified: llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp?rev=267097&r1=267096&r2=267097&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp Thu Apr 21 20:52:00 2016
> @@ -83,8 +83,7 @@ bool ModuleSummaryIndexObjectFile::hasGl
> // module summary/index.
> ErrorOr<std::unique_ptr<ModuleSummaryIndexObjectFile>>
> ModuleSummaryIndexObjectFile::create(
> - MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler,
> - bool IsLazy) {
> + MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler) {
> std::unique_ptr<ModuleSummaryIndex> Index;
>
> ErrorOr<MemoryBufferRef> BCOrErr = findBitcodeInMemBuffer(Object);
> @@ -92,7 +91,7 @@ ModuleSummaryIndexObjectFile::create(
> return BCOrErr.getError();
>
> ErrorOr<std::unique_ptr<ModuleSummaryIndex>> IOrErr =
> - getModuleSummaryIndex(BCOrErr.get(), DiagnosticHandler, IsLazy);
> + getModuleSummaryIndex(BCOrErr.get(), DiagnosticHandler);
>
> if (std::error_code EC = IOrErr.getError())
> return EC;
> @@ -103,23 +102,6 @@ ModuleSummaryIndexObjectFile::create(
> std::move(Index));
> }
>
> -// Parse the summary information for value 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(
> - MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler,
> - StringRef ValueName) {
> - 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));
> - }
> - default:
> - return object_error::invalid_file_type;
> - }
> -}
> -
> // Parse the module summary index out of an IR file and return the summary
> // index object if found, or nullptr if not.
> ErrorOr<std::unique_ptr<ModuleSummaryIndex>> llvm::getModuleSummaryIndexForFile(
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list