[Mlir-commits] [mlir] [mlir][NFC] Move LLVM::ModuleTranslation::SaveStack to a shared header (PR #144897)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Thu Jun 19 11:34:27 PDT 2025
================
@@ -0,0 +1,116 @@
+//===- StateStack.h - Utility for storing a stack of state ------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines utilities for storing a stack of generic context.
+// The context can be arbitrary data, possibly including file-scoped types.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_SUPPORT_STACKFRAME_H
+#define MLIR_SUPPORT_STACKFRAME_H
+
+#include "mlir/IR/Visitors.h"
+#include "mlir/Support/TypeID.h"
+#include <memory>
+
+namespace mlir {
+
+/// Common CRTP base class for StateStack frames.
+class StateStackFrame {
+public:
+ virtual ~StateStackFrame() = default;
+ TypeID getTypeID() const { return typeID; }
+
+protected:
+ explicit StateStackFrame(TypeID typeID) : typeID(typeID) {}
+
+private:
+ const TypeID typeID;
+ virtual void anchor() {};
----------------
ftynse wrote:
There is a reason why this empty method was defined in a source file and not inlined: it forces vtables to be emitted to a single object file. Please keep that unless you can show it is no longer necessary across the matrix of supported compilers.
https://github.com/llvm/llvm-project/pull/144897
More information about the Mlir-commits
mailing list