[flang-commits] [flang] [flang][NFC] Expose force-no-alias option via CommandLineOpts (PR #232568)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Thu Oct 15 18:53:38 PDT 2026


https://github.com/clementval created https://github.com/llvm/llvm-project/pull/232568

Move the force-no-alias cl::opt from a file-local static in Pipelines.cpp
to CommandLineOpts.cpp and declare it extern in CommandLineOpts.h, so
other pipelines built on top of flang can honor the same setting without
re-registering the option.

>From 049ad2aea0c96653328f7dde535219736bb1c9a9 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Thu, 15 Oct 2026 18:52:48 -0700
Subject: [PATCH] [flang][NFC] Expose force-no-alias option via CommandLineOpts

---
 flang/include/flang/Optimizer/Passes/CommandLineOpts.h | 1 +
 flang/lib/Optimizer/Passes/CommandLineOpts.cpp         | 4 ++++
 flang/lib/Optimizer/Passes/Pipelines.cpp               | 4 ----
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/flang/include/flang/Optimizer/Passes/CommandLineOpts.h b/flang/include/flang/Optimizer/Passes/CommandLineOpts.h
index 35eab740a28ddc..cf159327643b8e 100644
--- a/flang/include/flang/Optimizer/Passes/CommandLineOpts.h
+++ b/flang/include/flang/Optimizer/Passes/CommandLineOpts.h
@@ -56,6 +56,7 @@ extern llvm::cl::opt<bool> disableFirAliasTags;
 extern llvm::cl::opt<bool> disableFirLICM;
 extern llvm::cl::opt<bool> disableFirMao;
 extern llvm::cl::opt<bool> useOldAliasTags;
+extern llvm::cl::opt<bool> forceNoAlias;
 
 /// Experimental option to replace the stack-arrays and memory-allocation-opt
 /// passes with the unified allocation-placement pass.
diff --git a/flang/lib/Optimizer/Passes/CommandLineOpts.cpp b/flang/lib/Optimizer/Passes/CommandLineOpts.cpp
index bdaa12c13f475a..64a33ea9e57373 100644
--- a/flang/lib/Optimizer/Passes/CommandLineOpts.cpp
+++ b/flang/lib/Optimizer/Passes/CommandLineOpts.cpp
@@ -45,6 +45,10 @@ cl::opt<bool> skipExternalRttiDefinition(
                    "other compilation units"),
     cl::Hidden);
 
+/// Force setting the no-alias attribute on fuction arguments when possible.
+llvm::cl::opt<bool> forceNoAlias("force-no-alias", llvm::cl::Hidden,
+    llvm::cl::init(true));
+
 OptimizationLevel defaultOptLevel{OptimizationLevel::O0};
 
 codegenoptions::DebugInfoKind noDebugInfo{codegenoptions::NoDebugInfo};
diff --git a/flang/lib/Optimizer/Passes/Pipelines.cpp b/flang/lib/Optimizer/Passes/Pipelines.cpp
index d965400e028d24..13e71a43772ebe 100644
--- a/flang/lib/Optimizer/Passes/Pipelines.cpp
+++ b/flang/lib/Optimizer/Passes/Pipelines.cpp
@@ -19,10 +19,6 @@
 #include "llvm/Support/CommandLine.h"
 #include <vector>
 
-/// Force setting the no-alias attribute on fuction arguments when possible.
-static llvm::cl::opt<bool> forceNoAlias("force-no-alias", llvm::cl::Hidden,
-                                        llvm::cl::init(true));
-
 /// Disable the use of fake use for arguments.
 static llvm::cl::opt<bool> disableArgumentFakeUse("disable-argument-fake-use",
                                                   llvm::cl::Hidden,



More information about the flang-commits mailing list