Bug 35795 - [4.4 Regression] Revision 133787 breaks ia64
Summary: [4.4 Regression] Revision 133787 breaks ia64
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-02 04:28 UTC by H.J. Lu
Modified: 2008-04-03 16:21 UTC (History)
3 users (show)

See Also:
Host:
Target: ia64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2008-04-02 04:28:56 UTC
Breakpoint 1, fancy_abort (
    file=0x4000000000c7c9c8 "/net/gnu-13/export/gnu/src/gcc/gcc/gcc/function.c", line=3943, function=0x4000000000c7cd40 "prepare_function_start")
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/diagnostic.c:654
f 1654    internal_error ("in %s, at %s:%d", function, trim_filename (file), line);
(gdb) f 1
#1  0x400000000043aae0 in prepare_function_start ()
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/function.c:3943
3943      gcc_assert (!rtl.emit.x_last_insn);
(gdb)

rtl.emit.x_last_insn is set from

(gdb) bt
#0  emit_barrier () at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/emit-rtl.c:3430
#1  0x400000000090a630 in ia64_output_mi_thunk (file=0x6000000000188870,
    thunk=<value optimized out>, delta=0, vcall_offset=-24,
    function=0x2000000004e09110)
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/config/ia64/ia64.c:9684
#2  0x40000000001467e0 in use_thunk (thunk_fndecl=0x2000000004ac27d0,
    emit_p=<value optimized out>)
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/cp/method.c:443
#3  0x4000000000155a90 in emit_associated_thunks (fn=<value optimized out>)
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/cp/semantics.c:3157
#4  0x40000000009173d0 in cgraph_expand_function (node=0x2000000004da3f00)
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/cgraphunit.c:1156
#5  0x400000000091bfc0 in cgraph_optimize ()
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/cgraphunit.c:1220
#6  0x40000000000c1350 in cp_write_global_declarations ()
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/cp/decl2.c:3471
#7  0x4000000000630280 in toplev_main (argc=<value optimized out>,
    argv=<value optimized out>)
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/toplev.c:971
#8  0x40000000002336f0 in main (argc=12, argv=0x60000fffffffb6f8)
    at /net/gnu-13/export/gnu/src/gcc/gcc/gcc/main.c:35
Comment 1 H.J. Lu 2008-04-02 04:30:20 UTC
Bad revision is at

http://gcc.gnu.org/ml/gcc-cvs/2008-04/msg00011.html
Comment 2 H.J. Lu 2008-04-02 04:35:22 UTC
I am testing this patch:

--- function.c.foo      2008-04-01 17:40:49.000000000 -0700
+++ function.c  2008-04-01 21:34:20.000000000 -0700
@@ -3940,7 +3940,7 @@ push_struct_function (tree fndecl)
 static void
 prepare_function_start (void)
 {
-  gcc_assert (!rtl.emit.x_last_insn);
+  gcc_assert (!rtl.emit.sequence_stack || !rtl.emit.x_last_insn);
   init_emit ();
   init_varasm_status ();
   init_expr ();
Comment 3 Jan Hubicka 2008-04-02 09:35:51 UTC
Subject: Re:   New: [4.4 Regression] Revision 133787 breaks ia64

Hi,
I've added the assert to check that we don't initialize RTL world twice
without freeing it first (and thus that we don't leak memory).  This
seems to be the case.  Naively, something like this should fix it.
I am building a cross and will try to reproduce it.

Index: config/ia64/ia64.c
===================================================================
*** config/ia64/ia64.c	(revision 133785)
--- config/ia64/ia64.c	(working copy)
*************** ia64_output_mi_thunk (FILE *file, tree t
*** 9694,9699 ****
--- 9694,9700 ----
    final_start_function (insn, file, 1);
    final (insn, file, 1);
    final_end_function ();
+   free_after_compilation (cfun);
  
    reload_completed = 0;
    epilogue_completed = 0;
Comment 4 Dominique d'Humieres 2008-04-02 14:31:58 UTC
I think PR35801 is the same problem on powerpc-apple-darwin9.

Comment 5 H.J. Lu 2008-04-02 16:42:08 UTC
(In reply to comment #3)
> Subject: Re:   New: [4.4 Regression] Revision 133787 breaks ia64
> 
> Hi,
> I've added the assert to check that we don't initialize RTL world twice
> without freeing it first (and thus that we don't leak memory).  This
> seems to be the case.  Naively, something like this should fix it.
> I am building a cross and will try to reproduce it.
> 
> Index: config/ia64/ia64.c
> ===================================================================
> *** config/ia64/ia64.c  (revision 133785)
> --- config/ia64/ia64.c  (working copy)
> *************** ia64_output_mi_thunk (FILE *file, tree t
> *** 9694,9699 ****
> --- 9694,9700 ----
>     final_start_function (insn, file, 1);
>     final (insn, file, 1);
>     final_end_function ();
> +   free_after_compilation (cfun);
> 
>     reload_completed = 0;
>     epilogue_completed = 0;
> 

This patch works.
Comment 6 Jim Wilson 2008-04-03 05:16:07 UTC
Subject: Re:  [4.4 Regression] Revision 133787
 breaks ia64

hubicka at ucw dot cz wrote:
> *************** ia64_output_mi_thunk (FILE *file, tree t
>     final_end_function ();
> +   free_after_compilation (cfun);

The patch is OK.

But won't all targets that have similar code need the same fix?  If I cd 
to the config dir, and try "grep final_end_function */*" it looks like 
alpha, ia64, m68k, mips, rs6000, score (both score3 and score7), sh, and 
sparc all have the same problem.  The rs6000 port has already been fixed 
via PR 35801.  We have an ia64 patch here.  We also need patches for the 
rest.

Jim
Comment 7 Jan Hubicka 2008-04-03 06:12:25 UTC
Subject: Re:  [4.4 Regression] Revision 133787 breaks ia64

> The patch is OK.
> 
> But won't all targets that have similar code need the same fix?  If I cd 
> to the config dir, and try "grep final_end_function */*" it looks like 
> alpha, ia64, m68k, mips, rs6000, score (both score3 and score7), sh, and 
> sparc all have the same problem.  The rs6000 port has already been fixed 
> via PR 35801.  We have an ia64 patch here.  We also need patches for the 
> rest.

Thanks,
I've just noticed that too and send patch for all the backends.  Looks
like we was leaking memory here for ages, probably not that big deal
since thunks are pretty small functions, but still keeping all the RTL
register tables around seems bit expensive.

Honza
> 
> Jim
> 
> 
> -- 
> 
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35795
> 
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug, or are watching someone who is.
Comment 8 hjl@gcc.gnu.org 2008-04-03 12:50:19 UTC
Subject: Bug 35795

Author: hjl
Date: Thu Apr  3 12:49:27 2008
New Revision: 133868

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=133868
Log:
2008-04-03  Jan Hubicka  <jh@suse.cz>

	PR tree-optimization/35795
	* alpha/alpha.c (alpha_output_mi_thunk_osf): Free after compilation.
	* sparc/sparc.c (sparc_output_mi_thunk): Likewise.
	* ia64/ia64.c (ia64_output_mi_thunk): Likewise.
	* m68k/m68k.c (m68k_output_mi_thunk): Likewise.
	* score/score3.c (score3_output_mi_thunk): Likewise.
	* score/score7.c (score7_output_mi_thunk): Likewise.
	* mips/mips.c (mips_output_mi_thunk): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/alpha/alpha.c
    trunk/gcc/config/ia64/ia64.c
    trunk/gcc/config/m68k/m68k.c
    trunk/gcc/config/mips/mips.c
    trunk/gcc/config/score/score3.c
    trunk/gcc/config/score/score7.c
    trunk/gcc/config/sparc/sparc.c

Comment 9 Joel Sherrill 2008-04-03 13:44:48 UTC
I am pretty sure I saw this one targeting sparc-rtems.  Building an updated tree now to confirm it is the fix. 

../../../../gcc/libstdc++-v3/src/iostream-inst.cc: In member function 'void std::basic_iostream<char, std::char_traits<char> >::_ZThn8_NSdD1Ev()':
../../../../gcc/libstdc++-v3/src/iostream-inst.cc:51: internal compiler error: in prepare_function_start, at function.c:3940
Comment 10 Jan Hubicka 2008-04-03 15:44:04 UTC
Subject: Re:  [4.4 Regression] Revision 133787 breaks ia64

> I am pretty sure I saw this one targeting sparc-rtems.  Building an updated
> tree now to confirm it is the fix. 
> 
> ../../../../gcc/libstdc++-v3/src/iostream-inst.cc: In member function 'void
> std::basic_iostream<char, std::char_traits<char> >::_ZThn8_NSdD1Ev()':
> ../../../../gcc/libstdc++-v3/src/iostream-inst.cc:51: internal compiler error:
> in prepare_function_start, at function.c:3940

sparc, alpha, m68k, score and mips contained same problem, so hopefully
it is fixed now.

Honza
Comment 11 Joel Sherrill 2008-04-03 16:19:41 UTC
(In reply to comment #10)
> Subject: Re:  [4.4 Regression] Revision 133787 breaks ia64
> 
> > I am pretty sure I saw this one targeting sparc-rtems.  Building an updated
> > tree now to confirm it is the fix. 
> > 
> > ../../../../gcc/libstdc++-v3/src/iostream-inst.cc: In member function 'void
> > std::basic_iostream<char, std::char_traits<char> >::_ZThn8_NSdD1Ev()':
> > ../../../../gcc/libstdc++-v3/src/iostream-inst.cc:51: internal compiler error:
> > in prepare_function_start, at function.c:3940
> 
> sparc, alpha, m68k, score and mips contained same problem, so hopefully
> it is fixed now.

My sparc build is past this point now so I think it is fixed there.

Comment 12 H.J. Lu 2008-04-03 16:21:59 UTC
Fixed.