<div dir="ltr">Sorry for the break. Fixed the problem and recommitted at rL372478.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Sep 21, 2019 at 2:11 AM Amara Emerson <<a href="mailto:aemerson@apple.com" target="_blank">aemerson@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
This commit seems to have broken the Mac build/greendragon bots for a while: <a href="http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/2582" rel="noreferrer" target="_blank">http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/2582</a><br>
<br>
I’ve reverted it r372464.<br>
<br>
Thanks,<br>
Amara<br>
<br>
> On Sep 20, 2019, at 4:24 PM, Wei Mi via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
> <br>
> Author: wmi<br>
> Date: Fri Sep 20 16:24:50 2019<br>
> New Revision: 372439<br>
> <br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=372439&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=372439&view=rev</a><br>
> Log:<br>
> [SampleFDO] Expose an interface to return the size of a section or the size<br>
> of the profile for profile in ExtBinary format.<br>
> <br>
> Sometimes we want to limit the size of the profile by stripping some functions<br>
> with low sample count or by stripping some function names with small text size<br>
> from profile symbol list. That requires the profile reader to have the<br>
> interfaces returning the size of a section or the size of total profile. The<br>
> patch add those interfaces.<br>
> <br>
> At the same time, add some dump facility to show the size of each section.<br>
> <br>
> <br>
> Added:<br>
>    llvm/trunk/test/tools/llvm-profdata/show-prof-size.test<br>
> Modified:<br>
>    llvm/trunk/include/llvm/ProfileData/SampleProf.h<br>
>    llvm/trunk/include/llvm/ProfileData/SampleProfReader.h<br>
>    llvm/trunk/lib/ProfileData/SampleProfReader.cpp<br>
>    llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp<br>
> <br>
> Modified: llvm/trunk/include/llvm/ProfileData/SampleProf.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProf.h?rev=372439&r1=372438&r2=372439&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProf.h?rev=372439&r1=372438&r2=372439&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/ProfileData/SampleProf.h (original)<br>
> +++ llvm/trunk/include/llvm/ProfileData/SampleProf.h Fri Sep 20 16:24:50 2019<br>
> @@ -125,6 +125,22 @@ enum SecType {<br>
>   SecLBRProfile = SecFuncProfileFirst<br>
> };<br>
> <br>
> +static inline std::string getSecName(SecType Type) {<br>
> +  switch (Type) {<br>
> +  case SecInValid:<br>
> +    return "InvalidSection";<br>
> +  case SecProfSummary:<br>
> +    return "ProfileSummarySection";<br>
> +  case SecNameTable:<br>
> +    return "NameTableSection";<br>
> +  case SecProfileSymbolList:<br>
> +    return "ProfileSymbolListSection";<br>
> +  case SecLBRProfile:<br>
> +    return "LBRProfileSection";<br>
> +  }<br>
> +  llvm_unreachable("A SecType has no name for output");<br>
> +}<br>
> +<br>
> // Entry type of section header table used by SampleProfileExtBinaryBaseReader<br>
> // and SampleProfileExtBinaryBaseWriter.<br>
> struct SecHdrTableEntry {<br>
> <br>
> Modified: llvm/trunk/include/llvm/ProfileData/SampleProfReader.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProfReader.h?rev=372439&r1=372438&r2=372439&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProfReader.h?rev=372439&r1=372438&r2=372439&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/ProfileData/SampleProfReader.h (original)<br>
> +++ llvm/trunk/include/llvm/ProfileData/SampleProfReader.h Fri Sep 20 16:24:50 2019<br>
> @@ -333,6 +333,7 @@ public:<br>
>   /// It includes all the names that have samples either in outline instance<br>
>   /// or inline instance.<br>
>   virtual std::vector<StringRef> *getNameTable() { return nullptr; }<br>
> +  virtual bool dumpSectionInfo(raw_ostream &OS = dbgs()) { return false; };<br>
> <br>
> protected:<br>
>   /// Map every function to its associated profile.<br>
> @@ -504,6 +505,12 @@ public:<br>
> <br>
>   /// Read sample profiles in extensible format from the associated file.<br>
>   std::error_code read() override;<br>
> +<br>
> +  /// Get the total size of all \p Type sections.<br>
> +  uint64_t getSectionSize(SecType Type);<br>
> +  /// Get the total size of header and all sections.<br>
> +  uint64_t getFileSize();<br>
> +  virtual bool dumpSectionInfo(raw_ostream &OS = dbgs()) override;<br>
> };<br>
> <br>
> class SampleProfileReaderExtBinary : public SampleProfileReaderExtBinaryBase {<br>
> <br>
> Modified: llvm/trunk/lib/ProfileData/SampleProfReader.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProfReader.cpp?rev=372439&r1=372438&r2=372439&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProfReader.cpp?rev=372439&r1=372438&r2=372439&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ProfileData/SampleProfReader.cpp (original)<br>
> +++ llvm/trunk/lib/ProfileData/SampleProfReader.cpp Fri Sep 20 16:24:50 2019<br>
> @@ -667,6 +667,36 @@ std::error_code SampleProfileReaderExtBi<br>
>   return sampleprof_error::success;<br>
> }<br>
> <br>
> +uint64_t SampleProfileReaderExtBinaryBase::getSectionSize(SecType Type) {<br>
> +  for (auto &Entry : SecHdrTable) {<br>
> +    if (Entry.Type == Type)<br>
> +      return Entry.Size;<br>
> +  }<br>
> +  return 0;<br>
> +}<br>
> +<br>
> +uint64_t SampleProfileReaderExtBinaryBase::getFileSize() {<br>
> +  auto &LastEntry = SecHdrTable.back();<br>
> +  return LastEntry.Offset + LastEntry.Size;<br>
> +}<br>
> +<br>
> +bool SampleProfileReaderExtBinaryBase::dumpSectionInfo(raw_ostream &OS) {<br>
> +  uint64_t TotalSecsSize = 0;<br>
> +  for (auto &Entry : SecHdrTable) {<br>
> +    OS << getSecName(Entry.Type) << " - Offset: " << Entry.Offset<br>
> +       << ", Size: " << Entry.Size << "\n";<br>
> +    TotalSecsSize += getSectionSize(Entry.Type);<br>
> +  }<br>
> +  uint64_t HeaderSize = SecHdrTable.front().Offset;<br>
> +  assert(HeaderSize + TotalSecsSize == getFileSize() &&<br>
> +         "Size of 'header + sections' doesn't match the total size of profile");<br>
> +<br>
> +  OS << "Header Size: " << HeaderSize << "\n";<br>
> +  OS << "Total Sections Size: " << TotalSecsSize << "\n";<br>
> +  OS << "File Size: " << getFileSize() << "\n";<br>
> +  return true;<br>
> +}<br>
> +<br>
> std::error_code SampleProfileReaderBinary::readMagicIdent() {<br>
>   // Read and check the magic identifier.<br>
>   auto Magic = readNumber<uint64_t>();<br>
> <br>
> Added: llvm/trunk/test/tools/llvm-profdata/show-prof-size.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/show-prof-size.test?rev=372439&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/show-prof-size.test?rev=372439&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/test/tools/llvm-profdata/show-prof-size.test (added)<br>
> +++ llvm/trunk/test/tools/llvm-profdata/show-prof-size.test Fri Sep 20 16:24:50 2019<br>
> @@ -0,0 +1,7 @@<br>
> +; RUN: llvm-profdata merge -sample -extbinary -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile.proftext -o %t.1.output<br>
> +; RUN: ls -l %t.1.output |cut -f5 -d ' ' > %t.txt<br>
> +; RUN: llvm-profdata show -sample -show-sec-info-only %t.1.output >> %t.txt<br>
> +; RUN: FileCheck %s --input-file=%t.txt<br>
> +; Check llvm-profdata shows the correct file size.<br>
> +; CHECK: [[FILESIZE:.*]]<br>
> +; CHECK: [[FILESIZE]]<br>
> <br>
> Modified: llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp?rev=372439&r1=372438&r2=372439&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp?rev=372439&r1=372438&r2=372439&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp (original)<br>
> +++ llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp Fri Sep 20 16:24:50 2019<br>
> @@ -982,10 +982,21 @@ static int showInstrProfile(const std::s<br>
>   return 0;<br>
> }<br>
> <br>
> +static void showSectionInfo(sampleprof::SampleProfileReader *Reader,<br>
> +                            raw_fd_ostream &OS) {<br>
> +  if (!Reader->dumpSectionInfo(OS)) {<br>
> +    WithColor::warning() << "-show-sec-info-only is only supported for "<br>
> +                         << "sample profile in extbinary format and is "<br>
> +                         << "ignored for other formats.\n";<br>
> +    return;<br>
> +  }<br>
> +}<br>
> +<br>
> static int showSampleProfile(const std::string &Filename, bool ShowCounts,<br>
>                              bool ShowAllFunctions,<br>
>                              const std::string &ShowFunction,<br>
> -                             bool ShowProfileSymbolList, raw_fd_ostream &OS) {<br>
> +                             bool ShowProfileSymbolList,<br>
> +                             bool ShowSectionInfoOnly, raw_fd_ostream &OS) {<br>
>   using namespace sampleprof;<br>
>   LLVMContext Context;<br>
>   auto ReaderOrErr = SampleProfileReader::create(Filename, Context);<br>
> @@ -993,6 +1004,12 @@ static int showSampleProfile(const std::<br>
>     exitWithErrorCode(EC, Filename);<br>
> <br>
>   auto Reader = std::move(ReaderOrErr.get());<br>
> +<br>
> +  if (ShowSectionInfoOnly) {<br>
> +    showSectionInfo(Reader.get(), OS);<br>
> +    return 0;<br>
> +  }<br>
> +<br>
>   if (std::error_code EC = Reader->read())<br>
>     exitWithErrorCode(EC, Filename);<br>
> <br>
> @@ -1062,6 +1079,11 @@ static int show_main(int argc, const cha<br>
>   cl::opt<bool> ShowProfileSymbolList(<br>
>       "show-prof-sym-list", cl::init(false),<br>
>       cl::desc("Show profile symbol list if it exists in the profile. "));<br>
> +  cl::opt<bool> ShowSectionInfoOnly(<br>
> +      "show-sec-info-only", cl::init(false),<br>
> +      cl::desc("Show the information of each section in the sample profile. "<br>
> +               "The flag is only usable when the sample profile is in "<br>
> +               "extbinary format"));<br>
> <br>
>   cl::ParseCommandLineOptions(argc, argv, "LLVM profile data summary\n");<br>
> <br>
> @@ -1090,7 +1112,8 @@ static int show_main(int argc, const cha<br>
>                             OnlyListBelow, ShowFunction, TextFormat, OS);<br>
>   else<br>
>     return showSampleProfile(Filename, ShowCounts, ShowAllFunctions,<br>
> -                             ShowFunction, ShowProfileSymbolList, OS);<br>
> +                             ShowFunction, ShowProfileSymbolList,<br>
> +                             ShowSectionInfoOnly, OS);<br>
> }<br>
> <br>
> int main(int argc, const char *argv[]) {<br>
> <br>
> <br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br>
</blockquote></div>