<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 4, 2016 at 4:18 PM, Justin Bogner <span dir="ltr"><<a href="mailto:mail@justinbogner.com" target="_blank">mail@justinbogner.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Teresa Johnson via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> writes:<br>
> Author: tejohnson<br>
> Date: Thu Apr 21 20:52:00 2016<br>
> New Revision: 267097<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=267097&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=267097&view=rev</a><br>
> Log:<br>
> [ThinLTO] Remove unused/incomplete lazy summary reading support (NFC)<br>
><br>
> This removes the interfaces added (and not yet complete) to support<br>
> lazy reading of summaries. This support is not expected to be needed<br>
> since we are moving to a model where the full index is only being<br>
> traversed in the thin link step, instead of the back ends.<br>
<br>
</span>This leaves ModuleSummaryIndexBitcodeReader::parseGlobalValueSummary<br>
unused. Should it be removed too?<br></blockquote><div><br></div><div>Yes, missed that one. Will remove it too.</div><div>Thanks,</div><div>Teresa </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
> (The second part of this that I plan to do next is remove the<br>
> GlobalValueInfo from the ModuleSummaryIndex - it was mostly needed to<br>
> support lazy parsing of summaries. The index can instead reference the<br>
> summary structures directly.)<br>
><br>
> Modified:<br>
>     llvm/trunk/include/llvm/Bitcode/ReaderWriter.h<br>
>     llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h<br>
>     llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp<br>
>     llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp<br>
>     llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/Bitcode/ReaderWriter.h<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/ReaderWriter.h?rev=267097&r1=267096&r2=267097&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/ReaderWriter.h?rev=267097&r1=267096&r2=267097&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/Bitcode/ReaderWriter.h (original)<br>
> +++ llvm/trunk/include/llvm/Bitcode/ReaderWriter.h Thu Apr 21 20:52:00 2016<br>
> @@ -75,24 +75,9 @@ namespace llvm {<br>
>                               DiagnosticHandlerFunction DiagnosticHandler);<br>
><br>
>    /// Parse the specified bitcode buffer, returning the module summary index.<br>
> -  /// If IsLazy is true, parse the entire module summary into<br>
> -  /// the index. Otherwise skip the module summary section, and only create<br>
> -  /// an index object with a map from value name to the value's summary offset.<br>
> -  /// The index is used to perform lazy summary reading later.<br>
>    ErrorOr<std::unique_ptr<ModuleSummaryIndex>><br>
>    getModuleSummaryIndex(MemoryBufferRef Buffer,<br>
> -                        DiagnosticHandlerFunction DiagnosticHandler,<br>
> -                        bool IsLazy = false);<br>
> -<br>
> -  /// This method supports lazy reading of summary data from the<br>
> -  /// combined index during function importing. When reading the combined index<br>
> -  /// file, getModuleSummaryIndex is first invoked with IsLazy=true.<br>
> -  /// Then this method is called for each value considered for importing,<br>
> -  /// to parse the summary information for the given value name into<br>
> -  /// the index.<br>
> -  std::error_code readGlobalValueSummary(<br>
> -      MemoryBufferRef Buffer, DiagnosticHandlerFunction DiagnosticHandler,<br>
> -      StringRef ValueName, std::unique_ptr<ModuleSummaryIndex> Index);<br>
> +                        DiagnosticHandlerFunction DiagnosticHandler);<br>
><br>
>    /// \brief Write the specified module to the specified raw output stream.<br>
>    ///<br>
><br>
> Modified: llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h?rev=267097&r1=267096&r2=267097&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h?rev=267097&r1=267096&r2=267097&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h (original)<br>
> +++ llvm/trunk/include/llvm/Object/ModuleSummaryIndexObjectFile.h Thu Apr 21 20:52:00 2016<br>
> @@ -89,16 +89,7 @@ public:<br>
>    /// Return new ModuleSummaryIndexObjectFile instance containing parsed module<br>
>    /// summary/index.<br>
>    static ErrorOr<std::unique_ptr<ModuleSummaryIndexObjectFile>><br>
> -  create(MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler,<br>
> -         bool IsLazy = false);<br>
> -<br>
> -  /// \brief Parse the summary information for global value with the<br>
> -  /// given name out of the given buffer. Parsed information is<br>
> -  /// stored on the index object saved in this object.<br>
> -  std::error_code<br>
> -  findGlobalValueSummaryInMemBuffer(MemoryBufferRef Object,<br>
> -                                    DiagnosticHandlerFunction DiagnosticHandler,<br>
> -                                    StringRef ValueName);<br>
> +  create(MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler);<br>
>  };<br>
>  }<br>
><br>
><br>
> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=267097&r1=267096&r2=267097&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=267097&r1=267096&r2=267097&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)<br>
> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu Apr 21 20:52:00 2016<br>
> @@ -430,14 +430,6 @@ class ModuleSummaryIndexBitcodeReader {<br>
>    std::unique_ptr<BitstreamReader> StreamFile;<br>
>    BitstreamCursor Stream;<br>
><br>
> -  /// \brief Used to indicate whether we are doing lazy parsing of summary data.<br>
> -  ///<br>
> -  /// If false, the summary section is fully parsed into the index during<br>
> -  /// the initial parse. Otherwise, if true, the caller is expected to<br>
> -  /// invoke \a readGlobalValueSummary for each summary needed, and the summary<br>
> -  /// section is thus parsed lazily.<br>
> -  bool IsLazy = false;<br>
> -<br>
>    /// Used to indicate whether caller only wants to check for the presence<br>
>    /// of the global value summary bitcode section. All blocks are skipped,<br>
>    /// but the SeenGlobalValSummary boolean is set.<br>
> @@ -483,9 +475,9 @@ public:<br>
><br>
>    ModuleSummaryIndexBitcodeReader(<br>
>        MemoryBuffer *Buffer, DiagnosticHandlerFunction DiagnosticHandler,<br>
> -      bool IsLazy = false, bool CheckGlobalValSummaryPresenceOnly = false);<br>
> +      bool CheckGlobalValSummaryPresenceOnly = false);<br>
>    ModuleSummaryIndexBitcodeReader(<br>
> -      DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy = false,<br>
> +      DiagnosticHandlerFunction DiagnosticHandler,<br>
>        bool CheckGlobalValSummaryPresenceOnly = false);<br>
>    ~ModuleSummaryIndexBitcodeReader() { freeState(); }<br>
><br>
> @@ -5512,14 +5504,14 @@ std::error_code ModuleSummaryIndexBitcod<br>
><br>
>  ModuleSummaryIndexBitcodeReader::ModuleSummaryIndexBitcodeReader(<br>
>      MemoryBuffer *Buffer, DiagnosticHandlerFunction DiagnosticHandler,<br>
> -    bool IsLazy, bool CheckGlobalValSummaryPresenceOnly)<br>
> -    : DiagnosticHandler(DiagnosticHandler), Buffer(Buffer), IsLazy(IsLazy),<br>
> +    bool CheckGlobalValSummaryPresenceOnly)<br>
> +    : DiagnosticHandler(DiagnosticHandler), Buffer(Buffer),<br>
>        CheckGlobalValSummaryPresenceOnly(CheckGlobalValSummaryPresenceOnly) {}<br>
><br>
>  ModuleSummaryIndexBitcodeReader::ModuleSummaryIndexBitcodeReader(<br>
> -    DiagnosticHandlerFunction DiagnosticHandler, bool IsLazy,<br>
> +    DiagnosticHandlerFunction DiagnosticHandler,<br>
>      bool CheckGlobalValSummaryPresenceOnly)<br>
> -    : DiagnosticHandler(DiagnosticHandler), Buffer(nullptr), IsLazy(IsLazy),<br>
> +    : DiagnosticHandler(DiagnosticHandler), Buffer(nullptr),<br>
>        CheckGlobalValSummaryPresenceOnly(CheckGlobalValSummaryPresenceOnly) {}<br>
><br>
>  void ModuleSummaryIndexBitcodeReader::freeState() { Buffer = nullptr; }<br>
> @@ -5606,7 +5598,6 @@ std::error_code ModuleSummaryIndexBitcod<br>
>          return error("Invalid record");<br>
>        unsigned ValueID = Record[0];<br>
>        uint64_t FuncOffset = Record[1];<br>
> -      assert(!IsLazy && "Lazy summary read only supported for combined index");<br>
>        std::unique_ptr<GlobalValueInfo> FuncInfo =<br>
>            llvm::make_unique<GlobalValueInfo>(FuncOffset);<br>
>        assert(!SourceFileName.empty());<br>
> @@ -5650,9 +5641,7 @@ std::error_code ModuleSummaryIndexBitcod<br>
>  // Parse just the blocks needed for building the index out of the module.<br>
>  // At the end of this routine the module Index is populated with a map<br>
>  // from global value name to GlobalValueInfo. The global value info contains<br>
> -// either the parsed summary information (when parsing summaries<br>
> -// eagerly), or just to the summary record's offset<br>
> -// if parsing lazily (IsLazy).<br>
> +// the parsed summary information (when parsing summaries eagerly).<br>
>  std::error_code ModuleSummaryIndexBitcodeReader::parseModule() {<br>
>    if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))<br>
>      return error("Invalid record");<br>
> @@ -5710,11 +5699,7 @@ std::error_code ModuleSummaryIndexBitcod<br>
>            return EC;<br>
>          SeenValueSymbolTable = true;<br>
>          SeenGlobalValSummary = true;<br>
> -        if (IsLazy) {<br>
> -          // Lazy parsing of summary info, skip it.<br>
> -          if (Stream.SkipBlock())<br>
> -            return error("Invalid record");<br>
> -        } else if (std::error_code EC = parseEntireSummary())<br>
> +        if (std::error_code EC = parseEntireSummary())<br>
>            return EC;<br>
>          break;<br>
>        case bitc::MODULE_STRTAB_BLOCK_ID:<br>
> @@ -6347,16 +6332,11 @@ std::string llvm::getBitcodeProducerStri<br>
>  }<br>
><br>
>  // Parse the specified bitcode buffer, returning the function info index.<br>
> -// If IsLazy is false, parse the entire function summary into<br>
> -// the index. Otherwise skip the function summary section, and only create<br>
> -// an index object with a map from function name to function summary offset.<br>
> -// The index is used to perform lazy function summary reading later.<br>
>  ErrorOr<std::unique_ptr<ModuleSummaryIndex>><br>
>  llvm::getModuleSummaryIndex(MemoryBufferRef Buffer,<br>
> -                            DiagnosticHandlerFunction DiagnosticHandler,<br>
> -                            bool IsLazy) {<br>
> +                            DiagnosticHandlerFunction DiagnosticHandler) {<br>
>    std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);<br>
> -  ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler, IsLazy);<br>
> +  ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler);<br>
><br>
>    auto Index = llvm::make_unique<ModuleSummaryIndex>();<br>
><br>
> @@ -6376,7 +6356,7 @@ llvm::getModuleSummaryIndex(MemoryBuffer<br>
>  bool llvm::hasGlobalValueSummary(MemoryBufferRef Buffer,<br>
>                                   DiagnosticHandlerFunction DiagnosticHandler) {<br>
>    std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);<br>
> -  ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler, false, true);<br>
> +  ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler, true);<br>
><br>
>    auto cleanupOnError = [&](std::error_code EC) {<br>
>      R.releaseBuffer(); // Never take ownership on error.<br>
> @@ -6389,35 +6369,3 @@ bool llvm::hasGlobalValueSummary(MemoryB<br>
>    Buf.release(); // The ModuleSummaryIndexBitcodeReader owns it now.<br>
>    return R.foundGlobalValSummary();<br>
>  }<br>
> -<br>
> -// This method supports lazy reading of summary data from the combined<br>
> -// index during ThinLTO function importing. When reading the combined index<br>
> -// file, getModuleSummaryIndex is first invoked with IsLazy=true.<br>
> -// Then this method is called for each value considered for importing,<br>
> -// to parse the summary information for the given value name into<br>
> -// the index.<br>
> -std::error_code llvm::readGlobalValueSummary(<br>
> -    MemoryBufferRef Buffer, DiagnosticHandlerFunction DiagnosticHandler,<br>
> -    StringRef ValueName, std::unique_ptr<ModuleSummaryIndex> Index) {<br>
> -  std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(Buffer, false);<br>
> -  ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler);<br>
> -<br>
> -  auto cleanupOnError = [&](std::error_code EC) {<br>
> -    R.releaseBuffer(); // Never take ownership on error.<br>
> -    return EC;<br>
> -  };<br>
> -<br>
> -  // Lookup the given value name in the GlobalValueMap, which may<br>
> -  // contain a list of global value infos in the case of a COMDAT. Walk through<br>
> -  // and parse each summary info at the summary offset<br>
> -  // recorded when parsing the value symbol table.<br>
> -  for (const auto &FI : Index->getGlobalValueInfoList(ValueName)) {<br>
> -    size_t SummaryOffset = FI->bitcodeIndex();<br>
> -    if (std::error_code EC =<br>
> -            R.parseGlobalValueSummary(nullptr, Index.get(), SummaryOffset))<br>
> -      return cleanupOnError(EC);<br>
> -  }<br>
> -<br>
> -  Buf.release(); // The ModuleSummaryIndexBitcodeReader owns it now.<br>
> -  return std::error_code();<br>
> -}<br>
><br>
> Modified: llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp?rev=267097&r1=267096&r2=267097&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp?rev=267097&r1=267096&r2=267097&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp (original)<br>
> +++ llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp Thu Apr 21 20:52:00 2016<br>
> @@ -547,7 +547,7 @@ std::unique_ptr<ModuleSummaryIndex> Thin<br>
>    for (auto &ModuleBuffer : Modules) {<br>
>      ErrorOr<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =<br>
>          object::ModuleSummaryIndexObjectFile::create(ModuleBuffer,<br>
> -                                                     diagnosticHandler, false);<br>
> +                                                     diagnosticHandler);<br>
>      if (std::error_code EC = ObjOrErr.getError()) {<br>
>        // FIXME diagnose<br>
>        errs() << "error: can't create ModuleSummaryIndexObjectFile for buffer: "<br>
><br>
> Modified: llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp?rev=267097&r1=267096&r2=267097&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp?rev=267097&r1=267096&r2=267097&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp (original)<br>
> +++ llvm/trunk/lib/Object/ModuleSummaryIndexObjectFile.cpp Thu Apr 21 20:52:00 2016<br>
> @@ -83,8 +83,7 @@ bool ModuleSummaryIndexObjectFile::hasGl<br>
>  // module summary/index.<br>
>  ErrorOr<std::unique_ptr<ModuleSummaryIndexObjectFile>><br>
>  ModuleSummaryIndexObjectFile::create(<br>
> -    MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler,<br>
> -    bool IsLazy) {<br>
> +    MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler) {<br>
>    std::unique_ptr<ModuleSummaryIndex> Index;<br>
><br>
>    ErrorOr<MemoryBufferRef> BCOrErr = findBitcodeInMemBuffer(Object);<br>
> @@ -92,7 +91,7 @@ ModuleSummaryIndexObjectFile::create(<br>
>      return BCOrErr.getError();<br>
><br>
>    ErrorOr<std::unique_ptr<ModuleSummaryIndex>> IOrErr =<br>
> -      getModuleSummaryIndex(BCOrErr.get(), DiagnosticHandler, IsLazy);<br>
> +      getModuleSummaryIndex(BCOrErr.get(), DiagnosticHandler);<br>
><br>
>    if (std::error_code EC = IOrErr.getError())<br>
>      return EC;<br>
> @@ -103,23 +102,6 @@ ModuleSummaryIndexObjectFile::create(<br>
>                                                           std::move(Index));<br>
>  }<br>
><br>
> -// Parse the summary information for value with the<br>
> -// given name out of the given buffer. Parsed information is<br>
> -// stored on the index object saved in this object.<br>
> -std::error_code ModuleSummaryIndexObjectFile::findGlobalValueSummaryInMemBuffer(<br>
> -    MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler,<br>
> -    StringRef ValueName) {<br>
> -  sys::fs::file_magic Type = sys::fs::identify_magic(Object.getBuffer());<br>
> -  switch (Type) {<br>
> -  case sys::fs::file_magic::bitcode: {<br>
> -    return readGlobalValueSummary(Object, DiagnosticHandler, ValueName,<br>
> -                                  std::move(Index));<br>
> -  }<br>
> -  default:<br>
> -    return object_error::invalid_file_type;<br>
> -  }<br>
> -}<br>
> -<br>
>  // Parse the module summary index out of an IR file and return the summary<br>
>  // index object if found, or nullptr if not.<br>
>  ErrorOr<std::unique_ptr<ModuleSummaryIndex>> llvm::getModuleSummaryIndexForFile(<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><span style="font-family:Times;font-size:medium"><table cellspacing="0" cellpadding="0"><tbody><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small"><td nowrap style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px">Teresa Johnson |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px"> Software Engineer |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |</td><td nowrap style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px"> 408-460-2413</td></tr></tbody></table></span></div>
</div></div>