[clang] [NFC] Refactor fast-math handling for clang driver (PR #81173)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 8 14:44:05 PST 2024
================
@@ -2842,9 +2862,8 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
<< Args.MakeArgString("-ffp-model=" + FPModel)
<< Args.MakeArgString("-ffp-model=" + Val);
if (Val.equals("fast")) {
- optID = options::OPT_ffast_math;
FPModel = Val;
- FPContract = "fast";
+ applyFastMath();
----------------
andykaylor wrote:
I just re-read you comment, and I think I see the confusion now. The previous code was not easy to follow. We were changing the value of optID here, so when we finished with this switch statement execution would continue on to the switch statement below where the "whole pile of flags" was being set by the OPT_ffast_math handler. Now I'm not changing the value of optID here and instead calling the lambda to set the pile of flags. In a future revision I'd like to add a parameter to the lambda to indicate that I want slightly less aggressive fast math settings.
I started out with a change that chained all the OPT_ffast_math, OPT_fno_fast_math, OPT_funsafe_math_optimizations, and OPT_fno_unsafe_math_optimizations into a pair of nested lambdas with a parameter for positive and negative versions, but that got way too convoluted to handle all the variations needed to make it NFC. I think that pointed to some things we're doing wrong, but I'll address those separately to keep the history clean. This seemed like a manageable place to start.
https://github.com/llvm/llvm-project/pull/81173
More information about the cfe-commits
mailing list