[Mlir-commits] [mlir] [mlir] Add searchable remark history and query-based links (PR #237762)

Henrich Lauko llvmlistbot at llvm.org
Tue Nov 3 01:35:18 PST 2026


================
@@ -174,6 +183,71 @@ InFlightRemark::~InFlightRemark() {
 // Remark Engine
 //===----------------------------------------------------------------------===//
 
+struct RemarkEngine::RemarkHistory {
+  struct Entry {
+    RemarkId id;
+    RemarkKind kind;
+    Location location;
+    std::string name, category, subCategory, function;
+  };
+  std::vector<Entry> entries;
+};
+
+void RemarkEngine::enableHistory(bool enable) {
+  std::lock_guard<std::mutex> lock(historyMutex);
+  if (enable) {
+    if (!history)
+      history = std::make_unique<RemarkHistory>();
+  } else {
+    history.reset();
+  }
+  historyEnabled.store(enable, std::memory_order_release);
+}
+
+void RemarkEngine::clearHistory() {
+  std::lock_guard<std::mutex> lock(historyMutex);
+  if (history)
+    history->entries.clear();
+}
+
+SmallVector<RemarkId>
+RemarkEngine::findRemarks(const RemarkQuery &query) const {
+  SmallVector<RemarkId> result;
+  std::lock_guard<std::mutex> lock(historyMutex);
----------------
xlauko wrote:

This always takes the mutex, even when history is disabled. Check historyEnabled first, as report() does.

nit: use C++17 std::scoped_lock lock(historyMutex)

https://github.com/llvm/llvm-project/pull/237762


More information about the Mlir-commits mailing list