diff options
author | Eli Bendersky <eliben@chromium.org> | 2013-07-10 08:54:29 -0700 |
---|---|---|
committer | Eli Bendersky <eliben@chromium.org> | 2013-07-10 08:54:29 -0700 |
commit | f69ebb4201da8bb5045f9335150ed6ef6bcfc2cc (patch) | |
tree | 6d0ef75997255e633806335ddf7e8647dbcd5459 /lib/CodeGen/CGBuiltin.cpp | |
parent | 3ae70608405cf8180c89f8d3393049b4acd58104 (diff) |
Cherry-picking the pow-for-le32 fix from upstream clang.
SVN log from upstream clang:
r185568 | eliben | 2013-07-03 12:19:12 -0700 (Wed, 03 Jul 2013)
Add target hook CodeGen queries when generating builtin pow*.
Without fmath-errno, Clang currently generates calls to @llvm.pow.* intrinsics
when it sees pow*(). This may not be suitable for all targets (for
example le32/PNaCl), so the attached patch adds a target hook that CodeGen
queries. The target can state its preference for having or not having the
intrinsic generated. Non-PNaCl behavior remains unchanged;
PNaCl-specific test added.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3513
R=dschuff@chromium.org
Review URL: https://codereview.chromium.org/18953003
Diffstat (limited to 'lib/CodeGen/CGBuiltin.cpp')
-rw-r--r-- | lib/CodeGen/CGBuiltin.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 7f1709e10f..0d5be26a5e 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1293,10 +1293,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD, case Builtin::BIpow: case Builtin::BIpowf: case Builtin::BIpowl: { - // LOCALMOD: For PNACl we don't want pow* calls to ever turn into - // intrinsics. We want them to be resolved vs. the newlib implementation - // within the pexe during bitcode linking. - // TODO(eliben): upstream this + // 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)); + } break; } |