[PATCH] D35550: [mips] Add support for -m(no-)extern-data.
Simon Dardis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 18 05:05:59 PDT 2017
sdardis created this revision.
Herald added a subscriber: arichardson.
Add support for -m(no-)extern-data when using -mgpopt in the driver. It is
enabled by default in the backend.
https://reviews.llvm.org/D35550
Files:
include/clang/Driver/Options.td
lib/Driver/ToolChains/Clang.cpp
test/Driver/mips-features.c
Index: test/Driver/mips-features.c
===================================================================
--- test/Driver/mips-features.c
+++ test/Driver/mips-features.c
@@ -50,6 +50,21 @@
// RUN: | FileCheck --check-prefix=CHECK-MLOCALSDATADEF %s
// CHECK-MLOCALSDATADEF-NOT: "-mllvm" "-mlocal-sdata"
//
+// -mno-abicalls -mgpopt -mextern-sdata
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mno-extern-sdata -mextern-sdata 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATA %s
+// CHECK-MEXTERNSDATA: "-mllvm" "-mextern-sdata=1"
+//
+// -mno-abicalls -mgpopt -mno-extern-sdata
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt -mextern-sdata -mno-extern-sdata 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MNOEXTERNSDATA %s
+// CHECK-MNOEXTERNSDATA: "-mllvm" "-mextern-sdata=0"
+//
+// -mno-abicalls -mgpopt
+// RUN: %clang -target mips-linux-gnu -### -c %s -mno-abicalls -mgpopt 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-MEXTERNSDATADEF %s
+// CHECK-MEXTERNSDATADEF-NOT: "-mllvm" "-mextern-sdata"
+//
// -mips16
// RUN: %clang -target mips-linux-gnu -### -c %s \
// RUN: -mno-mips16 -mips16 2>&1 \
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1466,6 +1466,7 @@
Arg *ABICalls = Args.getLastArg(options::OPT_mabicalls, options::OPT_mno_abicalls);
Arg *LocalSData =
Args.getLastArg(options::OPT_mlocal_sdata, options::OPT_mno_local_sdata);
+ Arg *ExternSData = Args.getLastArg(options::OPT_mextern_sdata, options::OPT_mno_extern_sdata);
// -mabicalls is the default for many MIPS environments, even with -fno-pic.
// -mgpopt is the default for static, -fno-pic environments but these two
// options conflict. We want to be certain that -mno-abicalls -mgpopt is
@@ -1498,6 +1499,16 @@
}
LocalSData->claim();
}
+
+ if (ExternSData) {
+ CmdArgs.push_back("-mllvm");
+ if (ExternSData->getOption().matches(options::OPT_mextern_sdata)) {
+ CmdArgs.push_back("-mextern-sdata=1");
+ } else {
+ CmdArgs.push_back("-mextern-sdata=0");
+ }
+ ExternSData->claim();
+ }
}
if (Arg *A = Args.getLastArg(options::OPT_mcompact_branches_EQ)) {
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2045,6 +2045,12 @@
HelpText<"Extend the -G behaviour to object local data (MIPS)">;
def mno_local_sdata : Flag<["-"], "mno-local-sdata">, Group<m_Group>,
HelpText<"Do not extend the -G behaviour to object local data (MIPS)">;
+def mextern_sdata : Flag<["-"], "mextern-sdata">, Group<m_Group>,
+ HelpText<"Assume that externally defined data is in the small data if it"
+ " meets the -G <size> threshold (MIPS)">;
+def mno_extern_sdata : Flag<["-"], "mno-extern-sdata">, Group<m_Group>,
+ HelpText<"Do not assume that externally defined data is in the small data if"
+ " it meets the -G <size> threshold (MIPS)">;
def mnan_EQ : Joined<["-"], "mnan=">, Group<m_Group>;
def mabicalls : Flag<["-"], "mabicalls">, Group<m_Group>,
HelpText<"Enable SVR4-style position-independent code (Mips only)">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35550.107073.patch
Type: text/x-patch
Size: 3355 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170718/a9d6a650/attachment.bin>
More information about the cfe-commits
mailing list