[llvm-commits] [llvm-gcc-4.2] r86371 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Eric Christopher
echristo at apple.com
Sat Nov 7 01:57:16 PST 2009
Author: echristo
Date: Sat Nov 7 03:57:16 2009
New Revision: 86371
URL: http://llvm.org/viewvc/llvm-project?rev=86371&view=rev
Log:
Third time is the charm. Enable __builtin_object_size
codegen via intrinsic. Coerce return type to size_t.
Tested via bootstrap on x86-darwin10.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=86371&r1=86370&r2=86371&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Sat Nov 7 03:57:16 2009
@@ -4909,12 +4909,12 @@
return EmitBuiltinUnwindInit(exp, Result);
case BUILT_IN_OBJECT_SIZE: {
- tree ArgList = TREE_OPERAND (exp, 1);
- if (!validate_arglist(ArgList, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) {
+ tree arglist = TREE_OPERAND (exp, 1);
+ if (!validate_arglist(arglist, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) {
error("Invalid builtin_object_size argument types");
return false;
}
- tree ObjSizeTree = TREE_VALUE (TREE_CHAIN (ArgList));
+ tree ObjSizeTree = TREE_VALUE (TREE_CHAIN (arglist));
STRIP_NOPS (ObjSizeTree);
if (TREE_CODE (ObjSizeTree) != INTEGER_CST
|| tree_int_cst_sgn (ObjSizeTree) < 0
@@ -4923,12 +4923,26 @@
return false;
}
- // This treats everything as unknown, and is minimally defensible as
- // correct, although completely useless.
- if (tree_low_cst (ObjSizeTree, 0) < 2)
- Result = Constant::getAllOnesValue(TD.getIntPtrType(Context));
- else
- Result = ConstantInt::get(TD.getIntPtrType(Context), 0);
+ tree Object = TREE_VALUE(arglist);
+ tree ObjTy = TREE_VALUE(TREE_CHAIN(arglist));
+
+ Value* Args[] = {
+ Emit(Object, 0),
+ Emit(ObjTy, 0)
+ };
+
+ // Grab the current return type.
+ const Type* Ty;
+ Ty = ConvertType(TREE_TYPE(exp));
+
+ // Manually coerce the arg to the correct pointer type.
+ Args[0] = Builder.CreateBitCast(Args[0], Type::getInt8PtrTy(Context));
+
+ Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule,
+ Intrinsic::objectsize,
+ &Ty,
+ 1),
+ Args, Args + 2);
return true;
}
// Unary bit counting intrinsics.
More information about the llvm-commits
mailing list