Skip to content
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

[NFC][MLIR] Make file-local cl::opt global variables static #126714

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

DanielAugusto191
Copy link
Contributor

Fix #125983.
We split it on some PR as suggested by @jurahul here #126243
This one is for MLIR. I also made it for clang, clang-tools-extra, lldb, and Polly projects, which will be in other PRs, but check this one first so that any comments may be valid for other projects too.

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 labels Feb 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 11, 2025

@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: Daniel (DanielAugusto191)

Changes

Fix #125983.
We split it on some PR as suggested by @jurahul here #126243
This one is for MLIR. I also made it for clang, clang-tools-extra, lldb, and Polly projects, which will be in other PRs, but check this one first so that any comments may be valid for other projects too.


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

5 Files Affected:

  • (modified) mlir/tools/mlir-rewrite/mlir-rewrite.cpp (+4-4)
  • (modified) mlir/tools/mlir-runner/mlir-runner.cpp (+1-1)
  • (modified) mlir/tools/mlir-tblgen/DialectGen.cpp (+1-1)
  • (modified) mlir/tools/mlir-tblgen/OpDocGen.cpp (+2-2)
  • (modified) mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp (+1-1)
diff --git a/mlir/tools/mlir-rewrite/mlir-rewrite.cpp b/mlir/tools/mlir-rewrite/mlir-rewrite.cpp
index bbb6bd6617a13c5..87df9e19d18425a 100644
--- a/mlir/tools/mlir-rewrite/mlir-rewrite.cpp
+++ b/mlir/tools/mlir-rewrite/mlir-rewrite.cpp
@@ -348,11 +348,11 @@ static mlir::RewriterRegistration
     rewriteMarkRanges("mark-ranges", "Indicate ranges parsed", markRanges);
 
 int main(int argc, char **argv) {
-  static llvm::cl::opt<std::string> inputFilename(
-      llvm::cl::Positional, llvm::cl::desc("<input file>"),
-      llvm::cl::init("-"));
+  llvm::cl::opt<std::string> inputFilename(llvm::cl::Positional,
+                                           llvm::cl::desc("<input file>"),
+                                           llvm::cl::init("-"));
 
-  static llvm::cl::opt<std::string> outputFilename(
+  llvm::cl::opt<std::string> outputFilename(
       "o", llvm::cl::desc("Output filename"), llvm::cl::value_desc("filename"),
       llvm::cl::init("-"));
 
diff --git a/mlir/tools/mlir-runner/mlir-runner.cpp b/mlir/tools/mlir-runner/mlir-runner.cpp
index 7e8793de03ead90..932c9f6cc9fdce4 100644
--- a/mlir/tools/mlir-runner/mlir-runner.cpp
+++ b/mlir/tools/mlir-runner/mlir-runner.cpp
@@ -32,7 +32,7 @@ using namespace mlir;
 // TODO: Consider removing this linking functionality from the SPIR-V CPU Runner
 //       flow in favour of a more proper host/device split like other runners.
 //       https://github.com/llvm/llvm-project/issues/115348
-llvm::cl::opt<bool> LinkNestedModules(
+static llvm::cl::opt<bool> LinkNestedModules(
     "link-nested-modules",
     llvm::cl::desc("Link two nested MLIR modules into a single LLVM IR module. "
                    "Useful if both the host and device code can be run on the "
diff --git a/mlir/tools/mlir-tblgen/DialectGen.cpp b/mlir/tools/mlir-tblgen/DialectGen.cpp
index 414cad5e1dcc2e7..6cf71d2bb017414 100644
--- a/mlir/tools/mlir-tblgen/DialectGen.cpp
+++ b/mlir/tools/mlir-tblgen/DialectGen.cpp
@@ -34,7 +34,7 @@ using llvm::Record;
 using llvm::RecordKeeper;
 
 static llvm::cl::OptionCategory dialectGenCat("Options for -gen-dialect-*");
-llvm::cl::opt<std::string>
+static llvm::cl::opt<std::string>
     selectedDialect("dialect", llvm::cl::desc("The dialect to gen for"),
                     llvm::cl::cat(dialectGenCat), llvm::cl::CommaSeparated);
 
diff --git a/mlir/tools/mlir-tblgen/OpDocGen.cpp b/mlir/tools/mlir-tblgen/OpDocGen.cpp
index 1c394f5680a5c9b..119be06de0df213 100644
--- a/mlir/tools/mlir-tblgen/OpDocGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDocGen.cpp
@@ -44,11 +44,11 @@ using mlir::tblgen::Operator;
 //===----------------------------------------------------------------------===//
 static cl::OptionCategory
     docCat("Options for -gen-(attrdef|typedef|enum|op|dialect)-doc");
-cl::opt<std::string>
+static cl::opt<std::string>
     stripPrefix("strip-prefix",
                 cl::desc("Strip prefix of the fully qualified names"),
                 cl::init("::mlir::"), cl::cat(docCat));
-cl::opt<bool> allowHugoSpecificFeatures(
+static cl::opt<bool> allowHugoSpecificFeatures(
     "allow-hugo-specific-features",
     cl::desc("Allows using features specific to Hugo"), cl::init(false),
     cl::cat(docCat));
diff --git a/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp b/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp
index c9f6dd35de44e96..c2ad09ffaaed5b7 100644
--- a/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp
+++ b/mlir/tools/tblgen-to-irdl/OpDefinitionsGen.cpp
@@ -36,7 +36,7 @@ using namespace mlir;
 using tblgen::NamedTypeConstraint;
 
 static llvm::cl::OptionCategory dialectGenCat("Options for -gen-irdl-dialect");
-llvm::cl::opt<std::string>
+static llvm::cl::opt<std::string>
     selectedDialect("dialect", llvm::cl::desc("The dialect to gen for"),
                     llvm::cl::cat(dialectGenCat), llvm::cl::Required);
 

Copy link
Contributor

@jurahul jurahul left a comment

Choose a reason for hiding this comment

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

Changes LGTM, but let's wait for another approval from someone more active on MLIR side as well (@jpienaar or @River707 ?)

@jurahul jurahul requested review from jpienaar and River707 February 18, 2025 18:11
Copy link
Contributor

@River707 River707 left a comment

Choose a reason for hiding this comment

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

LGTM

@DanielAugusto191
Copy link
Contributor Author

DanielAugusto191 commented Feb 18, 2025

I forgot to allow auto merge, done now. @River707

@joker-eph joker-eph merged commit c0a763d into llvm:main Feb 19, 2025
9 checks passed
Copy link

@DanielAugusto191 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!

Prakhar-Dixit pushed a commit to Prakhar-Dixit/llvm-project that referenced this pull request Feb 19, 2025
)

This is per style-guide: make file-scope symbol static whenever possible.

Fix llvm#125983.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change all cl::opt<> in .cpp files to static
5 participants