Skip to content

[mlir][NFC] Remove internal linkage from reshape op helper templates - #214759

Merged
flash1729 merged 1 commit into
llvm:mainfrom
flash1729:wunused-template-mlir-reshape
Aug 12, 2026
Merged

flash1729 merged 1 commit into
llvm:mainfrom
flash1729:wunused-template-mlir-reshape

Conversation

@flash1729

Copy link
Copy Markdown
Member

Another case of the cleanup done for #208001, which enabled -Wunused-template under -Wall. Both helpers are static in ReshapeOpsUtils.h, which reaches many TUs via Linalg.h, Tensor.h and MemRef.h, so clang warns wherever they are not instantiated. Dropping static gives them vague linkage.

Another case of the cleanup done for llvm#208001, which enabled -Wunused-template
under -Wall. Both helpers are `static` in ReshapeOpsUtils.h, which reaches many
TUs via Linalg.h, Tensor.h and MemRef.h, so clang warns wherever they are not
instantiated. Dropping `static` gives them vague linkage.
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-mlir

Author: Aditya Medhane (flash1729)

Changes

Another case of the cleanup done for #208001, which enabled -Wunused-template under -Wall. Both helpers are static in ReshapeOpsUtils.h, which reaches many TUs via Linalg.h, Tensor.h and MemRef.h, so clang warns wherever they are not instantiated. Dropping static gives them vague linkage.


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

1 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h (+4-4)
diff --git a/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h b/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h
index 2e8c0e269995e..6f58ed48fd64f 100644
--- a/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h
+++ b/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h
@@ -84,8 +84,8 @@ bool isReassociationValid(ArrayRef<AffineMap> reassociation,
                           int *invalidIndex = nullptr);
 
 template <typename ReshapeOpTy, typename InverseReshapeOpTy>
-static OpFoldResult foldReshapeOp(ReshapeOpTy reshapeOp,
-                                  ArrayRef<Attribute> operands) {
+OpFoldResult foldReshapeOp(ReshapeOpTy reshapeOp,
+                           ArrayRef<Attribute> operands) {
   // Fold identity reshape.
   if (reshapeOp.getSrcType() == reshapeOp.getType())
     return reshapeOp.getSrc();
@@ -140,8 +140,8 @@ static OpFoldResult foldReshapeOp(ReshapeOpTy reshapeOp,
 /// Common verifier for reshape-like types. Fills `expandedType` and
 ///`collapsedType` with the proper `src` or `result` type.
 template <typename Op, typename T>
-static LogicalResult verifyReshapeLikeTypes(Op op, T expandedType,
-                                            T collapsedType, bool isExpansion) {
+LogicalResult verifyReshapeLikeTypes(Op op, T expandedType, T collapsedType,
+                                     bool isExpansion) {
 
   unsigned expandedRank = expandedType.getRank();
   unsigned collapsedRank = collapsedType.getRank();

@makslevental makslevental left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the original intent of marking the templates static (since generally one doesn't use static in a header) so this LGTM.

@flash1729
flash1729 merged commit 1376072 into llvm:main Aug 12, 2026
12 checks passed
hulxv pushed a commit that referenced this pull request Aug 12, 2026
…214759)

Another case of the cleanup done for #208001, which enabled
-Wunused-template under -Wall. Both helpers are `static` in
ReshapeOpsUtils.h, which reaches many TUs via Linalg.h, Tensor.h and
MemRef.h, so clang warns wherever they are not instantiated. Dropping
`static` gives them vague linkage.
zhangweize9-cyber pushed a commit to zhangweize9-cyber/llvm-project that referenced this pull request Aug 16, 2026
…lvm#214759)

Another case of the cleanup done for llvm#208001, which enabled
-Wunused-template under -Wall. Both helpers are `static` in
ReshapeOpsUtils.h, which reaches many TUs via Linalg.h, Tensor.h and
MemRef.h, so clang warns wherever they are not instantiated. Dropping
`static` gives them vague linkage.
carlobertolli pushed a commit to carlobertolli/llvm-project that referenced this pull request Aug 18, 2026
…lvm#214759)

Another case of the cleanup done for llvm#208001, which enabled
-Wunused-template under -Wall. Both helpers are `static` in
ReshapeOpsUtils.h, which reaches many TUs via Linalg.h, Tensor.h and
MemRef.h, so clang warns wherever they are not instantiated. Dropping
`static` gives them vague linkage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants