[llvm] [AMDGPU][NewInsertWaitcnt] Add Event Tracker (PR #226970)
Sameer Sahasrabuddhe via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 11 00:29:34 PDT 2026
================
@@ -0,0 +1,277 @@
+//===- AMDGPUEventTracking.h ------------------------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file Tracks a per-InstCounterType event timeline which preserves
+/// information about previously encountered MachineInstr and HWEvents.
+///
+/// The goal of this file is to implement a minimal API to preserve information
+/// about events that increment an instruction counter. Such events are
+/// contained in records called \ref EventTrackerRecord, which include:
+/// - The event kind, as a `HWEvent`
+/// - The instruction that triggered the event
+/// - The height of the record in the overall timeline of the counter, see
+/// \ref EventTrackerRecord for more details.
+///
+/// The "timeline" represents the state of an InstCounterType at a
+/// given point in time for a given MBB during a reverse postorder dataflow
+/// analysis of a function. Such a dataflow analysis is expected to pass over
+/// blocks as many times as necessary until a "fix point" is reached, which is a
+/// state in which the client (the pass that uses the APIs) decides it has
+/// enough information to safely perform its duties (generally, inserting
+/// `s_waitcnt` instructions).
+///
+/// See \ref EventTracker for more information as well.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUEVENTTRACKING_H
+#define LLVM_LIB_TARGET_AMDGPU_AMDGPUEVENTTRACKING_H
+
+#include "AMDGPUHWEvents.h"
+#include "AMDGPUWaitcntUtils.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace llvm {
+class raw_ostream;
+class MachineBasicBlock;
+
+namespace AMDGPU {
+namespace eventtracking {
+
+class EventTracker;
+
+/// FIXME: Move this to a common file and make it a generic utility.
+///
+/// Represents target-specific information about available \ref InstCounterType
+/// and their specifities. This is handled by reference and is expected to
----------------
ssahasra wrote:
Is this constant for a given invocation of the pass, or even for the entire invocation of the compiler? Is it a static property of the target? Can it potentially be moved to a TD file? (we don't have to, but is it something that can be?
https://github.com/llvm/llvm-project/pull/226970
More information about the llvm-commits
mailing list