From 544011fe9779f8620115192eddbd33b07a6df5ac Mon Sep 17 00:00:00 2001 From: Jessica Paquette Date: Wed, 2 May 2018 16:42:51 +0000 Subject: [PATCH] Add -foutline option to enable the MachineOutliner in AArch64 Since we've been working on productizing the MachineOutliner in AArch64, it makes sense to provide a more user-friendly way to enable it. This allows users of AArch64 to enable the outliner using -foutline instead of -mllvm -enable-machine-outliner. Other, less mature implementations (e.g, x86-64) can still enable the pass using the -mllvm option. Also add a test to make sure it works. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331370 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/Options.td | 2 ++ lib/Driver/ToolChains/Clang.cpp | 5 +++++ test/Driver/aarch64-outliner.c | 4 ++++ 3 files changed, 11 insertions(+) create mode 100644 test/Driver/aarch64-outliner.c diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 4a9e22b846..437006b9ff 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1317,6 +1317,8 @@ def fno_exceptions : Flag<["-"], "fno-exceptions">, Group; def fno_gnu_keywords : Flag<["-"], "fno-gnu-keywords">, Group, Flags<[CC1Option]>; def fno_inline_functions : Flag<["-"], "fno-inline-functions">, Group, Flags<[CC1Option]>; def fno_inline : Flag<["-"], "fno-inline">, Group, Flags<[CC1Option]>; +def foutline : Flag<["-"], "foutline">, Group, Flags<[CC1Option]>, + HelpText<"Enable function outlining (AArch64 only)">; def fno_experimental_isel : Flag<["-"], "fno-experimental-isel">, Group, HelpText<"Disables the experimental global instruction selector">; def fno_experimental_new_pass_manager : Flag<["-"], "fno-experimental-new-pass-manager">, diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 5e5dfdeeca..26789f1b81 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -1484,6 +1484,11 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args, else CmdArgs.push_back("-aarch64-enable-global-merge=true"); } + + if (Arg *A = Args.getLastArg(options::OPT_foutline)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-machine-outliner"); + } } void Clang::AddMIPSTargetArgs(const ArgList &Args, diff --git a/test/Driver/aarch64-outliner.c b/test/Driver/aarch64-outliner.c new file mode 100644 index 0000000000..2d539dfce6 --- /dev/null +++ b/test/Driver/aarch64-outliner.c @@ -0,0 +1,4 @@ +// REQUIRES: aarch64-registered-target + +// RUN: %clang -target aarch64 -foutline -S %s -### 2>&1 | FileCheck %s +// CHECK: "-mllvm" "-enable-machine-outliner" -- 2.40.0