aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorMelanie Blower <melanie.blower@intel.com>2019-12-04 12:23:46 -0800
committerMelanie Blower <melanie.blower@intel.com>2019-12-05 03:48:04 -0800
commit7f9b5138470db1dc58f3bc05631284c653c9ed7a (patch)
tree6df6dcd5ce5f7d56fcef6e72ab2c3f287bce860e /clang/lib/Frontend/CompilerInvocation.cpp
parentc16f0b18c13e88fedaa510bc2442bb693a6230c8 (diff)
downloadllvm-7f9b5138470db1dc58f3bc05631284c653c9ed7a.zip
llvm-7f9b5138470db1dc58f3bc05631284c653c9ed7a.tar.gz
llvm-7f9b5138470db1dc58f3bc05631284c653c9ed7a.tar.bz2
Reapply af57dbf12e54 "Add support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior="
Patch was reverted because https://bugs.llvm.org/show_bug.cgi?id=44048 The original patch is modified to set the strictfp IR attribute explicitly in CodeGen instead of as a side effect of IRBuilder. In the 2nd attempt to reapply there was a windows lit test fail, the tests were fixed to use wildcard matching. Differential Revision: https://reviews.llvm.org/D62731
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 74831e7..198ae69b7 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3145,6 +3145,34 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
}
+ LangOptions::FPRoundingModeKind FPRM = LangOptions::FPR_ToNearest;
+ if (Args.hasArg(OPT_frounding_math)) {
+ FPRM = LangOptions::FPR_Dynamic;
+ }
+ Opts.setFPRoundingMode(FPRM);
+
+ if (Args.hasArg(OPT_ftrapping_math)) {
+ Opts.setFPExceptionMode(LangOptions::FPE_Strict);
+ }
+
+ if (Args.hasArg(OPT_fno_trapping_math)) {
+ Opts.setFPExceptionMode(LangOptions::FPE_Ignore);
+ }
+
+ LangOptions::FPExceptionModeKind FPEB = LangOptions::FPE_Ignore;
+ if (Arg *A = Args.getLastArg(OPT_ffp_exception_behavior_EQ)) {
+ StringRef Val = A->getValue();
+ if (Val.equals("ignore"))
+ FPEB = LangOptions::FPE_Ignore;
+ else if (Val.equals("maytrap"))
+ FPEB = LangOptions::FPE_MayTrap;
+ else if (Val.equals("strict"))
+ FPEB = LangOptions::FPE_Strict;
+ else
+ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
+ }
+ Opts.setFPExceptionMode(FPEB);
+
Opts.RetainCommentsFromSystemHeaders =
Args.hasArg(OPT_fretain_comments_from_system_headers);