]> granicus.if.org Git - clang/commitdiff
[ARM] Don't pass -arm-execute-only to cc1as
authorChristof Douma <Christof.Douma@arm.com>
Tue, 28 Feb 2017 09:09:53 +0000 (09:09 +0000)
committerChristof Douma <Christof.Douma@arm.com>
Tue, 28 Feb 2017 09:09:53 +0000 (09:09 +0000)
The option -mexecute-only is translated into the backend option
-arm-execute-only. But this option only makes sense for the compiler and
the assembler does not recognize it. This patch stops clang from passing
this option to the assembler.

Change-Id: I4f4cb1162c13cfd50a0a36702a4ecab1bc0324ba
Review: https://reviews.llvm.org/D30414

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@296454 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Arch/ARM.cpp
test/Driver/arm-execute-only.c

index 29adbedecf6b3f961e97c80425e1ea262a6e9b63..d7d58c1f69f72f9b1796a92403b3df1c08d43d69 100644 (file)
@@ -374,25 +374,28 @@ void arm::getARMTargetFeatures(const ToolChain &TC,
   }
 
   // Generate execute-only output (no data access to code sections).
-  // Supported only on ARMv6T2 and ARMv7 and above.
-  // Cannot be combined with -mno-movt or -mlong-calls
-  if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, options::OPT_mno_execute_only)) {
-    if (A->getOption().matches(options::OPT_mexecute_only)) {
-      if (getARMSubArchVersionNumber(Triple) < 7 &&
-          llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::AK_ARMV6T2)
-            D.Diag(diag::err_target_unsupported_execute_only) << Triple.getArchName();
-      else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
-        D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args);
-      // Long calls create constant pool entries and have not yet been fixed up
-      // to play nicely with execute-only. Hence, they cannot be used in
-      // execute-only code for now
-      else if (Arg *B = Args.getLastArg(options::OPT_mlong_calls, options::OPT_mno_long_calls)) {
-        if (B->getOption().matches(options::OPT_mlong_calls))
+  // This only makes sense for the compiler, not for the assembler.
+  if (!ForAS) {
+    // Supported only on ARMv6T2 and ARMv7 and above.
+    // Cannot be combined with -mno-movt or -mlong-calls
+    if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, options::OPT_mno_execute_only)) {
+      if (A->getOption().matches(options::OPT_mexecute_only)) {
+        if (getARMSubArchVersionNumber(Triple) < 7 &&
+            llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::AK_ARMV6T2)
+              D.Diag(diag::err_target_unsupported_execute_only) << Triple.getArchName();
+        else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
           D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args);
+        // Long calls create constant pool entries and have not yet been fixed up
+        // to play nicely with execute-only. Hence, they cannot be used in
+        // execute-only code for now
+        else if (Arg *B = Args.getLastArg(options::OPT_mlong_calls, options::OPT_mno_long_calls)) {
+          if (B->getOption().matches(options::OPT_mlong_calls))
+            D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args);
+        }
+
+        CmdArgs.push_back("-backend-option");
+        CmdArgs.push_back("-arm-execute-only");
       }
-
-      CmdArgs.push_back("-backend-option");
-      CmdArgs.push_back("-arm-execute-only");
     }
   }
 
index 7010bbc837a09aa505a41a185936a78afc9d96b4..a4854485e1e446caeab3f5ba3d192ea1feb0c84d 100644 (file)
@@ -90,6 +90,9 @@
 // RUN: not %clang -target armv8m.main-eabi -mpure-code -mlong-calls %s 2>&1 \
 // RUN:    | FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-LONG-CALLS
 
+// RUN: %clang -target armv7m-eabi -x assembler -mexecute-only %s -c -### 2>&1 \
+// RUN:    | FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY -check-prefix CHECK-NO-EXECUTE-ONLY-ASM
+
 //
 // CHECK-NO-EXECUTE-ONLY-NOT: "-backend-option" "-arm-execute-only"
 // CHECK-EXECUTE-ONLY: "-backend-option" "-arm-execute-only"
 // CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for the thumbv6m sub-architecture
 // CHECK-EXECUTE-ONLY-NO-MOVT: error: option '-mexecute-only' cannot be specified with '-mno-movt'
 // CHECK-EXECUTE-ONLY-LONG-CALLS: error: option '-mexecute-only' cannot be specified with '-mlong-calls'
+// CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: '-mexecute-only'