Skip to content

Commit 86e0964

Browse files
committed
[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.
1 parent 31c8669 commit 86e0964

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5127,12 +5127,16 @@ def mms_bitfields : Flag<["-"], "mms-bitfields">, Group<m_Group>,
51275127
Visibility<[ClangOption, CC1Option]>,
51285128
HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard">,
51295129
MarshallingInfoFlag<LangOpts<"MSBitfields">>;
5130-
def moutline : Flag<["-"], "moutline">, Group<f_clang_Group>,
5131-
Visibility<[ClangOption, CC1Option]>,
5132-
HelpText<"Enable function outlining (AArch64 only)">;
5133-
def mno_outline : Flag<["-"], "mno-outline">, Group<f_clang_Group>,
5134-
Visibility<[ClangOption, CC1Option]>,
5135-
HelpText<"Disable function outlining (AArch64 only)">;
5130+
def moutline
5131+
: Flag<["-"], "moutline">,
5132+
Group<f_clang_Group>,
5133+
Visibility<[ClangOption, CC1Option]>,
5134+
HelpText<"Enable function outlining (AArch64,Arm,RISC-V,X86 only)">;
5135+
def mno_outline
5136+
: Flag<["-"], "mno-outline">,
5137+
Group<f_clang_Group>,
5138+
Visibility<[ClangOption, CC1Option]>,
5139+
HelpText<"Disable function outlining (AArch64,Arm,RISC-V,X86 only)">;
51365140
def mno_ms_bitfields : Flag<["-"], "mno-ms-bitfields">, Group<m_Group>,
51375141
HelpText<"Do not set the default structure layout to be compatible with the Microsoft compiler standard">;
51385142
def mskip_rax_setup : Flag<["-"], "mskip-rax-setup">, Group<m_Group>,

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2916,12 +2916,16 @@ void tools::addMachineOutlinerArgs(const Driver &D,
29162916
if (Arg *A = Args.getLastArg(options::OPT_moutline,
29172917
options::OPT_mno_outline)) {
29182918
if (A->getOption().matches(options::OPT_moutline)) {
2919-
// We only support -moutline in AArch64 and ARM targets right now. If
2920-
// we're not compiling for these, emit a warning and ignore the flag.
2921-
// Otherwise, add the proper mllvm flags.
2922-
if (!(Triple.isARM() || Triple.isThumb() || Triple.isAArch64())) {
2919+
// We only support -moutline in AArch64, ARM, RISC-V and X86 targets right
2920+
// now. If we're not compiling for these, emit a warning and ignore the
2921+
// flag. Otherwise, add the proper mllvm flags.
2922+
if (!(Triple.isARM() || Triple.isThumb() || Triple.isAArch64() ||
2923+
Triple.isRISCV() || Triple.isX86())) {
29232924
D.Diag(diag::warn_drv_moutline_unsupported_opt) << Triple.getArchName();
29242925
} else {
2926+
// FIXME: This should probably use the `nooutline` attribute rather than
2927+
// tweaking Pipeline Pass flags, so `-mno-outline` and `-moutline`
2928+
// objects can be combined correctly during LTO.
29252929
addArg(Twine("-enable-machine-outliner"));
29262930
}
29272931
} else {

clang/test/Driver/aarch64-outliner.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@
44
// RUN: %clang --target=aarch64 -moutline -mno-outline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF
55
// RUN: %clang --target=aarch64_be -moutline -mno-outline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF
66
// OFF: "-mllvm" "-enable-machine-outliner=never"
7-
// RUN: %clang --target=x86_64 -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=WARN
8-
// WARN: warning: 'x86_64' does not support '-moutline'; flag ignored [-Woption-ignored]
9-
// WARN-NOT: "-mllvm" "-enable-machine-outliner"

clang/test/Driver/riscv-outliner.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang --target=riscv32 -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=ON
2+
// RUN: %clang --target=riscv64 -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=ON
3+
// ON: "-mllvm" "-enable-machine-outliner"
4+
5+
// RUN: %clang --target=riscv32 -moutline -mno-outline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF
6+
// RUN: %clang --target=riscv64 -moutline -mno-outline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF
7+
// OFF: "-mllvm" "-enable-machine-outliner=never"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %clang --target=ppc64 -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=WARN
2+
// WARN: warning: 'ppc64' does not support '-moutline'; flag ignored [-Woption-ignored]
3+
// WARN-NOT: "-mllvm" "-enable-machine-outliner"

clang/test/Driver/x86-outliner.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang --target=i386 -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=ON
2+
// RUN: %clang --target=x86_64 -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=ON
3+
// ON: "-mllvm" "-enable-machine-outliner"
4+
5+
// RUN: %clang --target=i386 -moutline -mno-outline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF
6+
// RUN: %clang --target=x86_64 -moutline -mno-outline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF
7+
// OFF: "-mllvm" "-enable-machine-outliner=never"

0 commit comments

Comments
 (0)