[cfe-commits] r104281 - in /cfe/trunk: lib/CodeGen/CGExprCXX.cpp test/CodeGenObjC/objc-gc-aggr-assign.m

Fariborz Jahanian fjahanian at apple.com
Thu May 20 15:12:52 PDT 2010


On May 20, 2010, at 2:44 PM, Douglas Gregor wrote:

>
> On May 20, 2010, at 2:38 PM, Fariborz Jahanian wrote:
>
>> Author: fjahanian
>> Date: Thu May 20 16:38:57 2010
>> New Revision: 104281
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=104281&view=rev
>> Log:
>> Adds support for generation of objc_memmove_collectable API
>> in Objective-C++ mode.
>
> Should EmitAggregateCopy have this functionality internally, rather  
> than teaching all its callers to generate the different APIs?

objc_memmove_collectable is a write-barrier and is to be generated for  
assignments only. I initially looked at call sites for  
EmitAggregateCopy and
it is called in many other cases where a copy is needed. So, I did not  
put it there.

>
>
> Also, it looks like the HasObjectMember bit isn't propagated from  
> base classes to derived classes, e.g.,
>
>  struct Base {
>    NSObject *object;
>  };
>
>  struct Derived : Base { }; // won't have HasObjectMember bit set?

This is a valid point. g++ does not do this; neither does clang. I  
will bring it up with the group.
It is probably harmless to add.

- Fariborz

>
>
> 	- Doug
>
>>
>> Added:
>>   cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m
>> Modified:
>>   cfe/trunk/lib/CodeGen/CGExprCXX.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=104281&r1=104280&r2=104281&view=diff
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Thu May 20 16:38:57 2010
>> @@ -12,6 +12,7 @@
>> // 
>> = 
>> = 
>> = 
>> ----------------------------------------------------------------------= 
>> ==//
>>
>> #include "CodeGenFunction.h"
>> +#include "CGObjCRuntime.h"
>> using namespace clang;
>> using namespace CodeGen;
>>
>> @@ -274,7 +275,10 @@
>>
>>      llvm::Value *Src = EmitLValue(E->getArg(1)).getAddress();
>>      QualType Ty = E->getType();
>> -      EmitAggregateCopy(This, Src, Ty);
>> +      if (ClassDecl->hasObjectMember())
>> +        CGM.getObjCRuntime().EmitGCMemmoveCollectable(*this, This,  
>> Src, Ty);
>> +      else
>> +        EmitAggregateCopy(This, Src, Ty);
>>      return RValue::get(This);
>>    }
>>  }
>>
>> Added: cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m?rev=104281&view=auto
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m (added)
>> +++ cfe/trunk/test/CodeGenObjC/objc-gc-aggr-assign.m Thu May 20  
>> 16:38:57 2010
>> @@ -0,0 +1,48 @@
>> +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit- 
>> llvm -o %t %s
>> +// RUN: grep objc_memmove_collectable %t | grep call | count 3
>> +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 - 
>> fobjc-gc -emit-llvm -o %t %s
>> +// RUN: grep objc_memmove_collectable %t | grep call | count 3
>> +
>> +static int count;
>> +
>> +typedef struct S {
>> +   int ii;
>> +} SS;
>> +
>> +struct type_s {
>> +   SS may_recurse;
>> +   id id_val;
>> +};
>> +
>> + at interface NamedObject
>> +{
>> +  struct type_s type_s_ivar;
>> +}
>> +- (void) setSome : (struct type_s) arg;
>> +- (struct type_s) getSome;
>> + at property(assign) struct type_s aggre_prop;
>> + at end
>> +
>> + at implementation NamedObject
>> +- (void) setSome : (struct type_s) arg
>> +  {
>> +     type_s_ivar = arg;
>> +  }
>> +- (struct type_s) getSome
>> +  {
>> +    return type_s_ivar;
>> +  }
>> + at synthesize aggre_prop = type_s_ivar;
>> + at end
>> +
>> +struct type_s some = {{1234}, (id)0};
>> +
>> +struct type_s get(void)
>> +{
>> +  return some;
>> +}
>> +
>> +void f(const struct type_s *in, struct type_s *out) {
>> +  *out = *in;
>> +}
>> +
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list