]> granicus.if.org Git - clang/commitdiff
[MachineOutliner] Make last of -moutline/-mno-outline win
authorJessica Paquette <jpaquette@apple.com>
Mon, 25 Jun 2018 17:27:51 +0000 (17:27 +0000)
committerJessica Paquette <jpaquette@apple.com>
Mon, 25 Jun 2018 17:27:51 +0000 (17:27 +0000)
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

lib/Driver/ToolChains/Clang.cpp
test/Driver/aarch64-outliner.c

index 88e2f83f6daf515df83373ce3b1fb68c9bd192cf..248c460aa0e58e34de5e86b640731ccb3e1fc479 100644 (file)
@@ -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");
+    }
   }
 }
 
index 94034566b353ba96f6eb05c3c8a0e68ba08a53be..311ee59901397312646416cbad01e809a0fc023a 100644 (file)
@@ -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"