__builtin_object_size refinements. Ensure we handle expressions with
side-effects up front, as when we switch to the llvm intrinsic call
for __builtin_object_size later, it will have two evaluations.
We also finish off the intrinsic version of the code so we can just
turn it on once llvm has the intrinsic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85324 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index 29b4661..c269219 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -203,11 +203,13 @@
#if 0
// We pass this builtin onto the optimizer so that it can
// figure out the object size in more complex cases.
- Value *F = CGM.getIntrinsic(Intrinsic::objectsize, 0, 0);
- Builder.CreateCall2(F,
- EmitScalarExpr(E->getArg(0)));
- EmitScalarExpr(E->getArg(1)));
- return RValue::get(Address);
+ const llvm::Type *ResType[] = {
+ ConvertType(E->getType())
+ };
+ Value *F = CGM.getIntrinsic(Intrinsic::objectsize, ResType, 1);
+ return RValue::get(Builder.CreateCall2(F,
+ EmitScalarExpr(E->getArg(0)),
+ EmitScalarExpr(E->getArg(1))));
#else
// FIXME: Implement. For now we just always fail and pretend we
// don't know the object size.