[llvm] 0f7fcb4 - Revert "Add an option to print out annotation remark count."

Zain Jaffal via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 7 15:42:36 PDT 2023


Author: Zain Jaffal
Date: 2023-04-07T23:42:24+01:00
New Revision: 0f7fcb4c670fbef2c25b835fdfdd29598c6c13ae

URL: https://github.com/llvm/llvm-project/commit/0f7fcb4c670fbef2c25b835fdfdd29598c6c13ae
DIFF: https://github.com/llvm/llvm-project/commit/0f7fcb4c670fbef2c25b835fdfdd29598c6c13ae.diff

LOG: Revert "Add an option to print out annotation remark count."

This reverts commit 7cc80ef5fa359b68ee85033f98b1bef1f37fb21c.

Added: 
    

Modified: 
    llvm/docs/CommandGuide/llvm-remarkutil.rst
    llvm/test/tools/llvm-remarkutil/broken-bitstream-remark.test
    llvm/test/tools/llvm-remarkutil/broken-yaml-remark.test
    llvm/test/tools/llvm-remarkutil/empty-file.test
    llvm/tools/llvm-remarkutil/RemarkUtil.cpp

Removed: 
    llvm/test/tools/llvm-remarkutil/Inputs/annotation-count.bitstream
    llvm/test/tools/llvm-remarkutil/Inputs/annotation-count.yaml
    llvm/test/tools/llvm-remarkutil/annotation-count.test
    llvm/test/tools/llvm-remarkutil/no-annotation-count.test


################################################################################
diff  --git a/llvm/docs/CommandGuide/llvm-remarkutil.rst b/llvm/docs/CommandGuide/llvm-remarkutil.rst
index f3ecb56cd666e..481774a6bd358 100644
--- a/llvm/docs/CommandGuide/llvm-remarkutil.rst
+++ b/llvm/docs/CommandGuide/llvm-remarkutil.rst
@@ -20,7 +20,7 @@ Subcommands
   * :ref:`bitstream2yaml_subcommand` - Reserialize bitstream remarks to YAML.
   * :ref:`yaml2bitstream_subcommand` - Reserialize YAML remarks to bitstream.
   * :ref:`instruction-count_subcommand` - Output function instruction counts.
-  * :ref:`annotation-count_subcommand` - Output remark type count from annotation remarks.
+
 .. _bitstream2yaml_subcommand:
 
 bitstream2yaml
@@ -72,24 +72,3 @@ CSV format is as follows:
 ::
   Function,InstructionCount
   foo,123
-
-annotation-count
-~~~~~~~~~~~~~~~~~
-
-.. program:: llvm-remarkutil annotation-count
-
-USAGE: :program:`llvm-remarkutil` annotation-count <input file> --parser=<bitstream|yaml> --annotation-type=<type> -o <output file>
-
-Summary
-^^^^^^^
-
-Outputs a count for annotation-type `<type>` remark for every function. The count expresses
-the number of remark checks inserted at the function.
-
-Annotation count remarks require AnnotationRemarksPass remarks.
-
-CSV format is as follows:
-
-::
-  Function,Count
-  foo,123

diff  --git a/llvm/test/tools/llvm-remarkutil/Inputs/annotation-count.bitstream b/llvm/test/tools/llvm-remarkutil/Inputs/annotation-count.bitstream
deleted file mode 100644
index feb19692cea63..0000000000000
Binary files a/llvm/test/tools/llvm-remarkutil/Inputs/annotation-count.bitstream and /dev/null 
diff er

diff  --git a/llvm/test/tools/llvm-remarkutil/Inputs/annotation-count.yaml b/llvm/test/tools/llvm-remarkutil/Inputs/annotation-count.yaml
deleted file mode 100644
index f29808a7772cf..0000000000000
--- a/llvm/test/tools/llvm-remarkutil/Inputs/annotation-count.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
---- !Analysis
-Pass:            annotation-remarks
-Name:            AnnotationSummary
-Function:        func1 
-Args:
-  - String:          'Annotated '
-  - count:           '1'
-  - String:          ' instructions with '
-  - type:            remark
---- !Analysis
-Pass:            annotation-remarks
-Name:            AnnotationSummary
-Function:        func2 
-Args:
-  - String:          'Annotated '
-  - count:           '2'
-  - String:          ' instructions with '
-  - type:            remark
---- !Analysis
-Pass:            annotation-remarks
-Name:            AnnotationSummary
-Function:        func3
-Args:
-  - String:          'Annotated '
-  - count:           '3'
-  - String:          ' instructions with '
-  - type:            remark

diff  --git a/llvm/test/tools/llvm-remarkutil/annotation-count.test b/llvm/test/tools/llvm-remarkutil/annotation-count.test
deleted file mode 100644
index 73582402201dc..0000000000000
--- a/llvm/test/tools/llvm-remarkutil/annotation-count.test
+++ /dev/null
@@ -1,7 +0,0 @@
-RUN: llvm-remarkutil annotation-count --parser=yaml --annotation-type=remark %p/Inputs/annotation-count.yaml | FileCheck %s
-RUN: llvm-remarkutil yaml2bitstream %p/Inputs/annotation-count.yaml | llvm-remarkutil annotation-count --parser=bitstream --annotation-type=remark | FileCheck %s
-
-; CHECK-LABEL: Function,Count
-; CHECK: func1,1
-; CHECK: func2,2
-; CHECK: func3,3

diff  --git a/llvm/test/tools/llvm-remarkutil/broken-bitstream-remark.test b/llvm/test/tools/llvm-remarkutil/broken-bitstream-remark.test
index 515c096f540eb..9f37c57f4f034 100644
--- a/llvm/test/tools/llvm-remarkutil/broken-bitstream-remark.test
+++ b/llvm/test/tools/llvm-remarkutil/broken-bitstream-remark.test
@@ -1,4 +1,3 @@
 RUN: not llvm-remarkutil bitstream2yaml %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s
 RUN: not llvm-remarkutil instruction-count --parser=bitstream %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s
-RUN: not llvm-remarkutil annotation-count --parser=bitstream --annotation-type=remark %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s
 CHECK: error: Unknown magic number: expecting RMRK, got --- .

diff  --git a/llvm/test/tools/llvm-remarkutil/broken-yaml-remark.test b/llvm/test/tools/llvm-remarkutil/broken-yaml-remark.test
index df87e3db80442..764a839fc0fb8 100644
--- a/llvm/test/tools/llvm-remarkutil/broken-yaml-remark.test
+++ b/llvm/test/tools/llvm-remarkutil/broken-yaml-remark.test
@@ -1,4 +1,3 @@
 RUN: not llvm-remarkutil yaml2bitstream %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s
 RUN: not llvm-remarkutil instruction-count --parser=yaml %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s
-RUN: not llvm-remarkutil annotation-count --parser=yaml --annotation-type=remark %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s
 CHECK: error: Type, Pass, Name or Function missing

diff  --git a/llvm/test/tools/llvm-remarkutil/empty-file.test b/llvm/test/tools/llvm-remarkutil/empty-file.test
index aa2ee41dd70bd..67dfea4bc7803 100644
--- a/llvm/test/tools/llvm-remarkutil/empty-file.test
+++ b/llvm/test/tools/llvm-remarkutil/empty-file.test
@@ -1,9 +1,7 @@
 RUN: not llvm-remarkutil yaml2bitstream %p/Inputs/empty-file -o - 2>&1 | FileCheck %s --check-prefix=YAMLPARSER
 RUN: not llvm-remarkutil instruction-count --parser=yaml %p/Inputs/empty-file -o - 2>&1 | FileCheck %s --check-prefix=YAMLPARSER
-RUN: not llvm-remarkutil annotation-count --parser=yaml --annotation-type=remark %p/Inputs/empty-file -o - 2>&1 | FileCheck %s --check-prefix=YAMLPARSER
 RUN: llvm-remarkutil bitstream2yaml %p/Inputs/empty-file -o - 2>&1 | FileCheck %s --allow-empty --check-prefix=BITSTREAM2YAML
 RUN: llvm-remarkutil instruction-count --parser=bitstream %p/Inputs/empty-file -o - 2>&1 | FileCheck %s --allow-empty --check-prefix=SIZEBITSTREAM
-RUN: llvm-remarkutil annotation-count --parser=bitstream --annotation-type=remark %p/Inputs/empty-file -o - 2>&1 | FileCheck %s --allow-empty --check-prefix=ANNOTATIONBITSTREAM
 
 ; YAMLPARSER: error: document root is not of mapping type.
 
@@ -11,7 +9,4 @@ RUN: llvm-remarkutil annotation-count --parser=bitstream --annotation-type=remar
 ; BITSTREAM2YAML-NOT: error
 
 ; SIZEBITSTREAM-LABEL: Function,InstructionCount
-; SIZEBITSTREAM-EMPTY:
-
-; ANNOTATIONBITSTREAM-LABEL: Function,Count
-; ANNOTATIONBITSTREAM-EMPTY: 
+; SIZEBITSTREAM-EMPTY

diff  --git a/llvm/test/tools/llvm-remarkutil/no-annotation-count.test b/llvm/test/tools/llvm-remarkutil/no-annotation-count.test
deleted file mode 100644
index 9571bf760824d..0000000000000
--- a/llvm/test/tools/llvm-remarkutil/no-annotation-count.test
+++ /dev/null
@@ -1,5 +0,0 @@
-RUN: llvm-remarkutil annotation-count --parser=yaml --annotation-type=remark %p/Inputs/made-up-fake-remarks.yaml | FileCheck %s
-RUN: llvm-remarkutil yaml2bitstream %p/Inputs/made-up-fake-remarks.yaml | llvm-remarkutil annotation-count --parser=bitstream --annotation-type=remark | FileCheck %s
-
-; CHECK-LABEL: Function,Count
-; CHECK-EMPTY:

diff  --git a/llvm/tools/llvm-remarkutil/RemarkUtil.cpp b/llvm/tools/llvm-remarkutil/RemarkUtil.cpp
index 004229c567dd2..0412eae954ac9 100644
--- a/llvm/tools/llvm-remarkutil/RemarkUtil.cpp
+++ b/llvm/tools/llvm-remarkutil/RemarkUtil.cpp
@@ -38,10 +38,6 @@ static cl::SubCommand
 static cl::SubCommand InstructionCount(
     "instruction-count",
     "Function instruction count information (requires asm-printer remarks)");
-static cl::SubCommand
-    AnnotationCount("annotation-count",
-                    "Collect count information from annotation remarks (uses "
-                    "AnnotationRemarksPass)");
 } // namespace subopts
 
 // Keep input + output help + names consistent across the various modes via a
@@ -53,14 +49,6 @@ static cl::SubCommand
   static cl::opt<std::string> OutputFileName(                                  \
       "o", cl::init("-"), cl::cat(RemarkUtilCategory), cl::desc("Output"),     \
       cl::value_desc("filename"), cl::sub(SUBOPT));
-
-// Keep Input format and names consistent accross the modes via a macro.
-#define INPUT_FORMAT_COMMAND_LINE_OPTIONS(SUBOPT)                              \
-  static cl::opt<Format> InputFormat(                                          \
-      "parser", cl::desc("Input remark format to parse"),                      \
-      cl::values(clEnumValN(Format::YAML, "yaml", "YAML"),                     \
-                 clEnumValN(Format::Bitstream, "bitstream", "Bitstream")),     \
-      cl::sub(SUBOPT));
 namespace yaml2bitstream {
 /// Remark format to parse.
 static constexpr Format InputFormat = Format::YAML;
@@ -78,18 +66,14 @@ INPUT_OUTPUT_COMMAND_LINE_OPTIONS(subopts::Bitstream2YAML)
 } // namespace bitstream2yaml
 
 namespace instructioncount {
-INPUT_FORMAT_COMMAND_LINE_OPTIONS(subopts::InstructionCount)
+static cl::opt<Format> InputFormat(
+    "parser", cl::desc("Input remark format to parse"),
+    cl::values(clEnumValN(Format::YAML, "yaml", "YAML"),
+               clEnumValN(Format::Bitstream, "bitstream", "Bitstream")),
+    cl::sub(subopts::InstructionCount));
 INPUT_OUTPUT_COMMAND_LINE_OPTIONS(subopts::InstructionCount)
 } // namespace instructioncount
 
-namespace annotationcount {
-INPUT_FORMAT_COMMAND_LINE_OPTIONS(subopts::AnnotationCount)
-static cl::opt<std::string> AnnotationTypeToCollect(
-    "annotation-type", cl::desc("annotation-type remark to collect count for"),
-    cl::sub(subopts::AnnotationCount));
-INPUT_OUTPUT_COMMAND_LINE_OPTIONS(subopts::AnnotationCount)
-} // namespace annotationcount
-
 /// \returns A MemoryBuffer for the input file on success, and an Error
 /// otherwise.
 static Expected<std::unique_ptr<MemoryBuffer>>
@@ -270,51 +254,6 @@ static Error tryInstructionCount() {
 }
 } // namespace instructioncount
 
-namespace annotationcount {
-static Error tryAnnotationCount() {
-  // Create the output buffer.
-  auto MaybeOF = getOutputFileWithFlags(OutputFileName,
-                                        /*Flags = */ sys::fs::OF_TextWithCRLF);
-  if (!MaybeOF)
-    return MaybeOF.takeError();
-  auto OF = std::move(*MaybeOF);
-  // Create a parser for the user-specified input format.
-  auto MaybeBuf = getInputMemoryBuffer(InputFileName);
-  if (!MaybeBuf)
-    return MaybeBuf.takeError();
-  auto MaybeParser = createRemarkParser(InputFormat, (*MaybeBuf)->getBuffer());
-  if (!MaybeParser)
-    return MaybeParser.takeError();
-  // Emit CSV header.
-  OF->os() << "Function,Count\n";
-  // Parse all remarks. When we see the specified remark collect the count
-  // information.
-  auto &Parser = **MaybeParser;
-  auto MaybeRemark = Parser.next();
-  for (; MaybeRemark; MaybeRemark = Parser.next()) {
-    auto &Remark = **MaybeRemark;
-    if (Remark.RemarkName != "AnnotationSummary")
-      continue;
-    auto *RemarkNameArg = find_if(Remark.Args, [](const Argument &Arg) {
-      return Arg.Key == "type" && Arg.Val == AnnotationTypeToCollect;
-    });
-    if (RemarkNameArg == Remark.Args.end())
-      continue;
-    auto *CountArg = find_if(
-        Remark.Args, [](const Argument &Arg) { return Arg.Key == "count"; });
-    assert(CountArg != Remark.Args.end() &&
-           "Expected annotation-type remark to have a count key?");
-    OF->os() << Remark.FunctionName << "," << CountArg->Val << "\n";
-  }
-  auto E = MaybeRemark.takeError();
-  if (!E.isA<EndOfFileError>())
-    return E;
-  consumeError(std::move(E));
-  OF->keep();
-  return Error::success();
-}
-
-} // namespace annotationcount
 /// Handle user-specified suboptions (e.g. yaml2bitstream, bitstream2yaml).
 /// \returns An Error if the specified suboption fails or if no suboption was
 /// specified. Otherwise, Error::success().
@@ -325,9 +264,6 @@ static Error handleSuboptions() {
     return yaml2bitstream::tryYAML2Bitstream();
   if (subopts::InstructionCount)
     return instructioncount::tryInstructionCount();
-  if (subopts::AnnotationCount)
-    return annotationcount::tryAnnotationCount();
-
   return make_error<StringError>(
       "Please specify a subcommand. (See -help for options)",
       inconvertibleErrorCode());


        


More information about the llvm-commits mailing list