From dcaaba5511a3a3b60e4a7a3a65db8051b366906a Mon Sep 17 00:00:00 2001 From: Sjoerd Meijer Date: Thu, 13 Oct 2016 13:22:01 +0000 Subject: [PATCH] =?utf8?q?Guard=20flag=20=E2=80=93fdenormal-fp-math=20with?= =?utf8?q?=20=E2=80=93fno-fast-math.=20This=20allows=20disabling=20the=20F?= =?utf8?q?P=20options=20with=20just=20one=20flag=20(-fno-fast-math).?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Differential Revision: https://reviews.llvm.org/D25479 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284121 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 13 ++++++++++--- test/Driver/denormal-fp-math.c | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 6c07b9b5de..eb27cb486b 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4391,11 +4391,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (ReciprocalMath) CmdArgs.push_back("-freciprocal-math"); - if (!TrappingMath) + if (!TrappingMath) CmdArgs.push_back("-fno-trapping-math"); - if (Args.hasArg(options::OPT_fdenormal_fp_math_EQ)) - Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ); + + if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption, + options::OPT_fno_fast_math, + options::OPT_funsafe_math_optimizations, + options::OPT_fno_unsafe_math_optimizations, + options::OPT_fdenormal_fp_math_EQ)) + if (A->getOption().getID() != options::OPT_fno_fast_math && + A->getOption().getID() != options::OPT_fno_unsafe_math_optimizations) + Args.AddLastArg(CmdArgs, options::OPT_fdenormal_fp_math_EQ); // Validate and pass through -fp-contract option. if (Arg *A = Args.getLastArg(options::OPT_ffast_math, FastMathAliasOption, diff --git a/test/Driver/denormal-fp-math.c b/test/Driver/denormal-fp-math.c index 58f6e3c915..95ff232b0d 100644 --- a/test/Driver/denormal-fp-math.c +++ b/test/Driver/denormal-fp-math.c @@ -1,9 +1,12 @@ // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=preserve-sign -v 2>&1 | FileCheck -check-prefix=CHECK-PS %s // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=positive-zero -v 2>&1 | FileCheck -check-prefix=CHECK-PZ %s +// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -fno-fast-math -v 2>&1 | FileCheck -check-prefix=CHECK-NO-UNSAFE %s +// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=ieee -fno-unsafe-math-optimizations -v 2>&1 | FileCheck -check-prefix=CHECK-NO-UNSAFE %s // RUN: not %clang -target arm-unknown-linux-gnu -c %s -fdenormal-fp-math=foo -v 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s // CHECK-IEEE: "-fdenormal-fp-math=ieee" // CHECK-PS: "-fdenormal-fp-math=preserve-sign" // CHECK-PZ: "-fdenormal-fp-math=positive-zero" +// CHECK-NO-UNSAFE-NOT: "-fdenormal-fp-math=ieee" // CHECK-INVALID: error: invalid value 'foo' in '-fdenormal-fp-math=foo' -- 2.40.0