[cfe-commits] r66854 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/objc2-strong-cast.m
Daniel Dunbar
daniel at zuster.org
Sat Mar 14 22:50:23 PDT 2009
Hi Fariborz,
Two comments:
1. There is a lot of duplicate code here! First, can these methods move into
the common base class? Second, why not have a single function which does
this work and takes the function to call as a parameter.
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Thu Mar 12 19:42:52 2009
> @@ -2239,6 +2239,10 @@
> void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
> llvm::Value *src, llvm::Value *dst)
> {
> + if (!isa<llvm::PointerType>(src->getType())) {
> + src = CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy);
> + src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
> + }
> src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
2. The inttoptr instruction can cast from an arbitrary integer type, there
is no need to explicitly cast to long. This could could look like:
--
if (!isa<llvm::PointerType>(src->getType()))
src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.ObjectPtrTy);
else
src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
--
- Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20090314/6ba513a2/attachment.html>
More information about the cfe-commits
mailing list