[clang] [clang] Add partial-inlining options (PR #73210)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 22 21:07:15 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
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/73210.diff
3 Files Affected:
- (modified) clang/include/clang/Driver/Options.td (+2)
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+12)
- (modified) clang/test/Driver/clang_f_opts.c (+5)
``````````diff
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index b2f2bcb6ac37910..8bc1d7991fdd5cb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3134,6 +3134,8 @@ 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>, Flags<[CC1Option]>;
+def fno_partial_inlining : Flag<["-"], "fno-partial-inlining">, Group<f_clang_Group>, Flags<[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 6dec117aed1056b..028204140d1265f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6923,6 +6923,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 ebe8a0520bf0fca..bab1ea33dd7c941 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -611,3 +611,8 @@
// CHECK-INT-OBJEMITTER-NOT: unsupported option '-fintegrated-objemitter' for target
// RUN: not %clang -### -fno-integrated-objemitter --target=x86_64 %s 2>&1 | FileCheck -check-prefix=CHECK-NOINT-OBJEMITTER %s
// CHECK-NOINT-OBJEMITTER: unsupported option '-fno-integrated-objemitter' for target
+
+// 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/73210
More information about the cfe-commits
mailing list