[cfe-commits] r167374 - in /cfe/trunk: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/arc-captured-block-var-inlined-layout.m test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m

Fariborz Jahanian fjahanian at apple.com
Sun Nov 11 11:26:28 PST 2012


On Nov 10, 2012, at 4:13 PM, John McCall wrote:

> On Nov 4, 2012, at 10:19 AM, Fariborz Jahanian wrote:
>> Author: fjahanian
>> Date: Sun Nov  4 12:19:40 2012
>> New Revision: 167374
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=167374&view=rev
>> Log:
>> Fixes liftime of captured block variables in mrr mode, per John's feedback, as
>> well as couple of tests which were not being excercised because of TYPOs.
>> 
>> Modified:
>>   cfe/trunk/lib/CodeGen/CGObjCMac.cpp
>>   cfe/trunk/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m
>>   cfe/trunk/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=167374&r1=167373&r2=167374&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun Nov  4 12:19:40 2012
>> @@ -942,7 +942,7 @@
>>                           unsigned int BytePos, bool ForStrongLayout,
>>                           bool &HasUnion);
>> 
>> -  Qualifiers::ObjCLifetime GetObjCLifeTime(QualType QT);
>> +  Qualifiers::ObjCLifetime getBlockCaptureLifetime(QualType QT);
>> 
>>  void UpdateRunSkipBlockVars(bool IsByref,
>>                              Qualifiers::ObjCLifetime LifeTime,
>> @@ -1964,21 +1964,16 @@
>>  return C;
>> }
>> 
>> -Qualifiers::ObjCLifetime CGObjCCommonMac::GetObjCLifeTime(QualType FQT) {
>> +/// getBlockCaptureLifetime - This routine returns life time of the captured
>> +/// block variable for the purpose of block layout meta-data generation. FQT is
>> +/// the type of the variable captured in the block.
>> +Qualifiers::ObjCLifetime CGObjCCommonMac::getBlockCaptureLifetime(QualType FQT) {
>>  if (CGM.getLangOpts().ObjCAutoRefCount)
>>    return FQT.getObjCLifetime();
>> 
>> -  // MRR, is more ad hoc.
>> -  if (FQT.isObjCGCStrong())
>> -    return Qualifiers::OCL_Strong;
>> -  if (FQT.isObjCGCWeak())
>> -    return Qualifiers::OCL_Weak;
>> -  
>> +  // MRR.
>>  if (FQT->isObjCObjectPointerType() || FQT->isBlockPointerType())
>> -    return Qualifiers::OCL_Strong;
>> -  
>> -  if (const PointerType *PT = FQT->getAs<PointerType>())
>> -    return (GetObjCLifeTime(PT->getPointeeType()));
>> +    return Qualifiers::OCL_ExplicitNone;
> 
> I think I might have been unclear — when a normal variable of one of these
> types is captured in a block in MRR, it basically has __strong semantics.
> It's only __block variables that capture their results with __unsafe_unretained
> semantics.
> 
> So the extended layout for the following block in MRR should describe the
> variable as __strong:
>  NSString *string = foo.title;
>  bar(^(NSWindow *window){ window.title = string; });

OK. This was not mentioned in your initial comment.

> 
> Whereas the extended layout for the following block should describe the
> variable as byref, and the variable's own layout should describe its contents
> as __unsafe_unretained:
>  __block NSString *string;
>  bar(^(NSWindow *window) { string = window.title; });
Yes, 'string' is byref in the layout. But I don't understand what you mean by 'variable's own layout'. 
We are not laying out 'byref' variable's individual fields in the extended layout, only that they are 'byref'.

- Fariborz

> 
> John.





More information about the cfe-commits mailing list