[llvm-commits] [llvm-gcc-4.2] r85190 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Eric Christopher
echristo at apple.com
Mon Oct 26 17:53:46 PDT 2009
Author: echristo
Date: Mon Oct 26 19:53:46 2009
New Revision: 85190
URL: http://llvm.org/viewvc/llvm-project?rev=85190&view=rev
Log:
Use new objectsize intrinsic for object size checking instead of
folding to "don't know" immediately.
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=85190&r1=85189&r2=85190&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Oct 26 19:53:46 2009
@@ -4976,12 +4976,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
@@ -4990,12 +4990,24 @@
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)
+ };
+
+ const Type* Ty[3];
+ Ty[0] = ConvertType(TREE_TYPE(exp));
+ Ty[1] = Type::getInt8PtrTy(Context);
+ Ty[2] = Type::getInt32Ty(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