Message ID | CAFiYyc3d6EptDN9bG1QoZ8D3yPecRr6frXNtKScHmxvzA0QyUA@mail.gmail.com |
---|---|
State | New |
Headers | show |
> > 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. Thanks, Honza
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
> 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? I was poking around this last week with the type identification. C frontend seems always make the type complete by copying the fields in c-decl.c:finish_struct. I tried to add check that types are complete when main variant is and learnt that C++ FE seems in some cases leave the type incomplete even if main variant is complete but not in such a simple cases. I will look into it a bit more after arrival - but that is my recollection. The finish_builtin_struct was only case where we set DECL_SIZE but not DECL_FIELDS Honza > > Richard. > > >Thanks, > >Honza >
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