https://github.com/lenary updated 
https://github.com/llvm/llvm-project/pull/163664

>From 4152ef2e237e406278cb74634fe3c0b6c2406aed Mon Sep 17 00:00:00 2001
From: Sam Elliott <[email protected]>
Date: Tue, 14 Oct 2025 21:46:45 -0700
Subject: [PATCH 1/4] [clang][Driver] Support Outline Flags on RISC-V and X86

These two targets both also support the machine outliner, so these flags
should probably be cross-target. This updates the docs for these flags
as well.
---
 clang/include/clang/Options/Options.td     | 18 +++++++++++-------
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 16 ++++++++++------
 clang/test/Driver/aarch64-outliner.c       |  3 ---
 clang/test/Driver/riscv-outliner.c         |  7 +++++++
 clang/test/Driver/unsupported-outliner.c   |  3 +++
 clang/test/Driver/x86-outliner.c           |  7 +++++++
 6 files changed, 38 insertions(+), 16 deletions(-)
 create mode 100644 clang/test/Driver/riscv-outliner.c
 create mode 100644 clang/test/Driver/unsupported-outliner.c
 create mode 100644 clang/test/Driver/x86-outliner.c

diff --git a/clang/include/clang/Options/Options.td 
b/clang/include/clang/Options/Options.td
index 155f19fb00bd8..ac973602b3517 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -27,7 +27,7 @@ def GlobalDocumentation {
 #endif
 
 // Use this to generate program specific documentation, for example:
-// StringForProgram<"Control how %Program behaves.">.str
+// StringForProgram<"Control how %Program behaves.".str
 class StringForProgram<string _str> {
   string str = !subst("%Program", GlobalDocumentation.Program, _str);
 }
@@ -5297,14 +5297,18 @@ def mmacos_version_min_EQ : Joined<["-"], 
"mmacos-version-min=">,
 def : Joined<["-"], "mmacosx-version-min=">,
   Visibility<[ClangOption, CC1Option, FC1Option, FlangOption]>,
   Group<m_Group>, Alias<mmacos_version_min_EQ>;
+def moutline
+    : Flag<["-"], "moutline">,
+      Group<f_clang_Group>,
+      Visibility<[ClangOption, CC1Option]>,
+      HelpText<"Enable function outlining (AArch64,Arm,RISC-V,X86 only)">;
+def mno_outline
+    : Flag<["-"], "mno-outline">,
+      Group<f_clang_Group>,
+      Visibility<[ClangOption, CC1Option]>,
+      HelpText<"Disable function outlining (AArch64,Arm,RISC-V,X86 only)">;
 def mms_bitfields : Flag<["-"], "mms-bitfields">, Group<m_Group>,
   HelpText<"Set the default structure layout to be compatible with the 
Microsoft compiler standard">;
-def moutline : Flag<["-"], "moutline">, Group<f_clang_Group>,
-  Visibility<[ClangOption, CC1Option]>,
-    HelpText<"Enable function outlining (AArch64 only)">;
-def mno_outline : Flag<["-"], "mno-outline">, Group<f_clang_Group>,
-  Visibility<[ClangOption, CC1Option]>,
-    HelpText<"Disable function outlining (AArch64 only)">;
 def mno_ms_bitfields : Flag<["-"], "mno-ms-bitfields">, Group<m_Group>,
   HelpText<"Do not set the default structure layout to be compatible with the 
Microsoft compiler standard">;
 def fms_layout_compatibility_EQ : Joined<["-"], "fms-layout-compatibility=">,
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index a09c3db42b423..27cb9e7c0881e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2956,13 +2956,17 @@ void tools::addMachineOutlinerArgs(const Driver &D,
   if (Arg *A = Args.getLastArg(options::OPT_moutline,
                                options::OPT_mno_outline)) {
     if (A->getOption().matches(options::OPT_moutline)) {
-      // We only support -moutline in AArch64 and ARM targets right now. If
-      // we're not compiling for these, emit a warning and ignore the flag.
-      // Otherwise, add the proper mllvm flags.
-      if (!(Triple.isARM() || Triple.isThumb() || Triple.isAArch64())) {
-        D.Diag(diag::warn_drv_moutline_unsupported_opt) << 
Triple.getArchName();
-      } else {
+      // We only support -moutline in AArch64, ARM, RISC-V and X86 targets 
right
+      // now. If we're compiling for these, add the proper mllvm flags.
+      // Otherwise, emit a warning and ignore the flag.
+      if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64() ||
+          Triple.isRISCV() || Triple.isX86()) {
+        // FIXME: This should probably use the `nooutline` attribute rather 
than
+        // tweaking Pipeline Pass flags, so `-mno-outline` and `-moutline`
+        // objects can be combined correctly during LTO.
         addArg(Twine("-enable-machine-outliner"));
+      } else {
+        D.Diag(diag::warn_drv_moutline_unsupported_opt) << 
Triple.getArchName();
       }
     } else {
       // Disable all outlining behaviour.
diff --git a/clang/test/Driver/aarch64-outliner.c 
b/clang/test/Driver/aarch64-outliner.c
index c5d28d121513f..5ed822f122fc4 100644
--- a/clang/test/Driver/aarch64-outliner.c
+++ b/clang/test/Driver/aarch64-outliner.c
@@ -4,6 +4,3 @@
 // RUN: %clang --target=aarch64 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
 // RUN: %clang --target=aarch64_be -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
 // OFF: "-mllvm" "-enable-machine-outliner=never"
-// RUN: %clang --target=x86_64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=WARN
-// WARN: warning: 'x86_64' does not support '-moutline'; flag ignored 
[-Woption-ignored]
-// WARN-NOT: "-mllvm" "-enable-machine-outliner"
diff --git a/clang/test/Driver/riscv-outliner.c 
b/clang/test/Driver/riscv-outliner.c
new file mode 100644
index 0000000000000..9e9905ab4fd8a
--- /dev/null
+++ b/clang/test/Driver/riscv-outliner.c
@@ -0,0 +1,7 @@
+// RUN: %clang --target=riscv32 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
+// RUN: %clang --target=riscv64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
+// ON: "-mllvm" "-enable-machine-outliner"
+
+// RUN: %clang --target=riscv32 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
+// RUN: %clang --target=riscv64 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
+// OFF: "-mllvm" "-enable-machine-outliner=never"
diff --git a/clang/test/Driver/unsupported-outliner.c 
b/clang/test/Driver/unsupported-outliner.c
new file mode 100644
index 0000000000000..ff543a8e36e2a
--- /dev/null
+++ b/clang/test/Driver/unsupported-outliner.c
@@ -0,0 +1,3 @@
+// RUN: %clang --target=ppc64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=WARN
+// WARN: warning: 'ppc64' does not support '-moutline'; flag ignored 
[-Woption-ignored]
+// WARN-NOT: "-mllvm" "-enable-machine-outliner"
diff --git a/clang/test/Driver/x86-outliner.c b/clang/test/Driver/x86-outliner.c
new file mode 100644
index 0000000000000..e2af85d3d16ab
--- /dev/null
+++ b/clang/test/Driver/x86-outliner.c
@@ -0,0 +1,7 @@
+// RUN: %clang --target=i386 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
+// RUN: %clang --target=x86_64 -moutline -S %s -### 2>&1 | FileCheck %s 
-check-prefix=ON
+// ON: "-mllvm" "-enable-machine-outliner"
+
+// RUN: %clang --target=i386 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
+// RUN: %clang --target=x86_64 -moutline -mno-outline -S %s -### 2>&1 | 
FileCheck %s -check-prefix=OFF
+// OFF: "-mllvm" "-enable-machine-outliner=never"

>From 031424e67d286589d5c31da16234c09f7f577650 Mon Sep 17 00:00:00 2001
From: Sam Elliott <[email protected]>
Date: Thu, 16 Oct 2025 13:48:07 -0700
Subject: [PATCH 2/4] Release Note

---
 clang/docs/ReleaseNotes.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a1bb1bd2467b7..59fdbc80e8bed 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -149,6 +149,7 @@ Deprecated Compiler Flags
 
 Modified Compiler Flags
 -----------------------
+- The `-mno-outline` and `-moutline` compiler flags are now allowed on RISC-V 
and X86, which both support the machine outliner.
 
 Removed Compiler Flags
 ----------------------

>From 8a5168b6394214fb9cbf48117e13f63ae6c7f116 Mon Sep 17 00:00:00 2001
From: Sam Elliott <[email protected]>
Date: Thu, 16 Oct 2025 13:56:33 -0700
Subject: [PATCH 3/4] Move Comment to correct place

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 27cb9e7c0881e..6a604db4d200b 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2961,15 +2961,15 @@ void tools::addMachineOutlinerArgs(const Driver &D,
       // Otherwise, emit a warning and ignore the flag.
       if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64() ||
           Triple.isRISCV() || Triple.isX86()) {
-        // FIXME: This should probably use the `nooutline` attribute rather 
than
-        // tweaking Pipeline Pass flags, so `-mno-outline` and `-moutline`
-        // objects can be combined correctly during LTO.
         addArg(Twine("-enable-machine-outliner"));
       } else {
         D.Diag(diag::warn_drv_moutline_unsupported_opt) << 
Triple.getArchName();
       }
     } else {
       // Disable all outlining behaviour.
+      // FIXME: This should probably use the `nooutline` attribute rather than
+      // tweaking Pipeline Pass flags, so `-mno-outline` and `-moutline`
+      // objects can be combined correctly during LTO.
       addArg(Twine("-enable-machine-outliner=never"));
     }
   }

>From a455e389e7739cc27d3ad1c7db07e885537f6cb0 Mon Sep 17 00:00:00 2001
From: Sam Elliott <[email protected]>
Date: Thu, 16 Oct 2025 14:10:14 -0700
Subject: [PATCH 4/4] formatting

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 6a604db4d200b..6857231b2aafe 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2967,9 +2967,10 @@ void tools::addMachineOutlinerArgs(const Driver &D,
       }
     } else {
       // Disable all outlining behaviour.
+      //
       // FIXME: This should probably use the `nooutline` attribute rather than
-      // tweaking Pipeline Pass flags, so `-mno-outline` and `-moutline`
-      // objects can be combined correctly during LTO.
+      // tweaking Pipeline Pass flags, so `-mno-outline` and `-moutline` 
objects
+      // can be combined correctly during LTO.
       addArg(Twine("-enable-machine-outliner=never"));
     }
   }

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to