mibintc created this revision. mibintc added reviewers: plotfi, rjmccall. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This bug was observed by Apple since their compiler processes LangOpts and CGOpts in a different order Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D79735 Files: clang/lib/Frontend/CompilerInvocation.cpp Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -2454,7 +2454,7 @@ 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 @@ 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; @@ -3650,7 +3658,7 @@ // 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()) {
Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -2454,7 +2454,7 @@ 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 @@ 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; @@ -3650,7 +3658,7 @@ // 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()) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits