This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix representation of gcov_info_type


On July 8, 2014 4:03:05 PM CEST, Jan Hubicka <hubicka@ucw.cz> wrote:
>> 
>> So the issue seems to be:
>> 
>>  gcov_info_type = lang_hooks.types.make_type (RECORD_TYPE);
>>   gcov_fn_info_type = lang_hooks.types.make_type (RECORD_TYPE);
>>   gcov_fn_info_ptr_type = build_pointer_type
>>     (build_qualified_type (gcov_fn_info_type, TYPE_QUAL_CONST));
>>   build_fn_info_type (gcov_fn_info_type, n_counters, gcov_info_type);
>>   build_info_type (gcov_info_type, gcov_fn_info_ptr_type);
>> 
>> that __gcov_info has a member of type const __gcov_info * and that
>> rather than using the equivalent of
>> 
>> struct __gcov_info;
>> typedef const __gcov_info *gcov_fn_info_ptr_type;
>> struct __gcov_info {
>> ...
>>    gcov_fn_info_ptr_type x;
>> };
>> 
>> we build the variant of the yet incomplete struct and complete
>> it later.
>> 
>> Sth like
>> 
>> Index: coverage.c
>> ===================================================================
>> --- coverage.c  (revision 210965)
>> +++ coverage.c  (working copy)
>> @@ -1078,9 +1078,10 @@
>>    /* Build the info and fn_info types.  These are mutually
>recursive.  */
>>    gcov_info_type = lang_hooks.types.make_type (RECORD_TYPE);
>>    gcov_fn_info_type = lang_hooks.types.make_type (RECORD_TYPE);
>> +  build_fn_info_type (gcov_fn_info_type, n_counters,
>gcov_info_type);
>> +  gcov_info_type = lang_hooks.types.make_type (RECORD_TYPE);
>>    gcov_fn_info_ptr_type = build_pointer_type
>>      (build_qualified_type (gcov_fn_info_type, TYPE_QUAL_CONST));
>> -  build_fn_info_type (gcov_fn_info_type, n_counters,
>gcov_info_type);
>>    build_info_type (gcov_info_type, gcov_fn_info_ptr_type);
>> 
>>    /* Build the gcov info var, this is referred to in its own
>
>Hmm, right. I somehow misread it that gcov_info_type variant is built,
>but I
>hope it is not - will double check.  If not, then this should indeed
>work.
>Still do not know how to use current finish_builtin_struct interface
>for case
>where we want to have a structure that contains qualified pointer to
>itself.

You probably can't.  But check what the C frontend ends up producing with

Struct x { const struct x *p; };

Doesn't it use an incomplete copy during the definition of x?

Richard.

>Thanks,
>Honza



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]