================ @@ -707,7 +707,39 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const FunctionDecl *FD, const CallExpr *E, llvm::Constant *calleeValue) { CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E); CGCallee callee = CGCallee::forDirect(calleeValue, GlobalDecl(FD)); - return CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot()); + RValue Call = + CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot()); + + // Check the supported intrinsic. + if (unsigned BuiltinID = FD->getBuiltinID()) { + auto IntrinsicID = [&]() -> unsigned { + switch (BuiltinID) { + case Builtin::BIexpf: + case Builtin::BI__builtin_expf: + case Builtin::BI__builtin_expf128: + return true; + } + // TODO: support more FP math libcalls + return false; + }(); + + // Restrict to target with errno, for example, MacOS doesn't set errno. + if (IntrinsicID && CGF.CGM.getLangOpts().MathErrno) { + llvm::MDBuilder MDHelper(CGF.getLLVMContext()); + ASTContext &Context = CGF.getContext(); + // Emit "int" TBAA metadata on FP math libcalls. + clang::QualType IntTy = Context.IntTy; + MDNode *AliasType = CGF.CGM.getTBAATypeInfo(IntTy); + MDNode *MDInt = MDHelper.createTBAAStructTagNode(AliasType, AliasType, 0); ---------------- vfdff wrote:
Apply your comment, thanks very much https://github.com/llvm/llvm-project/pull/96025 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits