[llvm-branch-commits] [llvm-remarkutil] Introduce summary tool (PR #160549)
Jon Roelofs via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Sep 24 09:32:49 PDT 2025
================
@@ -0,0 +1,244 @@
+//===- RemarkSummary.cpp --------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Specialized tool to summarize remarks
+//
+//===----------------------------------------------------------------------===//
+
+#include "RemarkUtilHelpers.h"
+#include "RemarkUtilRegistry.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/Regex.h"
+#include "llvm/Support/WithColor.h"
+#include <memory>
+
+using namespace llvm;
+using namespace remarks;
+using namespace llvm::remarkutil;
+
+namespace summary {
+
+static cl::SubCommand
+ SummarySub("summary", "Summarize Remarks using different strategies.");
+
+INPUT_FORMAT_COMMAND_LINE_OPTIONS(SummarySub)
+OUTPUT_FORMAT_COMMAND_LINE_OPTIONS(SummarySub)
+INPUT_OUTPUT_COMMAND_LINE_OPTIONS(SummarySub)
+
+static cl::OptionCategory SummaryStrategyCat("Strategy options");
+
+enum class KeepMode { None, Used, All };
+
+static cl::opt<KeepMode> KeepInputOpt(
+ "keep", cl::desc("Keep input remarks in output"), cl::init(KeepMode::None),
+ cl::values(clEnumValN(KeepMode::None, "none",
+ "Don't keep input remarks (default)"),
+ clEnumValN(KeepMode::Used, "used",
+ "Keep only remarks used for summary"),
+ clEnumValN(KeepMode::All, "all", "Keep all input remarks")),
+ cl::sub(SummarySub));
+
+static cl::opt<bool>
+ IgnoreMalformedOpt("ignore-malformed",
+ cl::desc("Ignore remarks that fail to process"),
+ cl::init(false), cl::Hidden, cl::sub(SummarySub));
+
+// Use one cl::opt per Strategy, because future strategies might need to take
+// per-strategy parameters.
+static cl::opt<bool> EnableInlineSummaryOpt(
----------------
jroelofs wrote:
wdyt about making this a `cl::list<std::unique_ptr<SummaryStrategy>>`? I think that would nicely support repeated summaries, like an optimization pipeline of sorts.
https://github.com/llvm/llvm-project/pull/160549
More information about the llvm-branch-commits
mailing list