Patchwork Fixup T_U_D reading

login
register
mail settings
Submitter Richard Guenther
Date Sept. 17, 2010, 2:13 p.m.
Message ID <alpine.LNX.2.00.1009171612410.28912@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/65081/
State New
Headers show

Comments

Richard Guenther - Sept. 17, 2010, 2:13 p.m.
I forgot to copy the string - we only get a reference to the
string section.  Oops.

Bootstrapped and tested on x86_64-unknown-linux-gnu, committed.

Richard.

2010-09-17  Richard Guenther  <rguenther@suse.de>

	* lto-streamer-in.c (lto_input_ts_translation_unit_decl_tree_pointers):
	Properly copy the read string.
Steven Bosscher - Sept. 17, 2010, 2:19 p.m.
On Fri, Sep 17, 2010 at 4:13 PM, Richard Guenther <rguenther@suse.de> wrote:
>
> I forgot to copy the string - we only get a reference to the
> string section.  Oops.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, committed.
>
> Richard.
>
> 2010-09-17  Richard Guenther  <rguenther@suse.de>
>
>        * lto-streamer-in.c (lto_input_ts_translation_unit_decl_tree_pointers):
>        Properly copy the read string.
>
> Index: gcc/lto-streamer-in.c
> ===================================================================
> --- gcc/lto-streamer-in.c       (revision 164368)
> +++ gcc/lto-streamer-in.c       (working copy)
> @@ -2241,7 +2271,7 @@ lto_input_ts_translation_unit_decl_tree_
>                                                  struct data_in *data_in,
>                                                  tree expr)
>  {
> -  TRANSLATION_UNIT_LANGUAGE (expr) = input_string (data_in, ib);
> +  TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (input_string (data_in, ib));
>   VEC_safe_push (tree, gc, all_translation_units, expr);
>  }

I guess it's not worth sharing the language strings somehow??

Ciao!
Steven
Richard Guenther - Sept. 17, 2010, 2:20 p.m.
On Fri, 17 Sep 2010, Steven Bosscher wrote:

> On Fri, Sep 17, 2010 at 4:13 PM, Richard Guenther <rguenther@suse.de> wrote:
> >
> > I forgot to copy the string - we only get a reference to the
> > string section.  Oops.
> >
> > Bootstrapped and tested on x86_64-unknown-linux-gnu, committed.
> >
> > Richard.
> >
> > 2010-09-17  Richard Guenther  <rguenther@suse.de>
> >
> >        * lto-streamer-in.c (lto_input_ts_translation_unit_decl_tree_pointers):
> >        Properly copy the read string.
> >
> > Index: gcc/lto-streamer-in.c
> > ===================================================================
> > --- gcc/lto-streamer-in.c       (revision 164368)
> > +++ gcc/lto-streamer-in.c       (working copy)
> > @@ -2241,7 +2271,7 @@ lto_input_ts_translation_unit_decl_tree_
> >                                                  struct data_in *data_in,
> >                                                  tree expr)
> >  {
> > -  TRANSLATION_UNIT_LANGUAGE (expr) = input_string (data_in, ib);
> > +  TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (input_string (data_in, ib));
> >   VEC_safe_push (tree, gc, all_translation_units, expr);
> >  }
> 
> I guess it's not worth sharing the language strings somehow??

Well, it's going to be O(number of TUs) strings, so - no.  It might
be worth transitioning LANG_NAME from a string to an enum maybe ;)

Richard.
Jakub Jelinek - Sept. 17, 2010, 2:26 p.m.
On Fri, Sep 17, 2010 at 04:20:33PM +0200, Richard Guenther wrote:
> > >  {
> > > -  TRANSLATION_UNIT_LANGUAGE (expr) = input_string (data_in, ib);
> > > +  TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (input_string (data_in, ib));
> > >   VEC_safe_push (tree, gc, all_translation_units, expr);
> > >  }
> > 
> > I guess it's not worth sharing the language strings somehow??
> 
> Well, it's going to be O(number of TUs) strings, so - no.  It might
> be worth transitioning LANG_NAME from a string to an enum maybe ;)

Perhaps putting there not a const char *, but IDENTIFIER and use
get_identifier ("GNU C") etc.?

	Jakub
Richard Guenther - Sept. 17, 2010, 2:32 p.m.
On Fri, 17 Sep 2010, Jakub Jelinek wrote:

> On Fri, Sep 17, 2010 at 04:20:33PM +0200, Richard Guenther wrote:
> > > >  {
> > > > -  TRANSLATION_UNIT_LANGUAGE (expr) = input_string (data_in, ib);
> > > > +  TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (input_string (data_in, ib));
> > > >   VEC_safe_push (tree, gc, all_translation_units, expr);
> > > >  }
> > > 
> > > I guess it's not worth sharing the language strings somehow??
> > 
> > Well, it's going to be O(number of TUs) strings, so - no.  It might
> > be worth transitioning LANG_NAME from a string to an enum maybe ;)
> 
> Perhaps putting there not a const char *, but IDENTIFIER and use
> get_identifier ("GNU C") etc.?

Well, as I said, if changing anything changing it to an enum makes
more sense than trying to save a few bytes via string sharing
(in fact LANG_NAME is also not an identifier).

Richard.
Richard Henderson - Sept. 17, 2010, 8:35 p.m.
On 09/17/2010 07:32 AM, Richard Guenther wrote:
> On Fri, 17 Sep 2010, Jakub Jelinek wrote:
> 
>> On Fri, Sep 17, 2010 at 04:20:33PM +0200, Richard Guenther wrote:
>>>>>  {
>>>>> -  TRANSLATION_UNIT_LANGUAGE (expr) = input_string (data_in, ib);
>>>>> +  TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (input_string (data_in, ib));
>>>>>   VEC_safe_push (tree, gc, all_translation_units, expr);
>>>>>  }
>>>>
>>>> I guess it's not worth sharing the language strings somehow??
>>>
>>> Well, it's going to be O(number of TUs) strings, so - no.  It might
>>> be worth transitioning LANG_NAME from a string to an enum maybe ;)
>>
>> Perhaps putting there not a const char *, but IDENTIFIER and use
>> get_identifier ("GNU C") etc.?
> 
> Well, as I said, if changing anything changing it to an enum makes
> more sense than trying to save a few bytes via string sharing
> (in fact LANG_NAME is also not an identifier).

For the enum, use DW_LANG_* ?


r~
Richard Guenther - Sept. 20, 2010, 12:58 p.m.
On Fri, 17 Sep 2010, Richard Henderson wrote:

> On 09/17/2010 07:32 AM, Richard Guenther wrote:
> > On Fri, 17 Sep 2010, Jakub Jelinek wrote:
> > 
> >> On Fri, Sep 17, 2010 at 04:20:33PM +0200, Richard Guenther wrote:
> >>>>>  {
> >>>>> -  TRANSLATION_UNIT_LANGUAGE (expr) = input_string (data_in, ib);
> >>>>> +  TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (input_string (data_in, ib));
> >>>>>   VEC_safe_push (tree, gc, all_translation_units, expr);
> >>>>>  }
> >>>>
> >>>> I guess it's not worth sharing the language strings somehow??
> >>>
> >>> Well, it's going to be O(number of TUs) strings, so - no.  It might
> >>> be worth transitioning LANG_NAME from a string to an enum maybe ;)
> >>
> >> Perhaps putting there not a const char *, but IDENTIFIER and use
> >> get_identifier ("GNU C") etc.?
> > 
> > Well, as I said, if changing anything changing it to an enum makes
> > more sense than trying to save a few bytes via string sharing
> > (in fact LANG_NAME is also not an identifier).
> 
> For the enum, use DW_LANG_* ?

Yes, certainly one possibility.  I've placed it on my list of things
to do (replace LANG_NAME with that as well - I love the strcmp in
fold-const.c ...).

Richard.

Patch

Index: gcc/lto-streamer-in.c
===================================================================
--- gcc/lto-streamer-in.c	(revision 164368)
+++ gcc/lto-streamer-in.c	(working copy)
@@ -2241,7 +2271,7 @@  lto_input_ts_translation_unit_decl_tree_
 						  struct data_in *data_in,
 						  tree expr)
 {
-  TRANSLATION_UNIT_LANGUAGE (expr) = input_string (data_in, ib);
+  TRANSLATION_UNIT_LANGUAGE (expr) = xstrdup (input_string (data_in, ib));
   VEC_safe_push (tree, gc, all_translation_units, expr);
 }