[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:19:35 PDT 2015


Update test cases.


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
@@ -1,15 +1,21 @@
 // RUN: %clang -target arm-none-gnueabi -mrestrict-it -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s
 
+// RUN: %clang -target armv8-none-gnueabi -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-RESTRICTED < %t %s
+
 // 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 arm-none-gnueabi -### %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,8 @@
-// RUN: %clang -target armv7-windows -### %s 2>&1 | FileCheck %s
+// RUN: %clang -target armv7-windows -### %s 2>&1 | FileCheck --check-prefix=CHECK-RESTRICTED %s
+// RUN: %clang -target armv7-windows -mrestrict-it -### %s 2>&1 | FileCheck --check-prefix=CHECK-RESTRICTED %s
 
-// CHECK: "-backend-option" "-arm-restrict-it"
+// CHECK-RESTRICTED: "-target-feature" "+restrict-it"
 
+// RUN: %clang -target armv7-windows -mno-restrict-it -### %s 2>&1 | FileCheck --check-prefix=CHECK-NO-RESTRICTED %s
+
+// CHECK-NO-RESTRICTED-NOT: "-target-feature" "+restrict-it"

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10414.28382.patch
Type: text/x-patch
Size: 3963 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150624/615bc232/attachment.bin>


More information about the cfe-commits mailing list