[PATCH] D39481: [CodeGen] fix const-ness of builtin equivalents of <math.h> and <complex.h> functions that might set errno
Hal Finkel via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 2 11:10:21 PDT 2017
hfinkel added a comment.
In https://reviews.llvm.org/D39481#914174, @craig.topper wrote:
> There's an oddity with fma. The version without __builtin has 'e' already
Something that is potentially relevant: POSIX says that fma() can set errno (http://pubs.opengroup.org/onlinepubs/9699919799/functions/fma.html), however, the glibc man page says that its fma() does not set errno (https://linux.die.net/man/3/fma).
>
>
> LIBBUILTIN(fma, "dddd", "fne", "math.h", ALL_LANGUAGES)
> LIBBUILTIN(fmaf, "ffff", "fne", "math.h", ALL_LANGUAGES)
> LIBBUILTIN(fmal, "LdLdLdLd", "fne", "math.h", ALL_LANGUAGES)
>
>
> But we don't check the const attribute in CGBuiltin.cpp before converting it to an intrinsic
>
> case Builtin::BIfma:
> case Builtin::BIfmaf:
> case Builtin::BIfmal:
> case Builtin::BI__builtin_fma:
> case Builtin::BI__builtin_fmaf:
> case Builtin::BI__builtin_fmal: {
> // Rewrite fma to intrinsic.
> Value *FirstArg = EmitScalarExpr(E->getArg(0));
> llvm::Type *ArgType = FirstArg->getType();
> Value *F = CGM.getIntrinsic(Intrinsic::fma, ArgType);
> return RValue::get(
> Builder.CreateCall(F, {FirstArg, EmitScalarExpr(E->getArg(1)),
> EmitScalarExpr(E->getArg(2))}));
> }
>
https://reviews.llvm.org/D39481
More information about the cfe-commits
mailing list