public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <richard.guenther@gmail.com>
To: Steven Bosscher <stevenb.gcc@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch] Call free_after_parsing earlier
Date: Mon, 16 Jul 2012 09:07:00 -0000	[thread overview]
Message-ID: <CAFiYyc13wmoKoLOFCZvCUFCp0v1FvcyxO2mdw1knDEYM_y=izw@mail.gmail.com> (raw)
In-Reply-To: <CABu31nMC-B7zi8atdudejdnCCdYbxiGf=8tm=Oxu8G32Eaif7w@mail.gmail.com>

On Fri, Jul 13, 2012 at 4:33 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
> On Thu, Jul 12, 2012 at 9:21 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Wed, Jul 11, 2012 at 9:39 PM, Steven Bosscher <stevenb.gcc@gmail.com> wrote:
>>> Hello,
>>>
>>> GCC calls free_after_parsing in rest_of_clean_state.
>>> That's way too late, it can be done in free_lang_data_in_cgraph instead.
>>
>> But that's only called with -flto ... I think it should be called in
>> cgraph_finalize_function instead (being optimistic here - heh).
>
> Quite optimistic, indeed...

;)

Btw, the

* final.c (final): Don't loop to find max_uid.

part is ok if you want to commit it separately.

> I choose for free_lang_data_in_cgraph (which, BTW, doesn't belong in
> tree.c, but that aside) because I thought the C++ front end might need
> its function->language after cgraph_finalize_function. And indeed
> so...

Ok, so how about doing it at the end of cgraph_analyze_function?

Thanks,
Richard.

> Ciao!
> Steven
>
>
> $ cat t.C
> #line 14971 "configure"
> struct S { ~S(); };
> void bar();
> void foo()
> {
>   S s;
>   bar();
> }
>
> $ gdb --args ./cc1plus t.C
> GNU gdb 6.8-debian
> Copyright (C) 2008 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> This is free software: you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> and "show warranty" for details.
> This GDB was configured as "x86_64-linux-gnu"...
> Breakpoint 1 at 0x38a80b5: file ../../trunk/gcc/diagnostic.c, line 1011.
> Breakpoint 2 at 0x38a7ed6: file ../../trunk/gcc/diagnostic.c, line 955.
> Function "exit" not defined.
> Make breakpoint pending on future shared library load? (y or [n])
> [answered N; input not from terminal]
> Function "abort" not defined.
> Make breakpoint pending on future shared library load? (y or [n])
> [answered N; input not from terminal]
> (gdb) run
> Starting program: /home/stevenb/devel/build-test/gcc/cc1plus t.C
>  void foo()
> Analyzing compilation unit
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x000000000096b93a in stmts_are_full_exprs_p () at
> ../../trunk/gcc/cp/semantics.c:370
> 370       return current_stmt_tree ()->stmts_are_full_exprs_p;
> (gdb) bt
> #0  0x000000000096b93a in stmts_are_full_exprs_p () at
> ../../trunk/gcc/cp/semantics.c:370
> #1  0x0000000000b1f294 in cp_gimplify_expr (expr_p=0x7ffff7232a20,
> pre_p=0x7fffffff97a8, post_p=0x7fffffff8ba8) at
> ../../trunk/gcc/cp/cp-gimplify.c:530
> #2  0x000000000156fb44 in gimplify_expr (expr_p=0x7ffff7232a20,
> pre_p=0x7fffffff97a8, post_p=0x7fffffff8ba8, gimple_test_f=0x155d16c
> <is_gimple_stmt>, fallback=0)
>     at ../../trunk/gcc/gimplify.c:7064
> #3  0x0000000001563bb7 in gimplify_stmt (stmt_p=0x7ffff7232a20,
> seq_p=0x7fffffff97a8) at ../../trunk/gcc/gimplify.c:5678
> #4  0x0000000001562d43 in gimplify_cleanup_point_expr
> (expr_p=0x7ffff7245ad8, pre_p=0x7fffffffb3b0) at
> ../../trunk/gcc/gimplify.c:5455
> #5  0x0000000001572c33 in gimplify_expr (expr_p=0x7ffff7245ad8,
> pre_p=0x7fffffffb3b0, post_p=0x7fffffff9998, gimple_test_f=0x155d16c
> <is_gimple_stmt>, fallback=0)
>     at ../../trunk/gcc/gimplify.c:7479
> #6  0x0000000001563bb7 in gimplify_stmt (stmt_p=0x7ffff7245ad8,
> seq_p=0x7fffffffb3b0) at ../../trunk/gcc/gimplify.c:5678
> #7  0x0000000001543e69 in gimplify_statement_list
> (expr_p=0x7fffffffb288, pre_p=0x7fffffffb3b0) at
> ../../trunk/gcc/gimplify.c:1527
> #8  0x000000000157352f in gimplify_expr (expr_p=0x7fffffffb288,
> pre_p=0x7fffffffb3b0, post_p=0x7fffffffa6e8, gimple_test_f=0x155d16c
> <is_gimple_stmt>, fallback=0)
>     at ../../trunk/gcc/gimplify.c:7531
> #9  0x0000000001563bb7 in gimplify_stmt (stmt_p=0x7fffffffb288,
> seq_p=0x7fffffffb3b0) at ../../trunk/gcc/gimplify.c:5678
> #10 0x000000000153eb49 in gimplify_and_add (t=0x7ffff7247600,
> seq_p=0x7fffffffb3b0) at ../../trunk/gcc/gimplify.c:358
> #11 0x0000000001572a22 in gimplify_expr (expr_p=0x7ffff7245ac0,
> pre_p=0x7fffffffcd40, post_p=0x7fffffffb3f8, gimple_test_f=0x155d16c
> <is_gimple_stmt>, fallback=0)
>     at ../../trunk/gcc/gimplify.c:7457
> #12 0x0000000001563bb7 in gimplify_stmt (stmt_p=0x7ffff7245ac0,
> seq_p=0x7fffffffcd40) at ../../trunk/gcc/gimplify.c:5678
> #13 0x0000000001543e69 in gimplify_statement_list
> (expr_p=0x7ffff724c098, pre_p=0x7fffffffcd40) at
> ../../trunk/gcc/gimplify.c:1527
> #14 0x000000000157352f in gimplify_expr (expr_p=0x7ffff724c098,
> pre_p=0x7fffffffcd40, post_p=0x7fffffffc148, gimple_test_f=0x155d16c
> <is_gimple_stmt>, fallback=0)
>     at ../../trunk/gcc/gimplify.c:7531
> #15 0x0000000001563bb7 in gimplify_stmt (stmt_p=0x7ffff724c098,
> seq_p=0x7fffffffcd40) at ../../trunk/gcc/gimplify.c:5678
> #16 0x0000000001542106 in gimplify_bind_expr (expr_p=0x7ffff723c898,
> pre_p=0x7fffffffdc80) at ../../trunk/gcc/gimplify.c:1220
> #17 0x0000000001571446 in gimplify_expr (expr_p=0x7ffff723c898,
> pre_p=0x7fffffffdc80, post_p=0x7fffffffd068, gimple_test_f=0x155d16c
> <is_gimple_stmt>, fallback=0)
>     at ../../trunk/gcc/gimplify.c:7316
> #18 0x0000000001563bb7 in gimplify_stmt (stmt_p=0x7ffff723c898,
> seq_p=0x7fffffffdc80) at ../../trunk/gcc/gimplify.c:5678
> #19 0x0000000001577766 in gimplify_body (fndecl=0x7ffff723c800,
> do_parms=1 '\001') at ../../trunk/gcc/gimplify.c:8177
> #20 0x0000000001578d36 in gimplify_function_tree
> (fndecl=0x7ffff723c800) at ../../trunk/gcc/gimplify.c:8311
> #21 0x0000000000fc490c in cgraph_analyze_function
> (node=0x7ffff70d5750) at ../../trunk/gcc/cgraphunit.c:658
> #22 0x0000000000fc5c13 in cgraph_analyze_functions () at
> ../../trunk/gcc/cgraphunit.c:944
> #23 0x0000000000fc9a19 in finalize_compilation_unit () at
> ../../trunk/gcc/cgraphunit.c:2092
> #24 0x0000000000748909 in cp_write_global_declarations () at
> ../../trunk/gcc/cp/decl2.c:4024
> #25 0x0000000001eace3e in compile_file () at ../../trunk/gcc/toplev.c:560
> #26 0x0000000001eaecff in do_compile () at ../../trunk/gcc/toplev.c:1863
> #27 0x0000000001eaee54 in toplev_main (argc=2, argv=0x7fffffffe2b8) at
> ../../trunk/gcc/toplev.c:1939
> #28 0x00000000038889a1 in main (argc=2, argv=0x7fffffffe2b8) at
> ../../trunk/gcc/main.c:36
>
>
>
> Index: final.c
> ===================================================================
> --- final.c     (revision 189459)
> +++ final.c     (working copy)
> @@ -1826,7 +1826,6 @@ void
>  final (rtx first, FILE *file, int optimize_p)
>  {
>    rtx insn, next;
> -  int max_uid = 0;
>    int seen = 0;
>
>    /* Used for -dA dump.  */
> @@ -1837,11 +1836,9 @@ final (rtx first, FILE *file, int optimi
>
>    last_ignored_compare = 0;
>
> +#ifdef HAVE_cc0
>    for (insn = first; insn; insn = NEXT_INSN (insn))
>      {
> -      if (INSN_UID (insn) > max_uid)       /* Find largest UID.  */
> -       max_uid = INSN_UID (insn);
> -#ifdef HAVE_cc0
>        /* If CC tracking across branches is enabled, record the insn which
>          jumps to each branch only reached from one place.  */
>        if (optimize_p && JUMP_P (insn))
> @@ -1852,8 +1849,8 @@ final (rtx first, FILE *file, int optimi
>               LABEL_REFS (lab) = insn;
>             }
>         }
> -#endif
>      }
> +#endif
>
>    init_recog ();
>
> @@ -4500,7 +4497,6 @@ rest_of_clean_state (void)
>    init_recog_no_volatile ();
>
>    /* We're done with this function.  Free up memory if we can.  */
> -  free_after_parsing (cfun);
>    free_after_compilation (cfun);
>    return 0;
>  }
> Index: cgraphunit.c
> ===================================================================
> --- cgraphunit.c        (revision 189459)
> +++ cgraphunit.c        (working copy)
> @@ -404,6 +404,12 @@ cgraph_finalize_function (tree decl, boo
>  {
>    struct cgraph_node *node = cgraph_get_create_node (decl);
>
> +  /* The front end is done with this function.  Free up memory if we can.  */
> +  if (DECL_STRUCT_FUNCTION (decl))
> +    free_after_parsing (DECL_STRUCT_FUNCTION (decl));
> +
> +  /* If this node was finalized before, this must be a re-definition for
> +     an extern inline.  */
>    if (node->local.finalized)
>      {
>        cgraph_reset_node (node);

      reply	other threads:[~2012-07-16  9:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11 19:40 Steven Bosscher
2012-07-12  7:21 ` Richard Guenther
2012-07-13 14:33   ` Steven Bosscher
2012-07-16  9:07     ` Richard Guenther [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc13wmoKoLOFCZvCUFCp0v1FvcyxO2mdw1knDEYM_y=izw@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=stevenb.gcc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).