r296454 - [ARM] Don't pass -arm-execute-only to cc1as

Christof Douma via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 28 01:09:54 PST 2017


Author: christof
Date: Tue Feb 28 03:09:53 2017
New Revision: 296454

URL: http://llvm.org/viewvc/llvm-project?rev=296454&view=rev
Log:
[ARM] Don't pass -arm-execute-only to cc1as

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

Modified:
    cfe/trunk/lib/Driver/Arch/ARM.cpp
    cfe/trunk/test/Driver/arm-execute-only.c

Modified: cfe/trunk/lib/Driver/Arch/ARM.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Arch/ARM.cpp?rev=296454&r1=296453&r2=296454&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/Arch/ARM.cpp Tue Feb 28 03:09:53 2017
@@ -374,25 +374,28 @@ void arm::getARMTargetFeatures(const Too
   }
 
   // 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");
+      }
     }
   }
 

Modified: cfe/trunk/test/Driver/arm-execute-only.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-execute-only.c?rev=296454&r1=296453&r2=296454&view=diff
==============================================================================
--- cfe/trunk/test/Driver/arm-execute-only.c (original)
+++ cfe/trunk/test/Driver/arm-execute-only.c Tue Feb 28 03:09:53 2017
@@ -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"
@@ -97,3 +100,4 @@
 // 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'




More information about the cfe-commits mailing list