[PATCH][LTO] Fix PR48437
Richard Guenther
rguenther@suse.de
Wed Dec 7 16:17:00 GMT 2011
On Wed, 7 Dec 2011, Diego Novillo wrote:
> On 12/07/11 10:54, Richard Guenther wrote:
> > On Wed, 7 Dec 2011, Diego Novillo wrote:
> >
> > > On 12/07/11 10:46, Richard Guenther wrote:
> > > > On Wed, 7 Dec 2011, Diego Novillo wrote:
> > > >
> > > > > On 12/07/11 09:52, Richard Guenther wrote:
> > > > >
> > > > > > Index: gcc/lto-streamer-out.c
> > > > > > ===================================================================
> > > > > > *** gcc/lto-streamer-out.c (revision 182081)
> > > > > > --- gcc/lto-streamer-out.c (working copy)
> > > > > > *************** tree_is_indexable (tree t)
> > > > > > *** 129,134 ****
> > > > > > --- 129,144 ----
> > > > > > else if (TREE_CODE (t) == VAR_DECL&& decl_function_context
> > > > > > (t)
> > > > > > && !TREE_STATIC (t))
> > > > > > return false;
> > > > > > + /* If this is a decl generated for block local externs for
> > > > > > + debug info generation, stream it unshared alongside
> > > > > > BLOCK_VARS.
> > > > > > */
> > > > > > + else if (VAR_OR_FUNCTION_DECL_P (t)
> > > > > > + /* ??? The following tests are a literal match on what
> > > > > > + c-decl.c:pop_scope does. */
> > > > >
> > > > > Factor it into a common routine then?
> > > >
> > > > pop_scope of course _sets_ the values that way, it doesn't test them.
> > >
> > > Yes. I meant factoring, so future users have something to call, instead
> > > of
> > > three seemingly random flag checks. pop_scope could also be calling some
> > > complementary setter instead of doing the seemingly random flag setting.
> >
> > I don't see a good way to factor out the flags setting. Factoring out
> > the copying maybe. But well... we can do that when a 2nd user
> > comes along?
>
> The problem is that the 2nd user will cut-n-paste from this one. However, if
> you find adding a little function too strenuous, I guess it's not too big a
> deal.
Testing this kind of patches turns out to be quite time-consuming
(I do a LTO bootstrap and two SPEC 2k6 builds (-g and -g0)), so
yeah ...
The following is what I ended up LTO bootstrapping (finished ok),
testing is still in progress, as is SPEC 2k6 build.
It fixes PR49945 in a similar way, by streaming VLA types locally as well.
I'm going to apply it tomorrow, when full testing hopefully finished
Thanks,
Richard.
2011-12-08 Richard Guenther <rguenther@suse.de>
PR lto/48437
PR lto/49945
* lto-streamer-out.c (tree_is_indexable): Exclude block-local
extern declarations.
PR lto/48437
* gcc.dg/lto/20111207-2_0.c: New testcase.
* gcc.dg/guality/pr48437.c: Likewise.
Index: gcc/lto-streamer-out.c
===================================================================
*** gcc/lto-streamer-out.c (revision 182081)
--- gcc/lto-streamer-out.c (working copy)
*************** tree_is_indexable (tree t)
*** 129,134 ****
--- 129,147 ----
else if (TREE_CODE (t) == VAR_DECL && decl_function_context (t)
&& !TREE_STATIC (t))
return false;
+ /* If this is a decl generated for block local externs for
+ debug info generation, stream it unshared alongside BLOCK_VARS. */
+ else if (VAR_OR_FUNCTION_DECL_P (t)
+ /* ??? The following tests are a literal match on what
+ c-decl.c:pop_scope does. */
+ && TREE_PUBLIC (t)
+ && DECL_EXTERNAL (t)
+ && DECL_CONTEXT (t)
+ && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
+ return false;
+ else if (TYPE_P (t)
+ && variably_modified_type_p (t, NULL_TREE))
+ return false;
else
return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME);
}
Index: gcc/testsuite/gcc.dg/lto/20111207-2_0.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/20111207-2_0.c (revision 0)
--- gcc/testsuite/gcc.dg/lto/20111207-2_0.c (revision 0)
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-lto-do run } */
+
+ int
+ test (void)
+ {
+ int f (void);
+ return 0;
+ }
+
+ int
+ main (void)
+ {
+ int f (void);
+ int test (void);
+
+ return test ();
+ }
Index: gcc/testsuite/gcc.dg/guality/pr48437.c
===================================================================
*** gcc/testsuite/gcc.dg/guality/pr48437.c (revision 0)
--- gcc/testsuite/gcc.dg/guality/pr48437.c (revision 0)
***************
*** 0 ****
--- 1,17 ----
+ /* PR lto/48437 */
+ /* { dg-do run } */
+ /* { dg-options "-g" } */
+
+ #include "../nop.h"
+
+ int i __attribute__((used));
+ int main()
+ {
+ volatile int i;
+ for (i = 3; i < 7; ++i)
+ {
+ extern int i;
+ asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test 14 "i" "0" } } */
+ }
+ return 0;
+ }
More information about the Gcc-patches
mailing list