diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 1689c79a709cad7a0abf7b3892ea205a021c6b64..71664b8d3c0225d0135787f018688b7023ca1568 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1293,17 +1293,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, case Builtin::BIpow: case Builtin::BIpowf: case Builtin::BIpowl: { - // Transform a call to pow* into a @llvm.pow.* intrinsic call, but only - // if the target agrees. - if (getTargetHooks().emitIntrinsicForPow()) { - if (!FD->hasAttr<ConstAttr>()) - break; - Value *Base = EmitScalarExpr(E->getArg(0)); - Value *Exponent = EmitScalarExpr(E->getArg(1)); - llvm::Type *ArgType = Base->getType(); - Value *F = CGM.getIntrinsic(Intrinsic::pow, ArgType); - return RValue::get(Builder.CreateCall2(F, Base, Exponent)); - } + // Transform a call to pow* into a @llvm.pow.* intrinsic call. + if (!FD->hasAttr<ConstAttr>()) + break; + Value *Base = EmitScalarExpr(E->getArg(0)); + Value *Exponent = EmitScalarExpr(E->getArg(1)); + llvm::Type *ArgType = Base->getType(); + Value *F = CGM.getIntrinsic(Intrinsic::pow, ArgType); + return RValue::get(Builder.CreateCall2(F, Base, Exponent)); break; } diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp index a8861cf4500c8a49861a0d14c2e544633b342cf8..183aefe00cd512674cf6a0c3cf1fdf90eddab1c2 100644 --- a/lib/CodeGen/TargetInfo.cpp +++ b/lib/CodeGen/TargetInfo.cpp @@ -443,10 +443,6 @@ class PNaClTargetCodeGenInfo : public TargetCodeGenInfo { public: PNaClTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT) : TargetCodeGenInfo(new PNaClABIInfo(CGT)) {} - - /// For PNaCl we don't want llvm.pow.* intrinsics to be emitted instead - /// of library function calls. - bool emitIntrinsicForPow() const { return false; } }; void PNaClABIInfo::computeInfo(CGFunctionInfo &FI) const { diff --git a/lib/CodeGen/TargetInfo.h b/lib/CodeGen/TargetInfo.h index 1be7f4dfa45920a6df0d9702976731b8c8bf70f6..a7fb88649a3ea2a9b62d92e4151f4c250a1f1321 100644 --- a/lib/CodeGen/TargetInfo.h +++ b/lib/CodeGen/TargetInfo.h @@ -74,10 +74,6 @@ namespace clang { /// through such registers. virtual bool extendPointerWithSExt() const { return false; } - /// Controls whether BIpow* emit an intrinsic call instead of a library - /// function call. - virtual bool emitIntrinsicForPow() const { return true; } - /// Determines the DWARF register number for the stack pointer, for /// exception-handling purposes. Implements __builtin_dwarf_sp_column. /// diff --git a/test/CodeGen/le32-libcall-pow.c b/test/CodeGen/le32-libcall-pow.c index c2f892c3aebd9fa50f3f142aa63255cc0a01b06b..24a1bbc38c4e4711a451a6cc328622e114049772 100644 --- a/test/CodeGen/le32-libcall-pow.c +++ b/test/CodeGen/le32-libcall-pow.c @@ -1,7 +1,13 @@ -// RUN: %clang_cc1 -fmath-errno -emit-llvm -o - %s -triple le32-unknown-nacl | FileCheck %s -// RUN: %clang_cc1 -emit-llvm -o - %s -triple le32-unknown-nacl | FileCheck %s +// RUN: %clang_cc1 -fno-math-builtin -fmath-errno -emit-llvm -o - %s -triple le32-unknown-nacl | FileCheck %s +// RUN: %clang_cc1 -fno-math-builtin -emit-llvm -o - %s -triple le32-unknown-nacl | FileCheck %s -// le32 (PNaCl) never generates intrinsics for pow calls, with or without errno +// le32 (PNaCl) never generates intrinsics for pow calls, with or without +// errno, when the -fno-math-builtin flag is passed to -cc1. A separate test +// makes sure this flag is indeed passed for le32. + +float powf(float, float); +double pow(double, double); +long double powl(long double, long double); // CHECK: define void @test_pow void test_pow(float a0, double a1, long double a2) {