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 @@ -433,8 +433,8 @@ llvm::ARM::getFPUFeatures(llvm::ARM::FK_NONE, Features); // Disable hardware FP features which have been enabled. - // FIXME: Disabling vfp2 and neon should be enough as all the other - // features are dependent on these 2 features in LLVM. However + // FIXME: Disabling fpregs should be enough all by itself, since all + // the other FP features are dependent on it. However // there is currently no easy way to test this in clang, so for // now just be explicit and disable all known dependent features // as well. @@ -442,6 +442,11 @@ "neon", "crypto", "dotprod", "fp16fml"}) if (std::find(std::begin(Features), std::end(Features), "+" + Feature) != std::end(Features)) Features.push_back(Args.MakeArgString("-" + Feature)); + + // Disable the base feature unconditionally, even if it was not + // explicitly in the features list (e.g. if we had +vfp3, which + // implies it). + Features.push_back("-fpregs"); } // En/disable crc code generation. diff --git a/clang/test/CodeGen/arm-mfpu-none.c b/clang/test/CodeGen/arm-mfpu-none.c new file mode 100644 --- /dev/null +++ b/clang/test/CodeGen/arm-mfpu-none.c @@ -0,0 +1,8 @@ +// REQUIRES: arm-registered-target +// RUN: %clang -target arm-none-eabi -mcpu=cortex-m4 -mfpu=none -S -o - %s | FileCheck %s + +// CHECK-LABEL: compute +// CHECK-NOT: {{s[0-9]}} +float compute(float a, float b) { + return (a+b) * (a-b); +} diff --git a/llvm/lib/Support/ARMTargetParser.cpp b/llvm/lib/Support/ARMTargetParser.cpp --- a/llvm/lib/Support/ARMTargetParser.cpp +++ b/llvm/lib/Support/ARMTargetParser.cpp @@ -198,6 +198,7 @@ Features.push_back("-fp-armv8"); break; case FPUVersion::NONE: + Features.push_back("-fpregs"); Features.push_back("-vfp2"); Features.push_back("-vfp3"); Features.push_back("-fp16");