This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix representation of gcov_info_type
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 08 Jul 2014 16:51:41 +0200
- Subject: Re: Fix representation of gcov_info_type
- Authentication-results: sourceware.org; auth=none
- References: <20140628182230 dot GA2531 at kam dot mff dot cuni dot cz> <CAFiYyc0E6O=86FwEUVzgrOewOUXQ3DYnm64wd_Br7Y6+xcHEGA at mail dot gmail dot com> <20140708002540 dot GE12716 at kam dot mff dot cuni dot cz> <CAFiYyc3d6EptDN9bG1QoZ8D3yPecRr6frXNtKScHmxvzA0QyUA at mail dot gmail dot com> <20140708140304 dot GD27691 at kam dot mff dot cuni dot cz>
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