[clang] Remove FiniteMathOnly and use only NoHonorINFs and NoHonorNANs. (PR #97342)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 15 11:12:49 PDT 2024


================
@@ -3298,7 +3298,18 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
   }
 
   // Handle __FINITE_MATH_ONLY__ similarly.
-  if (!HonorINFs && !HonorNaNs)
+  bool InfValues = true;
+  bool NanValues = true;
+  auto processArg = [&](const auto *Arg) {
+    if (StringRef(Arg->getValue()) == "-menable-no-nans")
+      NanValues = false;
+    if (StringRef(Arg->getValue()) == "-menable-no-infs")
+      InfValues = false;
+  };
+  for (auto *Arg : Args.filtered(options::OPT_Xclang))
+    processArg(Arg);
----------------
AaronBallman wrote:

That could work, I was thinking along these lines:
```
  // Explanation of why we need to do this dance goes here.
  auto NaNsAndInfs = [&] {
    bool InfValues = true;
    bool NanValues = true;
    auto processArg = [&](const auto *Arg) {
      if (StringRef(Arg->getValue()) == "-menable-no-nans")
        NanValues = false;
      if (StringRef(Arg->getValue()) == "-menable-no-infs")
        InfValues = false;
    };

    for (auto *Arg : Args.filtered(options::OPT_Xclang))
      processArg(Arg);

    return InfValues && NanValues;
  };

  if ((!HonorINFs && !HonorNaNs) || !NaNsAndInfs())
    CmdArgs.push_back("-ffinite-math-only");
```
I leave it to driver folks to say what they'd prefer if they have a strong preference.

https://github.com/llvm/llvm-project/pull/97342


More information about the cfe-commits mailing list