[PATCH] D36315: [mips] Support implicit gpopt with N64 when using -fno-pic
Simon Dardis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 11 08:03:52 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL310714: [mips] Support implicit gpopt with N64 when using -fno-pic (authored by sdardis).
Repository:
rL LLVM
https://reviews.llvm.org/D36315
Files:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/mips-features.c
Index: cfe/trunk/test/Driver/mips-features.c
===================================================================
--- cfe/trunk/test/Driver/mips-features.c
+++ cfe/trunk/test/Driver/mips-features.c
@@ -85,6 +85,24 @@
// RUN: | FileCheck --check-prefix=CHECK-MEMBEDDEDDATADEF %s
// CHECK-MEMBEDDEDDATADEF-NOT: "-mllvm" "-membedded-data"
//
+// MIPS64 + N64: -fno-pic -> -mno-abicalls -mgpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-N64-GPOPT %s
+// CHECK-N64-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-GPOPT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -fno-pic -mno-gpopt
+// RUN: %clang -target mips64-mti-elf -mabi=64 -### -c %s -fno-pic -mno-gpopt 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-N64-MNO-GPOPT %s
+// CHECK-N64-MNO-GPOPT: "-target-feature" "+noabicalls"
+// CHECK-N64-MNO-GPOPT-NOT: "-mllvm" "-mgpopt"
+//
+// MIPS64 + N64: -mgpopt (-fpic is implicit)
+// RUN: %clang -target mips64-mti-linux-gnu -mabi=64 -### -c %s -mgpopt 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-N64-PIC-GPOPT %s
+// CHECK-N64-PIC-GPOPT-NOT: "-mllvm" "-mgpopt"
+// CHECK-N64-PIC-GPOPT: ignoring '-mgpopt' option as it cannot be used with the implicit usage of -mabicalls
+//
// -mips16
// RUN: %clang -target mips-linux-gnu -### -c %s \
// RUN: -mno-mips16 -mips16 2>&1 \
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1473,8 +1473,21 @@
// NOTE: We need a warning here or in the backend to warn when -mgpopt is
// passed explicitly when compiling something with -mabicalls
// (implictly) in affect. Currently the warning is in the backend.
+ //
+ // When the ABI in use is N64, we also need to determine the PIC mode that
+ // is in use, as -fno-pic for N64 implies -mno-abicalls.
bool NoABICalls =
ABICalls && ABICalls->getOption().matches(options::OPT_mno_abicalls);
+
+ llvm::Reloc::Model RelocationModel;
+ unsigned PICLevel;
+ bool IsPIE;
+ std::tie(RelocationModel, PICLevel, IsPIE) =
+ ParsePICArgs(getToolChain(), Args);
+
+ NoABICalls = NoABICalls ||
+ (RelocationModel == llvm::Reloc::Static && ABIName == "n64");
+
bool WantGPOpt = GPOpt && GPOpt->getOption().matches(options::OPT_mgpopt);
// We quietly ignore -mno-gpopt as the backend defaults to -mno-gpopt.
if (NoABICalls && (!GPOpt || WantGPOpt)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36315.110729.patch
Type: text/x-patch
Size: 2549 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170811/5ee555c5/attachment-0001.bin>
More information about the cfe-commits
mailing list