Sure, We need to call CodeGenPGO::assignRegionCounters for all functions
because we want to emit counter variables for all functions in a
translation unit, even if they aren't used. Currently static functions, and
also class methods defined inside a class and inline methods defined
outside of class aren't processed by assignRegionCounters when they aren't
used. Therefore we have to emit those functions so that the profile
counters are also emitted for them.


2014-05-28 12:23 GMT-07:00 Reid Kleckner <[email protected]>:

> Can you explain why this works at all?  Why aren't the counters emitted as
> linkonce_odr globals?
>
>
> On Tue, May 27, 2014 at 4:39 PM, Alex L <[email protected]> wrote:
>
>> This is needed to ensure that the profile counters are emitted
>> for all functions and methods.
>>
>>
>> -------------- next part --------------
>> Index: lib/CodeGen/CodeGenModule.cpp
>> ===================================================================
>>
>> --- lib/CodeGen/CodeGenModule.cpp    (revision 209698)
>> +++ lib/CodeGen/CodeGenModule.cpp    (working copy)
>> @@ -1073,6 +1073,8 @@
>>    if (LangOpts.EmitAllDecls)
>>      return false;
>>
>> +  if(CodeGenOpts.ProfileInstrGenerate && isa<FunctionDecl>(Global))
>>
>>
>> +    return false;
>>    return !getContext().DeclMustBeEmitted(Global);
>>  }
>>
>> @@ -3028,6 +3030,16 @@
>>      break;
>>
>>    // C++ Decls
>> +  case Decl::CXXRecord: {
>> +    if(!CodeGenOpts.ProfileInstrGenerate)
>>
>>
>> +      break;
>> +    CXXRecordDecl *Record = cast<CXXRecordDecl>(D);
>> +    for(CXXRecordDecl::method_iterator I = Record->method_begin(); I != 
>> Record->method_end(); ++I) {
>> +      if(I->hasBody())
>>
>> +        EmitTopLevelDecl(*I);
>>
>> +    }
>> +    break;
>> +  }
>>    case Decl::Namespace:
>>      EmitNamespace(cast<NamespaceDecl>(D));
>>      break;
>>
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to