[clang] [clang] Add partial-inlining options (PR #129024)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 27 01:20:56 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
@llvm/pr-subscribers-clang
Author: Jolyon (Jolyon0202)
<details>
<summary>Changes</summary>
Adaptation of adding -fpartial-inlining and -fno-partial-inlining options with GCC.
---
Full diff: https://github.com/llvm/llvm-project/pull/129024.diff
4 Files Affected:
- (modified) clang/docs/ReleaseNotes.rst (+2)
- (modified) clang/include/clang/Driver/Options.td (+4)
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+12)
- (modified) clang/test/Driver/clang_f_opts.c (+5)
``````````diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 307edf77ebb58..6a95a6bd494c9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -116,6 +116,8 @@ New Compiler Flags
The feature has `existed <https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#running-the-instrumented-program>`_)
for a while and this is just a user facing option.
+- New Options ``-fpartial-inlining`` and ``-fno-partial-inlining`` added to adapt with GCC.
+
Deprecated Compiler Flags
-------------------------
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index e521cbf678d93..9ee0a424afb43 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3376,6 +3376,10 @@ def fno_inline_functions : Flag<["-"], "fno-inline-functions">, Group<f_clang_Gr
Visibility<[ClangOption, CC1Option]>;
def fno_inline : Flag<["-"], "fno-inline">, Group<f_clang_Group>,
Visibility<[ClangOption, CC1Option]>;
+def fpartial_inlining : Flag<["-"], "fpartial-inlining">, Group<f_clang_Group>,
+ Visibility<[ClangOption, CC1Option]>;
+def fno_partial_inlining : Flag<["-"], "fno-partial-inlining">, Group<f_clang_Group>,
+ Visibility<[ClangOption, CC1Option]>;
def fno_global_isel : Flag<["-"], "fno-global-isel">, Group<f_clang_Group>,
HelpText<"Disables the global instruction selector">;
def fno_experimental_isel : Flag<["-"], "fno-experimental-isel">, Group<f_clang_Group>,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index aa83e3e36124c..705158a610224 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7370,6 +7370,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_finline_max_stacksize_EQ);
+ // Adaptation of partial-inlining option with GCC.
+ if (Arg *A = Args.getLastArg(options::OPT_fno_partial_inlining,
+ options::OPT_fpartial_inlining)) {
+ if (A->getOption().matches(options::OPT_fno_partial_inlining)) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("-disable-partial-inlining");
+ } else if (A->getOption().matches(options::OPT_fpartial_inlining)) {
+ CmdArgs.push_back("-mllvm");
+ CmdArgs.push_back("-enable-partial-inlining");
+ }
+ }
+
// FIXME: Find a better way to determine whether we are in C++20.
bool HaveCxx20 =
Std &&
diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c
index 7454ce3d30f5f..42a930cb94513 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -642,3 +642,8 @@
// RUN: %clang -### --target=x86_64-pc-windows-msvc -fno-strict-aliasing %s 2>&1 | FileCheck -check-prefix=CHECK-NO-STRICT-ALIASING %s
// CHECK-STRICT-ALIASING-NOT: -relaxed-aliasing
// CHECK-NO-STRICT-ALIASING: -relaxed-aliasing
+
+// RUN: %clang -### -S -fpartial-inlining %s 2>&1 | FileCheck -check-prefix=CHECK-PARTIAL-INLINING %s
+// CHECK-PARTIAL-INLINING: "-mllvm" "-enable-partial-inlining"
+// RUN: %clang -### -S -fno-partial-inlining %s 2>&1 | FileCheck -check-prefix=CHECK-NO-PARTIAL-INLINING %s
+// CHECK-NO-PARTIAL-INLINING: "-mllvm" "-disable-partial-inlining"
``````````
</details>
https://github.com/llvm/llvm-project/pull/129024
More information about the cfe-commits
mailing list