[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 25 04:16:12 PDT 2024


================
@@ -692,23 +692,22 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *FD,
   RValue Call =
       CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
 
-  // Check the supported intrinsic.
+  ASTContext &Context = CGF.getContext();
   if (unsigned BuiltinID = FD->getBuiltinID()) {
     auto IsErrnoIntrinsic = [&]() -> unsigned {
-      switch (BuiltinID) {
-      case Builtin::BIexpf:
-      case Builtin::BI__builtin_expf:
-      case Builtin::BI__builtin_expf128:
+      // Check whether a FP math builtin function, such as BI__builtin_expf
+      QualType ResultTy = FD->getReturnType();
+      bool IsMathLibCall =
+          Context.BuiltinInfo.isLibFunction(BuiltinID) ||
+          Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID);
+      if (IsMathLibCall && CGF.ConvertType(ResultTy)->isFloatingPointTy())
----------------
vfdff wrote:

No , we expect it works without explicit disable the MathErrno, just similar to the behavior of gcc, https://gcc.godbolt.org/z/rsbqsGWMv. it is discussed on [discourse](https://discourse.llvm.org/t/fp-can-we-add-pure-attribute-for-math-library-functions-default/79459/6?u=allen)

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


More information about the cfe-commits mailing list