[flang-commits] [flang] 77af8bf - [mlir]Moves the StateStack to IR folder from Support folder. (#145598)
via flang-commits
flang-commits at lists.llvm.org
Tue Jun 24 21:00:17 PDT 2025
Author: Lance Wang
Date: 2025-06-25T00:00:13-04:00
New Revision: 77af8bff97a0b20dac9ff9a95385d036da7d8ba5
URL: https://github.com/llvm/llvm-project/commit/77af8bff97a0b20dac9ff9a95385d036da7d8ba5
DIFF: https://github.com/llvm/llvm-project/commit/77af8bff97a0b20dac9ff9a95385d036da7d8ba5.diff
LOG: [mlir]Moves the StateStack to IR folder from Support folder. (#145598)
[MLIR] Fix circular dependency introduced in In
https://github.com/llvm/llvm-project/pull/144897. This PR is to break
the dependency. by moving StateStack to IR folder
This commit resolves a circular dependency issue between mlir/Support
and mlir/IR:
- Move StateStack.h and StateStack.cpp from Support to IR folder
- Update CMakeLists.txt files to reflect the new locations
- Update Bazel BUILD file to maintain correct dependencies
- Update includes in affected files (flang, Target/LLVMIR)
The circular dependency was caused by StateStack.h depending on
IR/Visitors.h
while other IR files depended on Support. Moving StateStack to IR
eliminates
this cycle while maintaining proper separation of concerns.
Added:
mlir/include/mlir/IR/StateStack.h
mlir/lib/IR/StateStack.cpp
Modified:
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/OpenMP/OpenMP.cpp
mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
mlir/lib/IR/CMakeLists.txt
mlir/lib/Support/CMakeLists.txt
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
Removed:
mlir/include/mlir/Support/StateStack.h
mlir/lib/Support/StateStack.cpp
################################################################################
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 8506b9a984e58..336a6f82319e6 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -68,8 +68,8 @@
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
+#include "mlir/IR/StateStack.h"
#include "mlir/Parser/Parser.h"
-#include "mlir/Support/StateStack.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringSet.h"
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 60b6366c184d4..8575d8cf352fd 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -39,7 +39,7 @@
#include "flang/Support/OpenMP-utils.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
-#include "mlir/Support/StateStack.h"
+#include "mlir/IR/StateStack.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Frontend/OpenMP/OMPConstants.h"
diff --git a/mlir/include/mlir/Support/StateStack.h b/mlir/include/mlir/IR/StateStack.h
similarity index 97%
rename from mlir/include/mlir/Support/StateStack.h
rename to mlir/include/mlir/IR/StateStack.h
index 44972fafe7fed..6a22e3b0d00a4 100644
--- a/mlir/include/mlir/Support/StateStack.h
+++ b/mlir/include/mlir/IR/StateStack.h
@@ -12,8 +12,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef MLIR_SUPPORT_STACKFRAME_H
-#define MLIR_SUPPORT_STACKFRAME_H
+#ifndef MLIR_IR_STACKFRAME_H
+#define MLIR_IR_STACKFRAME_H
#include "mlir/IR/Visitors.h"
#include "mlir/Support/TypeID.h"
@@ -125,4 +125,4 @@ struct isa_impl<T, ::mlir::StateStackFrame> {
};
} // namespace llvm
-#endif // MLIR_SUPPORT_STACKFRAME_H
+#endif // MLIR_IR_STACKFRAME_H
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index 79e8bb6add0da..197be5f30b5b0 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -16,9 +16,9 @@
#include "mlir/Dialect/LLVMIR/LLVMInterfaces.h"
#include "mlir/IR/Operation.h"
+#include "mlir/IR/StateStack.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/IR/Value.h"
-#include "mlir/Support/StateStack.h"
#include "mlir/Target/LLVMIR/Export.h"
#include "mlir/Target/LLVMIR/LLVMTranslationInterface.h"
#include "mlir/Target/LLVMIR/TypeToLLVM.h"
diff --git a/mlir/lib/IR/CMakeLists.txt b/mlir/lib/IR/CMakeLists.txt
index 4cabac185171c..997782df8c5f3 100644
--- a/mlir/lib/IR/CMakeLists.txt
+++ b/mlir/lib/IR/CMakeLists.txt
@@ -32,6 +32,7 @@ add_mlir_library(MLIRIR
PatternMatch.cpp
Region.cpp
RegionKindInterface.cpp
+ StateStack.cpp
SymbolTable.cpp
TensorEncoding.cpp
Types.cpp
diff --git a/mlir/lib/Support/StateStack.cpp b/mlir/lib/IR/StateStack.cpp
similarity index 92%
rename from mlir/lib/Support/StateStack.cpp
rename to mlir/lib/IR/StateStack.cpp
index a9bb3ffb2e1b0..22fdcd73c625b 100644
--- a/mlir/lib/Support/StateStack.cpp
+++ b/mlir/lib/IR/StateStack.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "mlir/Support/StateStack.h"
+#include "mlir/IR/StateStack.h"
namespace mlir {
diff --git a/mlir/lib/Support/CMakeLists.txt b/mlir/lib/Support/CMakeLists.txt
index 02b6c694a28fd..488decd52ae64 100644
--- a/mlir/lib/Support/CMakeLists.txt
+++ b/mlir/lib/Support/CMakeLists.txt
@@ -11,7 +11,6 @@ add_mlir_library(MLIRSupport
FileUtilities.cpp
InterfaceSupport.cpp
RawOstreamExtras.cpp
- StateStack.cpp
StorageUniquer.cpp
Timing.cpp
ToolUtilities.cpp
diff --git a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
index e7b289efc6e69..a0b72b9709695 100644
--- a/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -4845,11 +4845,7 @@ cc_library(
]),
hdrs = glob(["include/mlir/Support/*.h"]),
includes = ["include"],
- deps = [
- "//llvm:Support",
- "//mlir:IR",
- ],
-)
+ deps = ["//llvm:Support"],)
cc_library(
name = "Debug",
More information about the flang-commits
mailing list