aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Bendersky <eliben@chromium.org>2013-06-27 14:49:34 -0700
committerEli Bendersky <eliben@chromium.org>2013-06-27 14:49:34 -0700
commit192dd614d8d7291768f808bbd6ad8f1a98d62c57 (patch)
tree69fea5c2e220fac8ca55b8bdd4704fe30a92c546
parent8f0218fcec810b1178a0515843aceef43a339869 (diff)
Clang should not generate calls to llvm.pow.* intrinsics.
Instead, it should generate calls to the pow* library functions, which get found within the pexe. This is a LOCALMOD for now, but I'm working on a more generic solution that can be upstreamed to Clang. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3513 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/18135002
-rw-r--r--lib/CodeGen/CGBuiltin.cpp13
-rw-r--r--test/CodeGen/libcalls.c15
2 files changed, 13 insertions, 15 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index 9e09131a53..7f1709e10f 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -1293,14 +1293,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
case Builtin::BIpow:
case Builtin::BIpowf:
case Builtin::BIpowl: {
- // Rewrite sqrt to intrinsic if allowed.
- 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));
+ // 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
+ break;
}
case Builtin::BIfma:
diff --git a/test/CodeGen/libcalls.c b/test/CodeGen/libcalls.c
index 8f8e18226a..87e0592337 100644
--- a/test/CodeGen/libcalls.c
+++ b/test/CodeGen/libcalls.c
@@ -31,25 +31,27 @@ void test_sqrt(float a0, double a1, long double a2) {
// CHECK-YES: define void @test_pow
// CHECK-NO: define void @test_pow
void test_pow(float a0, double a1, long double a2) {
+ // LOCALMOD: for PNaCl we generate lib calls and not intrinsics, even without
+ // errno. For more details see the LOCALMOD in lib/CodeGen/CGBuiltin.cpp
// CHECK-YES: call float @powf
- // CHECK-NO: call float @llvm.pow.f32
+ // CHECK-NO: call float @powf
float l0 = powf(a0, a0);
// CHECK-YES: call double @pow
- // CHECK-NO: call double @llvm.pow.f64
+ // CHECK-NO: call double @pow
double l1 = pow(a1, a1);
// CHECK-YES: call x86_fp80 @powl
- // CHECK-NO: call x86_fp80 @llvm.pow.f80
+ // CHECK-NO: call x86_fp80 @powl
long double l2 = powl(a2, a2);
}
// CHECK-YES: declare float @powf(float, float)
// CHECK-YES: declare double @pow(double, double)
// CHECK-YES: declare x86_fp80 @powl(x86_fp80, x86_fp80)
-// CHECK-NO: declare float @llvm.pow.f32(float, float) [[NUW_RO:#[0-9]+]]
-// CHECK-NO: declare double @llvm.pow.f64(double, double) [[NUW_RO]]
-// CHECK-NO: declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80) [[NUW_RO]]
+// CHECK-NO: declare float @powf(float, float)
+// CHECK-NO: declare double @pow(double, double)
+// CHECK-NO: declare x86_fp80 @powl(x86_fp80, x86_fp80)
// CHECK-YES: define void @test_fma
// CHECK-NO: define void @test_fma
@@ -122,4 +124,3 @@ void test_builtins(double d, float f, long double ld) {
// CHECK-YES: attributes [[NUW_RN]] = { nounwind readnone }
// CHECK-NO: attributes [[NUW_RN]] = { nounwind readnone{{.*}} }
-// CHECK-NO: attributes [[NUW_RO]] = { nounwind readonly }