[PATCH] D100937: [ARM][Driver][Windows] Allow command-line upgrade to Armv8.

Simon Tatham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 21 02:47:26 PDT 2021


simon_tatham created this revision.
simon_tatham added reviewers: mstorsjo, thakis.
Herald added subscribers: dexonsmith, danielkiss, hiraditya, kristof.beyls.
simon_tatham requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

If you gave clang the options `--target=arm-pc-windows-msvc` and
`-march=armv8-a+crypto` together, the crypto extension would not be
enabled in the compilation, and you'd see the following warning
message suggesting that the 'armv8-a' had been ignored:

  clang: warning: ignoring extension 'crypto' because the 'armv7-a' architecture does not support it [-Winvalid-command-line-argument]

This happens because Triple::getARMCPUForArch(), for the Win32 OS,
unconditionally returns "cortex-a9" (an Armv7 CPU) regardless of
MArch, which overrides the architecture setting on the command line.

I don't think that the combination of Windows and AArch32 _should_
unconditionally outlaw the use of the crypto extension. MSVC itself
doesn't think so: you can perfectly well compile Thumb crypto code
using its AArch32-targeted compiler.

All the other default CPUs in the same switch statement are
conditional on a particular MArch setting; this is the only one that
returns a particular CPU _regardless_ of MArch. So I've fixed this one
by adding a condition, so that if you ask for an architecture *above*
v7, the default of Cortex-A9 no longer overrides it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100937

Files:
  clang/test/Driver/woa-crypto.c
  llvm/lib/Support/Triple.cpp


Index: llvm/lib/Support/Triple.cpp
===================================================================
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -1716,7 +1716,9 @@
     break;
   case llvm::Triple::Win32:
     // FIXME: this is invalid for WindowsCE
-    return "cortex-a9";
+    if (ARM::parseArchVersion(MArch) <= 7)
+      return "cortex-a9";
+    break;
   case llvm::Triple::IOS:
   case llvm::Triple::MacOSX:
   case llvm::Triple::TvOS:
Index: clang/test/Driver/woa-crypto.c
===================================================================
--- /dev/null
+++ clang/test/Driver/woa-crypto.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm-windows-msvc                       -### -S %s -O0 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-DEFAULT
+// RUN: %clang -target arm-windows-msvc -march=armv8-a+crypto -### -S %s -O0 -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-CRYPTO
+
+// CHECK-DEFAULT: "-target-cpu" "cortex-a9"
+// CHECK-CRYPTO: "-target-cpu" "generic"
+// CHECK-CRYPTO: "-target-feature" "+crypto"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100937.339155.patch
Type: text/x-patch
Size: 1051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210421/b090761f/attachment.bin>


More information about the llvm-commits mailing list