public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/40419]  New: __attribute__((mips16)) is broken on trunk.
@ 2009-06-11 21:02 ramana at gcc dot gnu dot org
  2009-06-11 21:29 ` [Bug target/40419] " ramana at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: ramana at gcc dot gnu dot org @ 2009-06-11 21:02 UTC (permalink / raw)
  To: gcc-bugs

While implementing something like mips16 as a __attribute__((thumb)) for the
ARM port I discovered that the following testcase stripped down from a testcase
in the gcc testsuite causes a segmentation fault in the compiler for the MIPS
port as well.


static double __attribute__((mips16)) time_giop_encode (unsigned long);
int
main(int ac, char *av[])
{
  time_giop_encode (0);
}


static
double  __attribute__ ((mips16))
time_giop_encode  (unsigned long l)
{
  giop_encode_ulong (l);
}


A run through a valgrind showed that there was a write to an invalid address - 


==7998== Invalid write of size 4
==7998==    at 0x8234A0E: gen_reg_rtx (emit-rtl.c:912)
==7998==    by 0x830CD7B: expand_function_start (function.c:4416)
==7998==    by 0x88BBF81: gimple_expand_cfg (cfgexpand.c:2512)
==7998==    by 0x83D220C: execute_one_pass (passes.c:1289)
==7998==    by 0x83D248B: execute_pass_list (passes.c:1338)
==7998==    by 0x854C81F: tree_rest_of_compilation (tree-optimize.c:394)
==7998==    by 0x86C524B: cgraph_expand_function (cgraphunit.c:1097)
==7998==    by 0x86C7A4C: cgraph_optimize (cgraphunit.c:1156)
==7998==    by 0x80BE9BA: c_write_global_declarations (c-decl.c:8593)
==7998==    by 0x84F4255: toplev_main (toplev.c:1044)
==7998==    by 0x8144A21: main (main.c:35)
==7998==  Address 0x46811f0 is not stack'd, malloc'd or (recently) free'd
==7998== 
==7998== Invalid write of size 4
==7998==    at 0x8234A0E: gen_reg_rtx (emit-rtl.c:912)
==7998==    by 0x8304E0B: assign_parm_setup_reg (function.c:2780)
==7998==    by 0x830AB61: assign_parms (function.c:3172)
==7998==    by 0x830C938: expand_function_start (function.c:4432)
==7998==    by 0x88BBF81: gimple_expand_cfg (cfgexpand.c:2512)
==7998==    by 0x83D220C: execute_one_pass (passes.c:1289)
==7998==    by 0x83D248B: execute_pass_list (passes.c:1338)
==7998==    by 0x854C81F: tree_rest_of_compilation (tree-optimize.c:394)
==7998==    by 0x86C524B: cgraph_expand_function (cgraphunit.c:1097)
==7998==    by 0x86C7A4C: cgraph_optimize (cgraphunit.c:1156)
==7998==    by 0x80BE9BA: c_write_global_declarations (c-decl.c:8593)
==7998==    by 0x84F4255: toplev_main (toplev.c:1044)
==7998==  Address 0x46811f4 is not stack'd, malloc'd or (recently) free'd
==7998== 
==7998== Invalid write of size 1
==7998==    at 0x82351A2: mark_reg_pointer (emit-rtl.c:1120)
==7998==    by 0x830522D: assign_parm_setup_reg (function.c:2945)
==7998==    by 0x830AB61: assign_parms (function.c:3172)
==7998==    by 0x830C938: expand_function_start (function.c:4432)
==7998==    by 0x88BBF81: gimple_expand_cfg (cfgexpand.c:2512)
==7998==    by 0x83D220C: execute_one_pass (passes.c:1289)
==7998==    by 0x83D248B: execute_pass_list (passes.c:1338)
==7998==    by 0x854C81F: tree_rest_of_compilation (tree-optimize.c:394)
==7998==    by 0x86C524B: cgraph_expand_function (cgraphunit.c:1097)
==7998==    by 0x86C7A4C: cgraph_optimize (cgraphunit.c:1156)
==7998==    by 0x80BE9BA: c_write_global_declarations (c-decl.c:8593)
==7998==    by 0x84F4255: toplev_main (toplev.c:1044)
==7998==  Address 0x479423a is 1 bytes after a block of size 1 alloc'd
==7998==    at 0x4026FDE: malloc (vg_replace_malloc.c:207)
==7998==    by 0x89D8DC7: xrealloc (xmalloc.c:177)
==7998==    by 0x8234A5E: gen_reg_rtx (emit-rtl.c:900)
==7998==    by 0x830CD7B: expand_function_start (function.c:4416)
==7998==    by 0x88BBF81: gimple_expand_cfg (cfgexpand.c:2512)
==7998==    by 0x83D220C: execute_one_pass (passes.c:1289)
==7998==    by 0x83D248B: execute_pass_list (passes.c:1338)
==7998==    by 0x854C81F: tree_rest_of_compilation (tree-optimize.c:394)
==7998==    by 0x86C524B: cgraph_expand_function (cgraphunit.c:1097)
==7998==    by 0x86C7A4C: cgraph_optimize (cgraphunit.c:1156)

The segfault is because reg_rtx_no is 0 and rtx_reg_no are uninitialized. It
looks like the infrastructure of target_reinit is broken because these are not
reinitialized correctly after inlining does its bit with setting and resetting
this .  init_function_start from tree_rest_of_compilation initializes these but
the inlining bits call set_cfun and do a target_reinit which sets all these
values to zero. expand_function_start gets called later and by this time since
regno_reg_rtx is set to 0 you have gen_reg_rtx returning a hard register.


-- 
           Summary: __attribute__((mips16)) is broken on trunk.
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ramana at gcc dot gnu dot org
 GCC build triplet: i686-linux-gnu
  GCC host triplet: i686-linux-gnu
GCC target triplet: mips-elf


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40419


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-18  9:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-40419-4@http.gcc.gnu.org/bugzilla/>
2012-01-09 22:15 ` [Bug target/40419] __attribute__((mips16)) is broken on trunk meadori at codesourcery dot com
2012-01-18 10:02 ` rsandifo at gcc dot gnu.org
2009-06-11 21:02 [Bug target/40419] New: " ramana at gcc dot gnu dot org
2009-06-11 21:29 ` [Bug target/40419] " ramana at gcc dot gnu dot org
2010-06-04 17:18 ` zadeck at naturalbridge dot com
2010-06-05  7:28 ` rsandifo at gcc dot gnu dot org
2010-06-05 11:44 ` zadeck at naturalbridge dot com

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).