[flang-commits] [flang] 8301c24 - [Flang] Keep -fkeep-inline-functions as an ignored option (#223733)
via flang-commits
flang-commits at lists.llvm.org
Tue Sep 15 12:04:12 PDT 2026
Author: Zaara Syeda
Date: 2026-09-15T15:04:05-04:00
New Revision: 8301c241d7fa0c0d737fe3a01a1213da8687f90b
URL: https://github.com/llvm/llvm-project/commit/8301c241d7fa0c0d737fe3a01a1213da8687f90b
DIFF: https://github.com/llvm/llvm-project/commit/8301c241d7fa0c0d737fe3a01a1213da8687f90b.diff
LOG: [Flang] Keep -fkeep-inline-functions as an ignored option (#223733)
55221f7 removed the warning check for -fkeep-inline-functions and
-fno-keep-inline-functions from flang-f-opts.f90 after the test started
failing when the option was implemented for Clang in 28efe19.
The options are currently only supported by Clang, so keep
-fkeep-inline-functions and -fno-keep-inline-functions as unsupported
options for Flang and emit the appropriate warnings.
Added:
Modified:
clang/include/clang/Options/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/test/Driver/flang-f-opts.f90
Removed:
################################################################################
diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td
index d78c9b728fece..06461acdf216e 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -2601,8 +2601,8 @@ defm keep_persistent_storage_variables : BoolFOption<"keep-persistent-storage-va
" keeping all variables that have a persistent storage duration, including global, static and thread-local variables, to guarantee that they can be directly addressed">>;
defm keep_inline_functions : BoolFOption<"keep-inline-functions",
CodeGenOpts<"KeepInlineFunctions">, DefaultFalse,
- PosFlag<SetTrue, [], [ClangOption, CC1Option], "Keep">,
- NegFlag<SetFalse, [], [ClangOption], "Don't keep">,
+ PosFlag<SetTrue, [], [ClangOption, CC1Option, FlangOption], "Keep">,
+ NegFlag<SetFalse, [], [ClangOption, FlangOption], "Don't keep">,
BothFlags<[], [],
" inline functions whose definition is owned by this translation unit, even if they are inlined into all callers.">>;
defm fixed_point : BoolFOption<"fixed-point",
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 0e6858d3bb645..3cccbd0cdb0c9 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -1331,6 +1331,16 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
A->claim();
}
+ // -fkeep-inline-functions/-fno-keep-inline-functions are real Clang options
+ // but are not supported by Flang; warn and ignore them.
+ for (options::ID Opt : {options::OPT_fkeep_inline_functions,
+ options::OPT_fno_keep_inline_functions}) {
+ if (const Arg *A = Args.getLastArg(Opt)) {
+ D.Diag(diag::warn_ignored_gcc_optimization) << A->getAsString(Args);
+ A->claim();
+ }
+ }
+
const InputInfo &Input = Inputs[0];
types::ID InputType = Input.getType();
diff --git a/flang/test/Driver/flang-f-opts.f90 b/flang/test/Driver/flang-f-opts.f90
index 67fe8b7fab814..a082545206ea3 100644
--- a/flang/test/Driver/flang-f-opts.f90
+++ b/flang/test/Driver/flang-f-opts.f90
@@ -68,6 +68,8 @@
! RUN: -fexpensive-optimizations \
! RUN: -fno-expensive-optimizations \
! RUN: -fno-defer-pop \
+! RUN: -fkeep-inline-functions \
+! RUN: -fno-keep-inline-functions \
! RUN: -freorder-blocks \
! RUN: -ffloat-store \
! RUN: -fgcse \
@@ -120,6 +122,8 @@
! CHECK-WARNING-DAG: optimization flag '-fexpensive-optimizations' is not supported
! CHECK-WARNING-DAG: optimization flag '-fno-expensive-optimizations' is not supported
! CHECK-WARNING-DAG: optimization flag '-fno-defer-pop' is not supported
+! CHECK-WARNING-DAG: optimization flag '-fkeep-inline-functions' is not supported
+! CHECK-WARNING-DAG: optimization flag '-fno-keep-inline-functions' is not supported
! CHECK-WARNING-DAG: optimization flag '-freorder-blocks' is not supported
! CHECK-WARNING-DAG: optimization flag '-ffloat-store' is not supported
! CHECK-WARNING-DAG: optimization flag '-fgcse' is not supported
More information about the flang-commits
mailing list