]> granicus.if.org Git - clang/commitdiff
[mips] Notify user that `-mabicalls` is ignored on non-PIC N64 ABI
authorSimon Atanasyan <simon@atanasyan.com>
Thu, 10 Aug 2017 15:42:16 +0000 (15:42 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Thu, 10 Aug 2017 15:42:16 +0000 (15:42 +0000)
The -mabicalls option does not make sense in the case of non position
independent code for the N64 ABI. After this change the driver shows a
warning that -mabicalls is ignored in that case.

Differential revision: https://reviews.llvm.org/D36550

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310613 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticDriverKinds.td
lib/Driver/ToolChains/Arch/Mips.cpp
test/Driver/mips-abicalls-warning.c [new file with mode: 0644]
test/Driver/mips-features.c

index e57cc1ad295deaffd63315262ad85bc12d40d6f6..df47f14f1c5cd06d1c09433b058c2259f505f7f9 100644 (file)
@@ -292,6 +292,10 @@ def warn_drv_unsupported_gpopt : Warning<
   "ignoring '-mgpopt' option as it cannot be used with %select{|the implicit"
   " usage of }0-mabicalls">,
   InGroup<UnsupportedGPOpt>;
+def warn_drv_unsupported_abicalls : Warning<
+  "ignoring '-mabicalls' option as it cannot be used with "
+  "non position-independent code and the N64 ABI">,
+  InGroup<OptionIgnored>;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
   "unable to find %0 directory, expected to be in '%1'">,
index c11e2518354214d162905c8e2e784514b51f315f..2a0d6eeeb9f25bae2ac1cba5defef440bc788532 100644 (file)
@@ -227,11 +227,23 @@ void mips::getMIPSTargetFeatures(const Driver &D, const llvm::Triple &Triple,
          O.matches(options::OPT_fno_PIE) || O.matches(options::OPT_fno_pie));
   }
 
-  if (IsN64 && NonPIC)
+  bool UseAbiCalls = false;
+
+  Arg *ABICallsArg =
+      Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
+  UseAbiCalls =
+      !ABICallsArg ||
+      (ABICallsArg && ABICallsArg->getOption().matches(options::OPT_mabicalls));
+
+  if (UseAbiCalls && IsN64 && NonPIC) {
+    D.Diag(diag::warn_drv_unsupported_abicalls);
+    UseAbiCalls = false;
+  }
+
+  if (!UseAbiCalls)
     Features.push_back("+noabicalls");
   else
-    AddTargetFeature(Args, Features, options::OPT_mno_abicalls,
-                     options::OPT_mabicalls, "noabicalls");
+    Features.push_back("-noabicalls");
 
   mips::FloatABI FloatABI = mips::getMipsFloatABI(D, Args);
   if (FloatABI == mips::FloatABI::Soft) {
diff --git a/test/Driver/mips-abicalls-warning.c b/test/Driver/mips-abicalls-warning.c
new file mode 100644 (file)
index 0000000..6bfa961
--- /dev/null
@@ -0,0 +1,3 @@
+// REQUIRES: mips-registered-target
+// RUN: %clang -### -c -target mips64-mti-elf -fno-PIC -mabicalls %s 2>&1 | FileCheck %s
+// CHECK: warning: ignoring '-mabicalls' option as it cannot be used with non position-independent code and the N64 ABI
index 80143c25eed736658c9fe6254f21774ff01016b0..d2814fec4a5f14284c3e7195b3a47f92c9bd0ada 100644 (file)
 // RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS %s
 // CHECK-MNOABICALLS: "-target-feature" "+noabicalls"
 //
+// -mno-abicalls non-PIC N64
+// RUN: %clang -target mips64-linux-gnu -### -c -fno-PIC %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-MNOABICALLS-N64NPIC %s
+// CHECK-MNOABICALLS-N64NPIC: "-target-feature" "+noabicalls"
+//
 // -mgpopt
 // RUN: %clang -target mips-linux-gnu -### -c %s -mno-gpopt -mgpopt -Wno-unsupported-gpopt 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MGPOPT-DEF-ABICALLS %s