aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorDavid Candler <david.candler@arm.com>2022-04-29 15:06:12 +0100
committerDavid Candler <david.candler@arm.com>2022-04-29 15:06:32 +0100
commit9e7c9967c3fd573ef53b145e24e6a1e6ba930c82 (patch)
treeb4851268a30b1675261ef25a5448f06714e2d002 /clang/lib/Frontend
parent205246cb64358aa6f03b54d47d73708122d76bbf (diff)
downloadllvm-9e7c9967c3fd573ef53b145e24e6a1e6ba930c82.zip
llvm-9e7c9967c3fd573ef53b145e24e6a1e6ba930c82.tar.gz
llvm-9e7c9967c3fd573ef53b145e24e6a1e6ba930c82.tar.bz2
Additionally set f32 mode with denormal-fp-math
When the denormal-fp-math option is used, this should set the denormal handling mode for all floating point types. However, currently 32-bit float types can ignore this setting as there is a variant of the option, denormal-fp-math-f32, specifically for that type which takes priority when checking the mode based on type and remains at the default of IEEE. From the description, denormal-fp-math would be expected to set the mode for floats unless overridden by the f32 variant, and code in the front end only emits the f32 option if it is different to the general one, so setting just denormal-fp-math should be valid. This patch changes the denormal-fp-math option to also set the f32 mode. If denormal-fp-math-f32 is also specified, this is then overridden as expected, but if it is absent floats will be set to the mode specified by the former option, rather than remain on the default. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D122589
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 6607287..b35e3f4 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1526,7 +1526,8 @@ void CompilerInvocation::GenerateCodeGenArgs(
if (Opts.FPDenormalMode != llvm::DenormalMode::getIEEE())
GenerateArg(Args, OPT_fdenormal_fp_math_EQ, Opts.FPDenormalMode.str(), SA);
- if (Opts.FP32DenormalMode != llvm::DenormalMode::getIEEE())
+ if ((Opts.FPDenormalMode != Opts.FP32DenormalMode) ||
+ (Opts.FP32DenormalMode != llvm::DenormalMode::getIEEE()))
GenerateArg(Args, OPT_fdenormal_fp_math_f32_EQ, Opts.FP32DenormalMode.str(),
SA);
@@ -1879,6 +1880,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
if (Arg *A = Args.getLastArg(OPT_fdenormal_fp_math_EQ)) {
StringRef Val = A->getValue();
Opts.FPDenormalMode = llvm::parseDenormalFPAttribute(Val);
+ Opts.FP32DenormalMode = Opts.FPDenormalMode;
if (!Opts.FPDenormalMode.isValid())
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
}