[clang] 01dc694 - FP LangOpts should not be dependent on CGOpt

Melanie Blower via cfe-commits cfe-commits at lists.llvm.org
Mon May 11 12:32:51 PDT 2020


Author: Melanie Blower
Date: 2020-05-11T12:32:35-07:00
New Revision: 01dc694ccb8689a4b4a180da67ed042f85bbcfd5

URL: https://github.com/llvm/llvm-project/commit/01dc694ccb8689a4b4a180da67ed042f85bbcfd5
DIFF: https://github.com/llvm/llvm-project/commit/01dc694ccb8689a4b4a180da67ed042f85bbcfd5.diff

LOG: FP LangOpts should not be dependent on CGOpt
This bug was observed by Apple since their compiler processes LangOpts and CGOpts in a different order.

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D79735

Added: 
    

Modified: 
    clang/lib/Frontend/CompilerInvocation.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index ec415472ea3c..2d6f4be6885e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2454,7 +2454,7 @@ static const StringRef GetInputKindName(InputKind IK) {
 
 static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
                           const TargetOptions &TargetOpts,
-                          PreprocessorOptions &PPOpts, CodeGenOptions &CGOpts,
+                          PreprocessorOptions &PPOpts,
                           DiagnosticsEngine &Diags) {
   // FIXME: Cleanup per-file based stuff.
   LangStandard::Kind LangStd = LangStandard::lang_unspecified;
@@ -3188,13 +3188,21 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   Opts.UnsafeFPMath = Args.hasArg(OPT_menable_unsafe_fp_math) ||
                       Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
                       Args.hasArg(OPT_cl_fast_relaxed_math);
-  Opts.AllowFPReassoc = Opts.FastMath || CGOpts.Reassociate;
-  Opts.NoHonorNaNs =
-      Opts.FastMath || CGOpts.NoNaNsFPMath || Opts.FiniteMathOnly;
-  Opts.NoHonorInfs =
-      Opts.FastMath || CGOpts.NoInfsFPMath || Opts.FiniteMathOnly;
-  Opts.NoSignedZero = Opts.FastMath || CGOpts.NoSignedZeros;
-  Opts.AllowRecip = Opts.FastMath || CGOpts.ReciprocalMath;
+  Opts.AllowFPReassoc = Opts.FastMath || Args.hasArg(OPT_mreassociate);
+  Opts.NoHonorNaNs = Opts.FastMath || Opts.FiniteMathOnly ||
+                     Args.hasArg(OPT_menable_no_nans) ||
+                     Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+                     Args.hasArg(OPT_cl_finite_math_only) ||
+                     Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoHonorInfs = Opts.FastMath || Opts.FiniteMathOnly ||
+                     Args.hasArg(OPT_menable_no_infinities) ||
+                     Args.hasArg(OPT_cl_finite_math_only) ||
+                     Args.hasArg(OPT_cl_fast_relaxed_math);
+  Opts.NoSignedZero = Opts.FastMath || (Args.hasArg(OPT_fno_signed_zeros) ||
+                      Args.hasArg(OPT_cl_no_signed_zeros) ||
+                      Args.hasArg(OPT_cl_unsafe_math_optimizations) ||
+                      Args.hasArg(OPT_cl_fast_relaxed_math));
+  Opts.AllowRecip = Opts.FastMath || Args.hasArg(OPT_freciprocal_math);
   // Currently there's no clang option to enable this individually
   Opts.ApproxFunc = Opts.FastMath;
 
@@ -3652,7 +3660,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
     // Other LangOpts are only initialized when the input is not AST or LLVM IR.
     // FIXME: Should we really be calling this for an Language::Asm input?
     ParseLangArgs(LangOpts, Args, DashX, Res.getTargetOpts(),
-                  Res.getPreprocessorOpts(), Res.getCodeGenOpts(), Diags);
+                  Res.getPreprocessorOpts(), Diags);
     if (Res.getFrontendOpts().ProgramAction == frontend::RewriteObjC)
       LangOpts.ObjCExceptions = 1;
     if (T.isOSDarwin() && DashX.isPreprocessed()) {


        


More information about the cfe-commits mailing list