Skip to content

[mlir]Moves the StateStack to IR folder from Support folder. #145598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025

Conversation

wang2yn84
Copy link
Contributor

@wang2yn84 wang2yn84 commented Jun 24, 2025

[MLIR] Fix circular dependency introduced in In #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.

This change improves build performance and reduces compilation issues.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir:llvm mlir labels Jun 24, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 24, 2025

@llvm/pr-subscribers-flang-fir-hlfir
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-core

Author: Lance Wang (wang2yn84)

Changes

In #144897, the StackState file is created in Support folder. However, it depends on the IR folder which forms a circular dependency. This PR is to break the dependency.


Full diff: https://github.com/llvm/llvm-project/pull/145598.diff

5 Files Affected:

  • (renamed) mlir/include/mlir/IR/StateStack.h (+3-3)
  • (modified) mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h (+1-1)
  • (modified) mlir/lib/IR/CMakeLists.txt (+1)
  • (renamed) mlir/lib/IR/StateStack.cpp (+1-1)
  • (modified) mlir/lib/Support/CMakeLists.txt (-1)
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

@llvmbot
Copy link
Member

llvmbot commented Jun 24, 2025

@llvm/pr-subscribers-mlir-llvm

Author: Lance Wang (wang2yn84)

Changes

In #144897, the StackState file is created in Support folder. However, it depends on the IR folder which forms a circular dependency. This PR is to break the dependency.


Full diff: https://github.com/llvm/llvm-project/pull/145598.diff

5 Files Affected:

  • (renamed) mlir/include/mlir/IR/StateStack.h (+3-3)
  • (modified) mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h (+1-1)
  • (modified) mlir/lib/IR/CMakeLists.txt (+1)
  • (renamed) mlir/lib/IR/StateStack.cpp (+1-1)
  • (modified) mlir/lib/Support/CMakeLists.txt (-1)
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

itf added a commit to itf/llvm-project that referenced this pull request Jun 24, 2025
itf added a commit to itf/llvm-project that referenced this pull request Jun 24, 2025
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Jun 24, 2025
@wang2yn84 wang2yn84 force-pushed the lance-dev branch 2 times, most recently from 75680f8 to cedf9bb Compare June 25, 2025 00:13
@llvmbot llvmbot added the bazel "Peripheral" support tier build system: utils/bazel label Jun 25, 2025
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.

This change improves build performance and reduces compilation issues.
@itf itf merged commit 77af8bf into llvm:main Jun 25, 2025
7 checks passed
Copy link

@wang2yn84 Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@ftynse
Copy link
Member

ftynse commented Jun 25, 2025

Thank you for the hotfix. The proper way of action would have been to revert the PR in question, or at least notify the author of the problem.

anthonyhatran pushed a commit to anthonyhatran/llvm-project that referenced this pull request Jun 26, 2025
…5598)

[MLIR] Fix circular dependency introduced in In
llvm#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel flang:fir-hlfir flang Flang issues not falling into any other category mlir:core MLIR Core Infrastructure mlir:llvm mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants