From patchwork Fri Jul 13 14:33:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 170903 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A39F62C0363 for ; Sat, 14 Jul 2012 00:34:10 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1342794851; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:In-Reply-To:References:From:Date: Message-ID:Subject:To:Cc:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=PqtOQDYLzdfa8ZOQkzQIHnq9yQU=; b=RGPwjUwggMKBnZa 3zpSf3ieoIUIrLSsrRAmq3O8ReD5AlKlYe2BNLVgIXBDuY1O0ov7Dw5cjQfUi44C PvHojhSeNNiZ7PMeI7aXoP3e7Xe9Qhg9trxoiObbtjFUhWSUNRHhd2NMhVbbRZvs JPlmsM8kgik7fqa/dvh3rhsS/2Qo= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:MIME-Version:Received:In-Reply-To:References:From:Date:Message-ID:Subject:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=S+mrpNpbPRmX/Zo/ISdThNXzGrw/AhsihGxeBuKnISMO/jQScfDWnOcp6+70S7 QjsluoTTgWuerw1FKorbtmgr6TKzDaPiJEaICDibchAl/E/cEt5n6tcrS6UHKIFB HOt2OPuAerfgBenVWT+Rx+Zwslbfg6GbAOK+8kcYtE6no=; Received: (qmail 5247 invoked by alias); 13 Jul 2012 14:33:52 -0000 Received: (qmail 5229 invoked by uid 22791); 13 Jul 2012 14:33:48 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-bk0-f47.google.com (HELO mail-bk0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Jul 2012 14:33:32 +0000 Received: by bkcik5 with SMTP id ik5so3020586bkc.20 for ; Fri, 13 Jul 2012 07:33:30 -0700 (PDT) Received: by 10.152.102.137 with SMTP id fo9mr1604353lab.35.1342190010421; Fri, 13 Jul 2012 07:33:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.4.229 with HTTP; Fri, 13 Jul 2012 07:33:10 -0700 (PDT) In-Reply-To: References: From: Steven Bosscher Date: Fri, 13 Jul 2012 16:33:10 +0200 Message-ID: Subject: Re: [patch] Call free_after_parsing earlier To: Richard Guenther Cc: GCC Patches X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Thu, Jul 12, 2012 at 9:21 AM, Richard Guenther wrote: > On Wed, Jul 11, 2012 at 9:39 PM, Steven Bosscher 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... 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... 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 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 , 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 , 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 , 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 , 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 , 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 , 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);