[clang] Fix math-errno issue (PR #66381)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 15 13:06:45 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) {
----------------
andykaylor 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.
I'm more concerned about the fact that Sema is marking calls as const in the AST based on the builtins information but we later discover that they aren't, in fact, const because of a pragma being used. @AaronBallman do you have any ideas about how that could be improved?
https://github.com/llvm/llvm-project/pull/66381
More information about the cfe-commits
mailing list