diff mbox

PR61868

Message ID B71DF1153024A14EABB94E39368E44A6042D5AA1@SJEXCHMB13.corp.ad.broadcom.com
State New
Headers show

Commit Message

Bingfeng Mei July 29, 2014, 1:01 p.m. UTC
Hi, 
Please find the patches for pr61868. The problem is that even with -frandom-seed gcc always uses 0 instead of specified number/string for places such as lto section names. init_random_seed is never called with -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?

Thanks,
Bingfeng Mei

Comments

Richard Biener July 30, 2014, 7:46 a.m. UTC | #1
On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei <bmei@broadcom.com> wrote:
> Hi,
> Please find the patches for pr61868. The problem is that even with -frandom-seed gcc always uses 0 instead of specified number/string for places such as lto section names. init_random_seed is never called with -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?

Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?

Andi, wasn't this used to support partial linking of LTO objects?  Thus,
this shortcut was on purpose?  Otherwise passing -frandom-seed to
LTO would break that?

Bingfeng, did you test if LTO bootstrap still works after this patch?

Thanks,
Richard.

> Thanks,
> Bingfeng Mei
>
>
> ===================================================================
> --- ChangeLog   (revision 213152)
> +++ ChangeLog   (working copy)
> @@ -1,3 +1,9 @@
> +2014-07-29  Bingfeng Mei <bmei@broadcom.com>
> +
> +       PR lto/61868
> +       * toplev.c (init_random_seed): Generate random seed when
> +       flag_random_seed is specified.
> +
>  2014-07-28  Jan Hubicka  <hubicka@ucw.cz>
>
>         * cgraph.c (cgraph_node::create_indirect_edge): Copy speculative data.
> Index: toplev.c
> ===================================================================
> --- toplev.c    (revision 213152)
> +++ toplev.c    (working copy)
> @@ -301,7 +301,7 @@ init_random_seed (void)
>  HOST_WIDE_INT
>  get_random_seed (bool noinit)
>  {
> -  if (!flag_random_seed && !noinit)
> +  if (!noinit)
>      init_random_seed ();
>    return random_seed;
>  }
> Index: testsuite/ChangeLog
> ===================================================================
> --- testsuite/ChangeLog (revision 213152)
> +++ testsuite/ChangeLog (working copy)
> @@ -1,3 +1,8 @@
> +2014-07-29  Bingfeng Mei  <bmei@broadcom.com>
> +
> +       PR lto/61868
> +       * gcc.dg/pr61868.c: New test.
> +
>  2014-07-28  Richard Biener  <rguenther@suse.de>
>
>         PR rtl-optimization/61801
> Index: testsuite/gcc.dg/pr61868.c
> ===================================================================
> --- testsuite/gcc.dg/pr61868.c  (revision 0)
> +++ testsuite/gcc.dg/pr61868.c  (revision 0)
> @@ -0,0 +1,9 @@
> +/* { dg-do compile } */
> +/* { dg-options "-flto -frandom-seed=0x12345" }  */
> +extern int foo (int);
> +int main ()
> +{
> +  foo (100);
> +  return 0;
> +}
> +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */
>
Bingfeng Mei July 30, 2014, 8:52 a.m. UTC | #2
Yes, opts-global.c fills flag_random_seed with string passed in command line. But init_random_seed in toplev.c is the one that processes the flag and set random_seed variable, which is returned by get_random_seed function. 

By default, my configuration enables LTO. How to test LTO bootstrap? 

Bingfeng

> -----Original Message-----

> From: Richard Biener [mailto:richard.guenther@gmail.com]

> Sent: 30 July 2014 08:47

> To: Bingfeng Mei; Andi Kleen

> Cc: gcc-patches@gcc.gnu.org

> Subject: Re: [PATCH] PR61868

> 

> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei <bmei@broadcom.com> wrote:

> > Hi,

> > Please find the patches for pr61868. The problem is that even with -

> frandom-seed gcc always uses 0 instead of specified number/string for

> places such as lto section names. init_random_seed is never called with

> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?

> 

> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?

> 

> Andi, wasn't this used to support partial linking of LTO objects?  Thus,

> this shortcut was on purpose?  Otherwise passing -frandom-seed to

> LTO would break that?

> 

> Bingfeng, did you test if LTO bootstrap still works after this patch?

> 

> Thanks,

> Richard.

> 

> > Thanks,

> > Bingfeng Mei

> >

> >

> > ===================================================================

> > --- ChangeLog   (revision 213152)

> > +++ ChangeLog   (working copy)

> > @@ -1,3 +1,9 @@

> > +2014-07-29  Bingfeng Mei <bmei@broadcom.com>

> > +

> > +       PR lto/61868

> > +       * toplev.c (init_random_seed): Generate random seed when

> > +       flag_random_seed is specified.

> > +

> >  2014-07-28  Jan Hubicka  <hubicka@ucw.cz>

> >

> >         * cgraph.c (cgraph_node::create_indirect_edge): Copy

> speculative data.

> > Index: toplev.c

> > ===================================================================

> > --- toplev.c    (revision 213152)

> > +++ toplev.c    (working copy)

> > @@ -301,7 +301,7 @@ init_random_seed (void)

> >  HOST_WIDE_INT

> >  get_random_seed (bool noinit)

> >  {

> > -  if (!flag_random_seed && !noinit)

> > +  if (!noinit)

> >      init_random_seed ();

> >    return random_seed;

> >  }

> > Index: testsuite/ChangeLog

> > ===================================================================

> > --- testsuite/ChangeLog (revision 213152)

> > +++ testsuite/ChangeLog (working copy)

> > @@ -1,3 +1,8 @@

> > +2014-07-29  Bingfeng Mei  <bmei@broadcom.com>

> > +

> > +       PR lto/61868

> > +       * gcc.dg/pr61868.c: New test.

> > +

> >  2014-07-28  Richard Biener  <rguenther@suse.de>

> >

> >         PR rtl-optimization/61801

> > Index: testsuite/gcc.dg/pr61868.c

> > ===================================================================

> > --- testsuite/gcc.dg/pr61868.c  (revision 0)

> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)

> > @@ -0,0 +1,9 @@

> > +/* { dg-do compile } */

> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */

> > +extern int foo (int);

> > +int main ()

> > +{

> > +  foo (100);

> > +  return 0;

> > +}

> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */

> >
Richard Biener July 30, 2014, 9:42 a.m. UTC | #3
On Wed, Jul 30, 2014 at 10:52 AM, Bingfeng Mei <bmei@broadcom.com> wrote:
> Yes, opts-global.c fills flag_random_seed with string passed in command line. But init_random_seed in toplev.c is the one that processes the flag and set random_seed variable, which is returned by get_random_seed function.

Err, I meant opts-global.c:handle_common_deferred_options

> By default, my configuration enables LTO. How to test LTO bootstrap?

configure with --with-build-config=bootstrap-lto (and reduce the
set of languages to c,c++ to get a sane bootstrap time).

Richard.

> Bingfeng
>
>> -----Original Message-----
>> From: Richard Biener [mailto:richard.guenther@gmail.com]
>> Sent: 30 July 2014 08:47
>> To: Bingfeng Mei; Andi Kleen
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [PATCH] PR61868
>>
>> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei <bmei@broadcom.com> wrote:
>> > Hi,
>> > Please find the patches for pr61868. The problem is that even with -
>> frandom-seed gcc always uses 0 instead of specified number/string for
>> places such as lto section names. init_random_seed is never called with
>> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
>>
>> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?
>>
>> Andi, wasn't this used to support partial linking of LTO objects?  Thus,
>> this shortcut was on purpose?  Otherwise passing -frandom-seed to
>> LTO would break that?
>>
>> Bingfeng, did you test if LTO bootstrap still works after this patch?
>>
>> Thanks,
>> Richard.
>>
>> > Thanks,
>> > Bingfeng Mei
>> >
>> >
>> > ===================================================================
>> > --- ChangeLog   (revision 213152)
>> > +++ ChangeLog   (working copy)
>> > @@ -1,3 +1,9 @@
>> > +2014-07-29  Bingfeng Mei <bmei@broadcom.com>
>> > +
>> > +       PR lto/61868
>> > +       * toplev.c (init_random_seed): Generate random seed when
>> > +       flag_random_seed is specified.
>> > +
>> >  2014-07-28  Jan Hubicka  <hubicka@ucw.cz>
>> >
>> >         * cgraph.c (cgraph_node::create_indirect_edge): Copy
>> speculative data.
>> > Index: toplev.c
>> > ===================================================================
>> > --- toplev.c    (revision 213152)
>> > +++ toplev.c    (working copy)
>> > @@ -301,7 +301,7 @@ init_random_seed (void)
>> >  HOST_WIDE_INT
>> >  get_random_seed (bool noinit)
>> >  {
>> > -  if (!flag_random_seed && !noinit)
>> > +  if (!noinit)
>> >      init_random_seed ();
>> >    return random_seed;
>> >  }
>> > Index: testsuite/ChangeLog
>> > ===================================================================
>> > --- testsuite/ChangeLog (revision 213152)
>> > +++ testsuite/ChangeLog (working copy)
>> > @@ -1,3 +1,8 @@
>> > +2014-07-29  Bingfeng Mei  <bmei@broadcom.com>
>> > +
>> > +       PR lto/61868
>> > +       * gcc.dg/pr61868.c: New test.
>> > +
>> >  2014-07-28  Richard Biener  <rguenther@suse.de>
>> >
>> >         PR rtl-optimization/61801
>> > Index: testsuite/gcc.dg/pr61868.c
>> > ===================================================================
>> > --- testsuite/gcc.dg/pr61868.c  (revision 0)
>> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)
>> > @@ -0,0 +1,9 @@
>> > +/* { dg-do compile } */
>> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */
>> > +extern int foo (int);
>> > +int main ()
>> > +{
>> > +  foo (100);
>> > +  return 0;
>> > +}
>> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */
>> >
Bingfeng Mei July 30, 2014, 10:46 a.m. UTC | #4
It did take a lot of time, but passed the LTO bootstrap.

Bingfeng

> -----Original Message-----

> From: Richard Biener [mailto:richard.guenther@gmail.com]

> Sent: 30 July 2014 10:43

> To: Bingfeng Mei

> Cc: Andi Kleen; gcc-patches@gcc.gnu.org

> Subject: Re: [PATCH] PR61868

> 

> On Wed, Jul 30, 2014 at 10:52 AM, Bingfeng Mei <bmei@broadcom.com> wrote:

> > Yes, opts-global.c fills flag_random_seed with string passed in

> command line. But init_random_seed in toplev.c is the one that processes

> the flag and set random_seed variable, which is returned by

> get_random_seed function.

> 

> Err, I meant opts-global.c:handle_common_deferred_options

> 

> > By default, my configuration enables LTO. How to test LTO bootstrap?

> 

> configure with --with-build-config=bootstrap-lto (and reduce the

> set of languages to c,c++ to get a sane bootstrap time).

> 

> Richard.

> 

> > Bingfeng

> >

> >> -----Original Message-----

> >> From: Richard Biener [mailto:richard.guenther@gmail.com]

> >> Sent: 30 July 2014 08:47

> >> To: Bingfeng Mei; Andi Kleen

> >> Cc: gcc-patches@gcc.gnu.org

> >> Subject: Re: [PATCH] PR61868

> >>

> >> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei <bmei@broadcom.com>

> wrote:

> >> > Hi,

> >> > Please find the patches for pr61868. The problem is that even with

> -

> >> frandom-seed gcc always uses 0 instead of specified number/string for

> >> places such as lto section names. init_random_seed is never called

> with

> >> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?

> >>

> >> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?

> >>

> >> Andi, wasn't this used to support partial linking of LTO objects?

> Thus,

> >> this shortcut was on purpose?  Otherwise passing -frandom-seed to

> >> LTO would break that?

> >>

> >> Bingfeng, did you test if LTO bootstrap still works after this patch?

> >>

> >> Thanks,

> >> Richard.

> >>

> >> > Thanks,

> >> > Bingfeng Mei

> >> >

> >> >

> >> > ===================================================================

> >> > --- ChangeLog   (revision 213152)

> >> > +++ ChangeLog   (working copy)

> >> > @@ -1,3 +1,9 @@

> >> > +2014-07-29  Bingfeng Mei <bmei@broadcom.com>

> >> > +

> >> > +       PR lto/61868

> >> > +       * toplev.c (init_random_seed): Generate random seed when

> >> > +       flag_random_seed is specified.

> >> > +

> >> >  2014-07-28  Jan Hubicka  <hubicka@ucw.cz>

> >> >

> >> >         * cgraph.c (cgraph_node::create_indirect_edge): Copy

> >> speculative data.

> >> > Index: toplev.c

> >> > ===================================================================

> >> > --- toplev.c    (revision 213152)

> >> > +++ toplev.c    (working copy)

> >> > @@ -301,7 +301,7 @@ init_random_seed (void)

> >> >  HOST_WIDE_INT

> >> >  get_random_seed (bool noinit)

> >> >  {

> >> > -  if (!flag_random_seed && !noinit)

> >> > +  if (!noinit)

> >> >      init_random_seed ();

> >> >    return random_seed;

> >> >  }

> >> > Index: testsuite/ChangeLog

> >> > ===================================================================

> >> > --- testsuite/ChangeLog (revision 213152)

> >> > +++ testsuite/ChangeLog (working copy)

> >> > @@ -1,3 +1,8 @@

> >> > +2014-07-29  Bingfeng Mei  <bmei@broadcom.com>

> >> > +

> >> > +       PR lto/61868

> >> > +       * gcc.dg/pr61868.c: New test.

> >> > +

> >> >  2014-07-28  Richard Biener  <rguenther@suse.de>

> >> >

> >> >         PR rtl-optimization/61801

> >> > Index: testsuite/gcc.dg/pr61868.c

> >> > ===================================================================

> >> > --- testsuite/gcc.dg/pr61868.c  (revision 0)

> >> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)

> >> > @@ -0,0 +1,9 @@

> >> > +/* { dg-do compile } */

> >> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */

> >> > +extern int foo (int);

> >> > +int main ()

> >> > +{

> >> > +  foo (100);

> >> > +  return 0;

> >> > +}

> >> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */

> >> >
Bingfeng Mei July 30, 2014, 12:48 p.m. UTC | #5
On the second thought, maybe the change should be made in set_random_seed. Otherwise, init_random_seed is invoked every time get_random_seed get called (not sure how often). What do you think? 

const char *
set_random_seed (const char *val)
{
  const char *old = flag_random_seed;
  flag_random_seed = val;
+ init_random_seed ();
  return old;
}

Bingfeng

> -----Original Message-----

> From: Richard Biener [mailto:richard.guenther@gmail.com]

> Sent: 30 July 2014 10:43

> To: Bingfeng Mei

> Cc: Andi Kleen; gcc-patches@gcc.gnu.org

> Subject: Re: [PATCH] PR61868

> 

> On Wed, Jul 30, 2014 at 10:52 AM, Bingfeng Mei <bmei@broadcom.com> wrote:

> > Yes, opts-global.c fills flag_random_seed with string passed in

> command line. But init_random_seed in toplev.c is the one that processes

> the flag and set random_seed variable, which is returned by

> get_random_seed function.

> 

> Err, I meant opts-global.c:handle_common_deferred_options

> 

> > By default, my configuration enables LTO. How to test LTO bootstrap?

> 

> configure with --with-build-config=bootstrap-lto (and reduce the

> set of languages to c,c++ to get a sane bootstrap time).

> 

> Richard.

> 

> > Bingfeng

> >

> >> -----Original Message-----

> >> From: Richard Biener [mailto:richard.guenther@gmail.com]

> >> Sent: 30 July 2014 08:47

> >> To: Bingfeng Mei; Andi Kleen

> >> Cc: gcc-patches@gcc.gnu.org

> >> Subject: Re: [PATCH] PR61868

> >>

> >> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei <bmei@broadcom.com>

> wrote:

> >> > Hi,

> >> > Please find the patches for pr61868. The problem is that even with

> -

> >> frandom-seed gcc always uses 0 instead of specified number/string for

> >> places such as lto section names. init_random_seed is never called

> with

> >> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?

> >>

> >> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?

> >>

> >> Andi, wasn't this used to support partial linking of LTO objects?

> Thus,

> >> this shortcut was on purpose?  Otherwise passing -frandom-seed to

> >> LTO would break that?

> >>

> >> Bingfeng, did you test if LTO bootstrap still works after this patch?

> >>

> >> Thanks,

> >> Richard.

> >>

> >> > Thanks,

> >> > Bingfeng Mei

> >> >

> >> >

> >> > ===================================================================

> >> > --- ChangeLog   (revision 213152)

> >> > +++ ChangeLog   (working copy)

> >> > @@ -1,3 +1,9 @@

> >> > +2014-07-29  Bingfeng Mei <bmei@broadcom.com>

> >> > +

> >> > +       PR lto/61868

> >> > +       * toplev.c (init_random_seed): Generate random seed when

> >> > +       flag_random_seed is specified.

> >> > +

> >> >  2014-07-28  Jan Hubicka  <hubicka@ucw.cz>

> >> >

> >> >         * cgraph.c (cgraph_node::create_indirect_edge): Copy

> >> speculative data.

> >> > Index: toplev.c

> >> > ===================================================================

> >> > --- toplev.c    (revision 213152)

> >> > +++ toplev.c    (working copy)

> >> > @@ -301,7 +301,7 @@ init_random_seed (void)

> >> >  HOST_WIDE_INT

> >> >  get_random_seed (bool noinit)

> >> >  {

> >> > -  if (!flag_random_seed && !noinit)

> >> > +  if (!noinit)

> >> >      init_random_seed ();

> >> >    return random_seed;

> >> >  }

> >> > Index: testsuite/ChangeLog

> >> > ===================================================================

> >> > --- testsuite/ChangeLog (revision 213152)

> >> > +++ testsuite/ChangeLog (working copy)

> >> > @@ -1,3 +1,8 @@

> >> > +2014-07-29  Bingfeng Mei  <bmei@broadcom.com>

> >> > +

> >> > +       PR lto/61868

> >> > +       * gcc.dg/pr61868.c: New test.

> >> > +

> >> >  2014-07-28  Richard Biener  <rguenther@suse.de>

> >> >

> >> >         PR rtl-optimization/61801

> >> > Index: testsuite/gcc.dg/pr61868.c

> >> > ===================================================================

> >> > --- testsuite/gcc.dg/pr61868.c  (revision 0)

> >> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)

> >> > @@ -0,0 +1,9 @@

> >> > +/* { dg-do compile } */

> >> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */

> >> > +extern int foo (int);

> >> > +int main ()

> >> > +{

> >> > +  foo (100);

> >> > +  return 0;

> >> > +}

> >> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */

> >> >
Richard Biener July 30, 2014, 1:07 p.m. UTC | #6
On Wed, Jul 30, 2014 at 2:48 PM, Bingfeng Mei <bmei@broadcom.com> wrote:
> On the second thought, maybe the change should be made in set_random_seed. Otherwise, init_random_seed is invoked every time get_random_seed get called (not sure how often). What do you think?
>
> const char *
> set_random_seed (const char *val)
> {
>   const char *old = flag_random_seed;
>   flag_random_seed = val;
> + init_random_seed ();
>   return old;
> }

I think it makes more sense to move the if (flag_random_seed)
code from init_random_seed inline here as init_random_seed is
never called with flag_random_set == true.

Richard.

> Bingfeng
>
>> -----Original Message-----
>> From: Richard Biener [mailto:richard.guenther@gmail.com]
>> Sent: 30 July 2014 10:43
>> To: Bingfeng Mei
>> Cc: Andi Kleen; gcc-patches@gcc.gnu.org
>> Subject: Re: [PATCH] PR61868
>>
>> On Wed, Jul 30, 2014 at 10:52 AM, Bingfeng Mei <bmei@broadcom.com> wrote:
>> > Yes, opts-global.c fills flag_random_seed with string passed in
>> command line. But init_random_seed in toplev.c is the one that processes
>> the flag and set random_seed variable, which is returned by
>> get_random_seed function.
>>
>> Err, I meant opts-global.c:handle_common_deferred_options
>>
>> > By default, my configuration enables LTO. How to test LTO bootstrap?
>>
>> configure with --with-build-config=bootstrap-lto (and reduce the
>> set of languages to c,c++ to get a sane bootstrap time).
>>
>> Richard.
>>
>> > Bingfeng
>> >
>> >> -----Original Message-----
>> >> From: Richard Biener [mailto:richard.guenther@gmail.com]
>> >> Sent: 30 July 2014 08:47
>> >> To: Bingfeng Mei; Andi Kleen
>> >> Cc: gcc-patches@gcc.gnu.org
>> >> Subject: Re: [PATCH] PR61868
>> >>
>> >> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei <bmei@broadcom.com>
>> wrote:
>> >> > Hi,
>> >> > Please find the patches for pr61868. The problem is that even with
>> -
>> >> frandom-seed gcc always uses 0 instead of specified number/string for
>> >> places such as lto section names. init_random_seed is never called
>> with
>> >> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
>> >>
>> >> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?
>> >>
>> >> Andi, wasn't this used to support partial linking of LTO objects?
>> Thus,
>> >> this shortcut was on purpose?  Otherwise passing -frandom-seed to
>> >> LTO would break that?
>> >>
>> >> Bingfeng, did you test if LTO bootstrap still works after this patch?
>> >>
>> >> Thanks,
>> >> Richard.
>> >>
>> >> > Thanks,
>> >> > Bingfeng Mei
>> >> >
>> >> >
>> >> > ===================================================================
>> >> > --- ChangeLog   (revision 213152)
>> >> > +++ ChangeLog   (working copy)
>> >> > @@ -1,3 +1,9 @@
>> >> > +2014-07-29  Bingfeng Mei <bmei@broadcom.com>
>> >> > +
>> >> > +       PR lto/61868
>> >> > +       * toplev.c (init_random_seed): Generate random seed when
>> >> > +       flag_random_seed is specified.
>> >> > +
>> >> >  2014-07-28  Jan Hubicka  <hubicka@ucw.cz>
>> >> >
>> >> >         * cgraph.c (cgraph_node::create_indirect_edge): Copy
>> >> speculative data.
>> >> > Index: toplev.c
>> >> > ===================================================================
>> >> > --- toplev.c    (revision 213152)
>> >> > +++ toplev.c    (working copy)
>> >> > @@ -301,7 +301,7 @@ init_random_seed (void)
>> >> >  HOST_WIDE_INT
>> >> >  get_random_seed (bool noinit)
>> >> >  {
>> >> > -  if (!flag_random_seed && !noinit)
>> >> > +  if (!noinit)
>> >> >      init_random_seed ();
>> >> >    return random_seed;
>> >> >  }
>> >> > Index: testsuite/ChangeLog
>> >> > ===================================================================
>> >> > --- testsuite/ChangeLog (revision 213152)
>> >> > +++ testsuite/ChangeLog (working copy)
>> >> > @@ -1,3 +1,8 @@
>> >> > +2014-07-29  Bingfeng Mei  <bmei@broadcom.com>
>> >> > +
>> >> > +       PR lto/61868
>> >> > +       * gcc.dg/pr61868.c: New test.
>> >> > +
>> >> >  2014-07-28  Richard Biener  <rguenther@suse.de>
>> >> >
>> >> >         PR rtl-optimization/61801
>> >> > Index: testsuite/gcc.dg/pr61868.c
>> >> > ===================================================================
>> >> > --- testsuite/gcc.dg/pr61868.c  (revision 0)
>> >> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)
>> >> > @@ -0,0 +1,9 @@
>> >> > +/* { dg-do compile } */
>> >> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */
>> >> > +extern int foo (int);
>> >> > +int main ()
>> >> > +{
>> >> > +  foo (100);
>> >> > +  return 0;
>> >> > +}
>> >> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */
>> >> >
Andi Kleen July 30, 2014, 2:46 p.m. UTC | #7
On Wed, Jul 30, 2014 at 09:46:48AM +0200, Richard Biener wrote:
> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei <bmei@broadcom.com> wrote:
> > Hi,
> > Please find the patches for pr61868. The problem is that even with -frandom-seed gcc always uses 0 instead of specified number/string for places such as lto section names. init_random_seed is never called with -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
> 
> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?
> 
> Andi, wasn't this used to support partial linking of LTO objects?  Thus,
> this shortcut was on purpose?  Otherwise passing -frandom-seed to
> LTO would break that?

I don't think it was on purpose. Partial linking doesn't need
the seeds. The seeding was only to avoid compare failures in
the gcc build.

-Andi
diff mbox

Patch

===================================================================
--- ChangeLog   (revision 213152)
+++ ChangeLog   (working copy)
@@ -1,3 +1,9 @@ 
+2014-07-29  Bingfeng Mei <bmei@broadcom.com>
+
+       PR lto/61868
+       * toplev.c (init_random_seed): Generate random seed when
+       flag_random_seed is specified.
+
 2014-07-28  Jan Hubicka  <hubicka@ucw.cz>

        * cgraph.c (cgraph_node::create_indirect_edge): Copy speculative data.
Index: toplev.c
===================================================================
--- toplev.c    (revision 213152)
+++ toplev.c    (working copy)
@@ -301,7 +301,7 @@  init_random_seed (void)
 HOST_WIDE_INT
 get_random_seed (bool noinit)
 {
-  if (!flag_random_seed && !noinit)
+  if (!noinit)
     init_random_seed ();
   return random_seed;
 }
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 213152)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@ 
+2014-07-29  Bingfeng Mei  <bmei@broadcom.com>
+
+       PR lto/61868
+       * gcc.dg/pr61868.c: New test.
+
 2014-07-28  Richard Biener  <rguenther@suse.de>

        PR rtl-optimization/61801
Index: testsuite/gcc.dg/pr61868.c
===================================================================
--- testsuite/gcc.dg/pr61868.c  (revision 0)
+++ testsuite/gcc.dg/pr61868.c  (revision 0)
@@ -0,0 +1,9 @@ 
+/* { dg-do compile } */
+/* { dg-options "-flto -frandom-seed=0x12345" }  */
+extern int foo (int);
+int main ()
+{
+  foo (100);
+  return 0;
+}
+/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */