[clang] Fix math-errno issue (PR #66381)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 15 13:10:42 PDT 2023
================
@@ -2339,6 +2345,28 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
// LLVM counterparts if the call is marked 'const' (known to never set errno).
// In case FP exceptions are enabled, the experimental versions of the
// intrinsics model those.
+ bool ConstAlways =
+ getContext().BuiltinInfo.isConst(BuiltinID);
+
+ // There's a special case with the fma builtins where they are always const
+ // if the target environment is GNU or the target is OS is Windows and we're
+ // targeting the MSVCRT.dll environment.
+ switch (BuiltinID) {
----------------
zahiraam wrote:
> @zahiraam I think the best way to do that would be to add a new letter vcode to the attributes here:
>
> https://github.com/llvm/llvm-project/blob/cbdccb30c23f71f20d05b19256232419e7c5e517/clang/include/clang/Basic/Builtins.def#L74
>
> -- something like "// m -> const when we GNU or MSVCRT libraries are targeted" and then fma, for example, would become "BUILTIN(__builtin_fma, "dddd", "Fmne")"
> I'd suggest doing that as a separate patch, because it isn't obvious exactly how it should be managed.
>
Yes, I can work on that in a subsequent patch. Will keep the FIXME comment then.
https://github.com/llvm/llvm-project/pull/66381
More information about the cfe-commits
mailing list