[PATCH] Attach function attribute "arm-restrict-it" instead of passing arm-restrict-it as a backend-option
Akira Hatanaka
ahatanak at gmail.com
Wed Jun 24 12:18:04 PDT 2015
Based on suggestions from Eric, I've made changes to my previous patch to attach restrict-it to the target-features instead of attaching it as a function attribute. In order to avoid defining two new ARM subtarget features in the backend, I made changes to the driver to decide whether IT blocks should be restricted based on the triple and sub-arch. Subtarget feature +restrict-it is attached if the OS is Windows or the sub-arch is v8, unless the user overrides it with "-mno-restrict-it".
Relevant mailing list discussion:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150622/thread.html#131397
http://reviews.llvm.org/D10414
Files:
lib/Driver/Tools.cpp
test/Driver/arm-restrict-it.c
test/Driver/woa-restrict-it.c
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -710,9 +710,22 @@
Features.push_back("-crc");
}
- if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v8_1a) {
+ auto SubArch = Triple.getSubArch();
+
+ if (SubArch == llvm::Triple::SubArchType::ARMSubArch_v8_1a) {
Features.insert(Features.begin(), "+v8.1a");
}
+
+ // Windows on ARM and ARMv8 expect restricted IT blocks.
+ if (Arg *A = Args.getLastArg(options::OPT_mrestrict_it,
+ options::OPT_mno_restrict_it)) {
+ if (A->getOption().matches(options::OPT_mrestrict_it))
+ Features.push_back("+restrict-it");
+ } else if (Triple.isOSWindows() ||
+ SubArch == llvm::Triple::SubArchType::ARMSubArch_v8 ||
+ SubArch == llvm::Triple::SubArchType::ARMSubArch_v8_1a) {
+ Features.push_back("+restrict-it");
+ }
}
void Clang::AddARMTargetArgs(const ArgList &Args,
@@ -4071,22 +4084,6 @@
getToolChain().getArch() == llvm::Triple::aarch64_be)
CmdArgs.push_back("-fallow-half-arguments-and-returns");
- if (Arg *A = Args.getLastArg(options::OPT_mrestrict_it,
- options::OPT_mno_restrict_it)) {
- if (A->getOption().matches(options::OPT_mrestrict_it)) {
- CmdArgs.push_back("-backend-option");
- CmdArgs.push_back("-arm-restrict-it");
- } else {
- CmdArgs.push_back("-backend-option");
- CmdArgs.push_back("-arm-no-restrict-it");
- }
- } else if (TT.isOSWindows() && (TT.getArch() == llvm::Triple::arm ||
- TT.getArch() == llvm::Triple::thumb)) {
- // Windows on ARM expects restricted IT blocks
- CmdArgs.push_back("-backend-option");
- CmdArgs.push_back("-arm-restrict-it");
- }
-
if (TT.getArch() == llvm::Triple::arm ||
TT.getArch() == llvm::Triple::thumb) {
if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
Index: test/Driver/arm-restrict-it.c
===================================================================
--- test/Driver/arm-restrict-it.c
+++ test/Driver/arm-restrict-it.c
@@ -4,12 +4,12 @@
// RUN: %clang -target armv8a-none-gnueabi -mrestrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s
-// CHECK-RESTRICTED: "-backend-option" "-arm-restrict-it"
+// CHECK-RESTRICTED: "-target-feature" "+restrict-it"
// RUN: %clang -target arm-none-gnueabi -mno-restrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NO-RESTRICTED < %t %s
// RUN: %clang -target armv8a-none-gnueabi -mno-restrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NO-RESTRICTED < %t %s
-// CHECK-NO-RESTRICTED: "-backend-option" "-arm-no-restrict-it"
+// CHECK-NO-RESTRICTED-NOT: "-target-feature" "+restrict-it"
Index: test/Driver/woa-restrict-it.c
===================================================================
--- test/Driver/woa-restrict-it.c
+++ test/Driver/woa-restrict-it.c
@@ -1,4 +1,4 @@
// RUN: %clang -target armv7-windows -### %s 2>&1 | FileCheck %s
-// CHECK: "-backend-option" "-arm-restrict-it"
+// CHECK: "-target-feature" "+restrict-it"
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10414.28380.patch
Type: text/x-patch
Size: 3193 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150624/79461ed7/attachment.bin>
More information about the cfe-commits
mailing list