From: Jessica Paquette Date: Mon, 25 Jun 2018 17:27:51 +0000 (+0000) Subject: [MachineOutliner] Make last of -moutline/-mno-outline win X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9dee2b4694b92fbf366b5d322c48ad62c81d7b07;p=clang [MachineOutliner] Make last of -moutline/-mno-outline win The expected behaviour of command-line flags to clang is to have the last of -m(whatever) and -mno-(whatever) win. The outliner didn't do that. This fixes that and updates the test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335503 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 88e2f83f6d..248c460aa0 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -1477,10 +1477,12 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args, CmdArgs.push_back("-aarch64-enable-global-merge=true"); } - if (!Args.hasArg(options::OPT_mno_outline) && - Args.getLastArg(options::OPT_moutline)) { - CmdArgs.push_back("-mllvm"); - CmdArgs.push_back("-enable-machine-outliner"); + if (Arg *A = Args.getLastArg(options::OPT_moutline, + options::OPT_mno_outline)) { + if (A->getOption().matches(options::OPT_moutline)) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-enable-machine-outliner"); + } } } diff --git a/test/Driver/aarch64-outliner.c b/test/Driver/aarch64-outliner.c index 94034566b3..311ee59901 100644 --- a/test/Driver/aarch64-outliner.c +++ b/test/Driver/aarch64-outliner.c @@ -1,9 +1,5 @@ // REQUIRES: aarch64-registered-target - // 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=OFF1 -// RUN: %clang -target aarch64 -mno-outline -moutline -S %s -### 2>&1 | FileCheck %s -check-prefix=OFF2 -// OFF1-NOT: "-mllvm" "-enable-machine-outliner" -// OFF2-NOT: "-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"