]> granicus.if.org Git - clang/commitdiff
Prep for future __builtin_object_size refinements. The theory is that
authorMike Stump <mrs@apple.com>
Mon, 26 Oct 2009 23:39:48 +0000 (23:39 +0000)
committerMike Stump <mrs@apple.com>
Mon, 26 Oct 2009 23:39:48 +0000 (23:39 +0000)
someone will add an llvm intrinsic for us to use, so the optimizer can
figure out the hard cases.  WIP.

For those that want to help, double check with Eric before starting.
He has a bit of code this will plug into.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85175 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGBuiltin.cpp

index 987cd24e2c8b5fc8580e0f515e0c5b6c3c58c1bc..29b46611e2e71ea6b4b170cd5701e94f824b2837 100644 (file)
@@ -199,6 +199,16 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
     return RValue::get(Builder.CreateCall(F, ArgValue, "tmp"));
   }
   case Builtin::BI__builtin_object_size: {
+    // FIXME: We're awaiting the llvm intrincis.
+#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);
+#else
     // FIXME: Implement. For now we just always fail and pretend we
     // don't know the object size.
     llvm::APSInt TypeArg = E->getArg(1)->EvaluateAsInt(CGM.getContext());
@@ -207,6 +217,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
     bool UseMinimum = TypeArg.getZExtValue() & 2;
     return RValue::get(
       llvm::ConstantInt::get(ResType, UseMinimum ? 0 : -1LL));
+#endif
   }
   case Builtin::BI__builtin_prefetch: {
     Value *Locality, *RW, *Address = EmitScalarExpr(E->getArg(0));