[clang] [clang] Add partial-inlining options (PR #73210)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 23 00:36:28 PST 2023
https://github.com/Jolyon0202 updated https://github.com/llvm/llvm-project/pull/73210
>From d5679e5dba708e8a54c63d63f3da6c92a6cf0aeb Mon Sep 17 00:00:00 2001
From: Jian Yang <yangjian86 at huawei.com>
Date: Thu, 23 Nov 2023 12:54:52 +0800
Subject: [PATCH] [clang] Add partial-inlining options
Adaptation of adding -fpartial-inlining and -fno-partial-inlining options with GCC.
---
clang/include/clang/Driver/Options.td | 4 ++++
clang/lib/Driver/ToolChains/Clang.cpp | 12 ++++++++++++
clang/test/Driver/clang_f_opts.c | 5 +++++
3 files changed, 21 insertions(+)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index b2f2bcb6ac37910..7dbf2363fe17b6b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3134,6 +3134,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 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"
More information about the cfe-commits
mailing list