[PATCH] D10414: Attach function attribute "arm-restrict-it" instead of passing arm-restrict-it as a backend-option
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 16:22:54 PDT 2015
ahatanak updated this revision to Diff 34379.
ahatanak added a comment.
Based on the feedback from reviewers for the llvm patch (http://reviews.llvm.org/D10416), I made changes to fix the handling of -mrestrict-it and -mno-restrict-it in the driver. The driver now passes subtarget feature "restrict-it" if the target requires it (target is windows or armv8) or -mrestrict-it is on the command line and -mno-restrict-it doesn't appear after it. The end-user can no longer use -mno-restrict-it to instruct the backend to emit the deprecated (unrestricted) forms of IT blocks when targeting windows or armv8.
http://reviews.llvm.org/D10414
Files:
lib/Driver/Tools.cpp
test/Driver/arm-restrict-it.c
test/Driver/woa-restrict-it.c
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"
+// RUN: %clang -target armv7-windows -### %s 2>&1 | FileCheck --check-prefix=CHECK-RESTRICTED %s
+// RUN: %clang -target armv7-windows -mno-restrict-it -### %s 2>&1 | FileCheck --check-prefix=CHECK-RESTRICTED %s
+// CHECK-RESTRICTED: "-target-feature" "+restrict-it"
Index: test/Driver/arm-restrict-it.c
===================================================================
--- test/Driver/arm-restrict-it.c
+++ test/Driver/arm-restrict-it.c
@@ -1,15 +1,21 @@
-// RUN: %clang -target arm-none-gnueabi -mrestrict-it -### %s 2> %t
+// RUN: %clang -target arm-none-gnueabi -mno-restrict-it -mrestrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s
-// RUN: %clang -target armv8a-none-gnueabi -mrestrict-it -### %s 2> %t
+// RUN: %clang -target armv8-none-gnueabi -mno-restrict-it -### %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s
-// CHECK-RESTRICTED: "-backend-option" "-arm-restrict-it"
+// RUN: %clang -target armv8a-none-gnueabi -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s
+
+// RUN: %clang -target armv8a-none-gnueabi -mno-restrict-it -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s
+
+// 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: %clang -target arm-none-gnueabi -### %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: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -795,10 +795,21 @@
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 (Triple.isOSWindows() ||
+ SubArch == llvm::Triple::SubArchType::ARMSubArch_v8 ||
+ SubArch == llvm::Triple::SubArchType::ARMSubArch_v8_1a)
+ Features.push_back("+restrict-it");
+ else if (Args.hasFlag(options::OPT_mrestrict_it, options::OPT_mno_restrict_it,
+ false))
+ Features.push_back("+restrict-it");
+
// Look for the last occurrence of -mlong-calls or -mno-long-calls. If
// neither options are specified, see if we are compiling for kernel/kext and
// decide whether to pass "+long-calls" based on the OS and its version.
@@ -4366,23 +4377,6 @@
break;
}
- 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 (Triple.isOSWindows() &&
- (Triple.getArch() == llvm::Triple::arm ||
- Triple.getArch() == llvm::Triple::thumb)) {
- // Windows on ARM expects restricted IT blocks
- CmdArgs.push_back("-backend-option");
- CmdArgs.push_back("-arm-restrict-it");
- }
-
// Forward -f options with positive and negative forms; we translate
// these by hand.
if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10414.34379.patch
Type: text/x-patch
Size: 4011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150909/cd0dff68/attachment-0001.bin>
More information about the cfe-commits
mailing list