[llvm] [AMDGPU][NewInsertWaitcnts] Boilerplate for the new wait insertion pass (PR #226335)
Pierre van Houtryve via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 02:05:31 PDT 2026
================
@@ -0,0 +1,78 @@
+//===- AMDGPUNewInsertWaitcnts.cpp - Wait Instruction Insertion Pass ------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// A wait insertion pass for AMDGPU.
+//
+//===----------------------------------------------------------------------===//
+
+#include "AMDGPUNewInsertWaitcnts.h"
+#include "AMDGPU.h"
+#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
+
+using namespace llvm;
+using namespace llvm::AMDGPU;
+
+#define DEBUG_TYPE "amdgpu-new-insert-waitcnts"
+
+namespace {
+
+class AMDGPUNewInsertWaitcntsLegacy : public MachineFunctionPass {
+ InsertWaitcnts IW;
+
+public:
+ static char ID;
+
+ AMDGPUNewInsertWaitcntsLegacy() : MachineFunctionPass(ID) {}
+
+ bool runOnMachineFunction(MachineFunction &MF) override { return IW.run(MF); }
+
+ StringRef getPassName() const override { return "AMDGPU New Wait Insertion"; }
+
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.setPreservesAll();
+ MachineFunctionPass::getAnalysisUsage(AU);
+ }
+};
+
+} // end anonymous namespace
+
+INITIALIZE_PASS(AMDGPUNewInsertWaitcntsLegacy, DEBUG_TYPE,
+ "AMDGPU New Insert Waitcnts", false, false)
+
+char AMDGPUNewInsertWaitcntsLegacy::ID = 0;
+
+char &llvm::AMDGPUNewInsertWaitcntsID = AMDGPUNewInsertWaitcntsLegacy::ID;
+
+FunctionPass *llvm::createAMDGPUNewInsertWaitcntsPass() {
+ return new AMDGPUNewInsertWaitcntsLegacy();
+}
+
+PreservedAnalyses
+AMDGPUNewInsertWaitcntsPass::run(MachineFunction &MF,
+ MachineFunctionAnalysisManager &MFAM) {
+ if (!IW.run(MF))
+ return PreservedAnalyses::all();
+ // Same as the original pass.
----------------
Pierre-vh wrote:
```suggestion
```
No need to mention that, it should exist in isolation on its own two feet without callbacks to InsertWaitcnt
Anything we port over needs to be studied and we should explain why it's needed, not use `SIInsertWaitcnt` did it as a justification :)
https://github.com/llvm/llvm-project/pull/226335
More information about the llvm-commits
mailing list