[PATCH] D137618: [Clang] Fix behavior of -ffp-model option when overriden
Qiu Chaofan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 8 01:18:10 PST 2022
qiucf created this revision.
qiucf added reviewers: aaron.ballman, mibintc, andrew.w.kaylor, masoud.ataei, zahiraam.
Herald added a project: All.
qiucf requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.
`-ffp-model=strict -ffp-model=fast` will still enable strict exception handling behavior, therefore clang still emits constrained FP operations in IR.
`-ffp-model=fast -ffp-model=strict` emits two warnings: one for `strict` overriding `fast`, the other for `strict` overriding `strict`, which is confusing.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137618
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/fp-model.c
Index: clang/test/Driver/fp-model.c
===================================================================
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -66,6 +66,11 @@
// RUN: | FileCheck --check-prefix=WARN10 %s
// WARN10: warning: overriding '-ffp-model=strict' option with '-fdenormal-fp-math=preserve-sign,preserve-sign' [-Woverriding-t-option]
+// RUN: %clang -### -ffp-model=fast -ffp-model=strict -c %s 2>&1 | FileCheck \
+// RUN: --check-prefix=WARN11 %s
+// WARN11: warning: overriding '-ffp-model=fast' option with '-ffp-model=strict' [-Woverriding-t-option]
+// WARN11-NOT: warning: overriding '-ffp-model=strict' option with '-ffp-model=strict' [-Woverriding-t-option]
+
// RUN: %clang -### -c %s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NOROUND %s
// CHECK-NOROUND: "-cc1"
@@ -107,6 +112,9 @@
// CHECK-FPM-STRICT: "-frounding-math"
// CHECK-FPM-STRICT: "-ffp-exception-behavior=strict"
+// RUN: %clang -### -nostdinc -ffp-model=strict -ffp-model=fast -c %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-NO-EXCEPT %s
+// CHECK-NO-EXCEPT-NOT: "-ffp-exception-behavior=strict"
// RUN: %clang -### -nostdinc -ffp-exception-behavior=strict -c %s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-FEB-STRICT %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2841,6 +2841,7 @@
optID = options::OPT_ffast_math;
FPModel = Val;
FPContract = "fast";
+ FPExceptionBehavior = "";
} else if (Val.equals("precise")) {
optID = options::OPT_ffp_contract;
FPModel = Val;
@@ -3071,10 +3072,12 @@
else {
StrictFPModel = false;
FPModel = "";
- D.Diag(clang::diag::warn_drv_overriding_flag_option)
- << "-ffp-model=strict" <<
- ((A->getNumValues() == 0) ? A->getSpelling()
- : Args.MakeArgString(A->getSpelling() + A->getValue()));
+ auto RHS = (A->getNumValues() == 0)
+ ? A->getSpelling()
+ : Args.MakeArgString(A->getSpelling() + A->getValue());
+ if (RHS != "-ffp-model=strict")
+ D.Diag(clang::diag::warn_drv_overriding_flag_option)
+ << "-ffp-model=strict" << RHS;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137618.473914.patch
Type: text/x-patch
Size: 2393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221108/f22c2f51/attachment-0001.bin>
More information about the cfe-commits
mailing list