diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -496,7 +496,12 @@ } else { D.Diag(clang::diag::warn_target_unsupported_extension) << "crypto" << llvm::ARM::getArchName(llvm::ARM::parseArch(ArchSuffix)); - Features.push_back("-crypto"); + //-mfpu=crypto-neon-fp-armv8 does allow +sha2 / +aes / +crypto features, + // even if compiling for an cpu armv7a, if explicitly defined by the user, + // so do not deactivate them. + if ((llvm::find(Features, "+fp-armv8") == Features.end()) || + (llvm::find(Features, "+neon") == Features.end())) + Features.push_back("-crypto"); } } diff --git a/clang/test/Driver/arm-features.c b/clang/test/Driver/arm-features.c --- a/clang/test/Driver/arm-features.c +++ b/clang/test/Driver/arm-features.c @@ -79,3 +79,18 @@ // RUN: %clang -target arm-arm-none-eabi -mcpu=cortex-m23+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO5 %s // CHECK-NOCRYPTO5: warning: ignoring extension 'crypto' because the {{.*}} architecture does not support it // CHECK-NOCRYPTO5-NOT: "-target-feature" "+crypto"{{.*}} "-target-feature" "+sha2" "-target-feature" "+aes" +// +// Check +crypto does not affect -march=armv7a -mfpu=crypto-neon-fp-armv8, but it does warn that +crypto has no effect +// RUN: %clang -target arm-arm-none-eabi -march=armv7a -mfpu=crypto-neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefixes=CHECK-WARNONLY,ALL %s +// RUN: %clang -target arm-arm-none-eabi -march=armv7a+aes -mfpu=crypto-neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefixes=CHECK-WARNONLY,ALL,CHECK-HASAES %s +// RUN: %clang -target arm-arm-none-eabi -march=armv7a+sha2 -mfpu=crypto-neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefixes=CHECK-WARNONLY,ALL,CHECK-HASSHA %s +// RUN: %clang -target arm-arm-none-eabi -march=armv7a+sha2+aes -mfpu=crypto-neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefixes=CHECK-WARNONLY,ALL,CHECK-HASSHA,CHECK-HASAES %s +// RUN: %clang -target arm-arm-none-eabi -march=armv7a+aes -mfpu=neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefixes=ALL,CHECK-HASAES %s +// RUN: %clang -target arm-arm-none-eabi -march=armv7a+sha2 -mfpu=neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefixes=ALL,CHECK-HASSHA %s +// RUN: %clang -target arm-arm-none-eabi -march=armv7a+sha2+aes -mfpu=neon-fp-armv8 -### -c %s 2>&1 | FileCheck -check-prefixes=ALL,CHECK-HASSHA,CHECK-HASAES %s +// CHECK-WARNONLY: warning: ignoring extension 'crypto' because the 'armv7-a' architecture does not support it +// ALL: "-target-feature" +// CHECK-WARNONLY-NOT: "-target-feature" "-crypto" +// CHECK-HASSHA-SAME: "-target-feature" "+sha2" +// CHECK-HASAES-SAME: "-target-feature" "+aes" +//