From: Jessica Paquette Date: Fri, 29 Jun 2018 18:06:10 +0000 (+0000) Subject: [MachineOutliner] Make -mno-outline use -enable-machine-outliner=never X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4497d9c52cf6c9e2f1503d47a5f910c1aaf075fe;p=clang [MachineOutliner] Make -mno-outline use -enable-machine-outliner=never This updates -mno-outline so that it passes -enable-machine-outliner=never instead of nothing. This puts it in sync with the behaviour in llc and other tools. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336001 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 790fae4a6c..5999d0b3f9 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -4797,23 +4797,30 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, options::OPT_fno_complete_member_pointers, false)) CmdArgs.push_back("-fcomplete-member-pointers"); - if (Args.hasFlag(options::OPT_moutline, options::OPT_mno_outline, false)) { - // We only support -moutline in AArch64 right now. If we're not compiling - // for AArch64, emit a warning and ignore the flag. Otherwise, add the - // proper mllvm flags. - if (Triple.getArch() != llvm::Triple::aarch64) { - D.Diag(diag::warn_drv_moutline_unsupported_opt) << Triple.getArchName(); - } else { - CmdArgs.push_back("-mllvm"); - CmdArgs.push_back("-enable-machine-outliner"); - - // The outliner shouldn't compete with linkers that dedupe linkonceodr - // functions in LTO. Enable that behaviour by default when compiling with - // LTO. - if (getToolChain().getDriver().isUsingLTO()) { + 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 right now. If we're not compiling + // for AArch64, emit a warning and ignore the flag. Otherwise, add the + // proper mllvm flags. + if (Triple.getArch() != llvm::Triple::aarch64) { + D.Diag(diag::warn_drv_moutline_unsupported_opt) << Triple.getArchName(); + } else { CmdArgs.push_back("-mllvm"); - CmdArgs.push_back("-enable-linkonceodr-outlining"); + CmdArgs.push_back("-enable-machine-outliner"); + + // The outliner shouldn't compete with linkers that dedupe linkonceodr + // functions in LTO. Enable that behaviour by default when compiling with + // LTO. + if (getToolChain().getDriver().isUsingLTO()) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-linkonceodr-outlining"); + } } + } else { + // Disable all outlining behaviour. + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-machine-outliner=never"); } } diff --git a/test/Driver/aarch64-outliner.c b/test/Driver/aarch64-outliner.c index a02722df21..82f02ff99f 100644 --- a/test/Driver/aarch64-outliner.c +++ b/test/Driver/aarch64-outliner.c @@ -2,7 +2,7 @@ // RUN: %clang -target aarch64 -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=ON // ON: "-mllvm" "-enable-machine-outliner" // RUN: %clang -target aarch64 -moutline -mno-outline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF -// OFF-NOT: "-mllvm" "-enable-machine-outliner" +// OFF: "-mllvm" "-enable-machine-outliner=never" // RUN: %clang -target aarch64 -moutline -flto=thin -S %s -### 2>&1 | FileCheck %s -check-prefix=FLTO // FLTO: "-mllvm" "-enable-linkonceodr-outlining" // RUN: %clang -target aarch64 -moutline -flto=full -S %s -### 2>&1 | FileCheck %s -check-prefix=TLTO