diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -541,6 +541,12 @@ return CGF.Builder.CreateCall(F, Src0); } +static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E, + unsigned IntrinsicID, llvm::StringRef Name) { + llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0)); + return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name); +} + // Emit an intrinsic that has 2 operands of the same type as its result. static Value *emitBinaryBuiltin(CodeGenFunction &CGF, const CallExpr *E, @@ -3128,8 +3134,8 @@ Result = Builder.CreateBinaryIntrinsic( llvm::Intrinsic::abs, Op0, Builder.getFalse(), nullptr, "elt.abs"); else - Result = Builder.CreateUnaryIntrinsic(llvm::Intrinsic::fabs, Op0, nullptr, - "elt.abs"); + Result = emitUnaryBuiltin(*this, E, llvm::Intrinsic::fabs, "elt.abs"); + return RValue::get(Result); }