llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-clang Author: Allen (vfdff) <details> <summary>Changes</summary> Follow PR96025, except expf, more FP math libcalls in libm should also be supported. Fix https://github.com/llvm/llvm-project/issues/86635 --- Full diff: https://github.com/llvm/llvm-project/pull/100302.diff 1 Files Affected: - (modified) clang/lib/CodeGen/CGBuiltin.cpp (+7-8) ``````````diff diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index a0d03b87ccdc9..a9696ebe61e3a 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -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()) return true; - } - // TODO: support more FP math libcalls return false; }(); // Restrict to target with errno, for example, MacOS doesn't set errno. if (IsErrnoIntrinsic && CGF.CGM.getLangOpts().MathErrno && !CGF.Builder.getIsFPConstrained()) { - ASTContext &Context = CGF.getContext(); // Emit "int" TBAA metadata on FP math libcalls. clang::QualType IntTy = Context.IntTy; TBAAAccessInfo TBAAInfo = CGF.CGM.getTBAAAccessInfo(IntTy); `````````` </details> https://github.com/llvm/llvm-project/pull/100302 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits