public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mikpe at it dot uu.se" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/48835] porting GNAT to m68k-linux
Date: Fri, 22 Mar 2013 14:30:00 -0000	[thread overview]
Message-ID: <bug-48835-4-2HVkGBQsVL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-48835-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #55 from Mikael Pettersson <mikpe at it dot uu.se> 2013-03-22 14:30:23 UTC ---
(In reply to comment #54)
> This ICE started with r180192, an ICE fix (PR50780).  I don't see anything in
> that patch that seems m68k or cc0 related

Actually, r180192 is HIGHLY CC0-related, see PR49847#c16.

Here's an annotated gdb session:

sh-4.2$ gdb /mnt/scratch/objdir47/./gcc/gnat1
GNU gdb (GDB) Brewer Linux (7.4.50.20120120-52.bl17.bl.1)
Copyright (C) 2012 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 "m68k-brewer-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /mnt/scratch/objdir47/gcc/gnat1...done.
(gdb) run -gnatwa -quiet -nostdinc -dumpbase a-calfor.adb -auxbase-strip
a-calfor.o -O2 -Wextra -Wall -fpic -g -mcpu=68060 -gnatpg -mcpu=68060 -gnatO
a-calfor.o a-calfor.adb -o /tmp/ccudsaKf.s
Starting program: /mnt/scratch/objdir47/gcc/gnat1 -gnatwa -quiet -nostdinc
-dumpbase a-calfor.adb -auxbase-strip a-calfor.o -O2 -Wextra -Wall -fpic -g
-mcpu=68060 -gnatpg -mcpu=68060 -gnatO a-calfor.o a-calfor.adb -o
/tmp/ccudsaKf.s

Program received signal SIGSEGV, Segmentation fault.
0x806f7016 in find_comparison_args (code=GE, parg1=0xeffff218,
parg2=0xeffff21c, pmode1=0xeffff220, pmode2=0xeffff224) at
/mnt/scratch/gcc-4.7-r180192/gcc/cse.c:2975
2975      while (arg2 == CONST0_RTX (GET_MODE (arg1)))
Missing separate debuginfos, use: debuginfo-install
glibc-2.15-58.bl17.bl.1.m68k gmp-5.0.4-1.bl15.bl.2.m68k
libmpc-1.0.1-1.bl17.bl.1.m68k mpfr-3.1.1-1.bl17.bl.1.m68k
zlib-1.2.5-7.bl17.m68k
(gdb) bt
#0  0x806f7016 in find_comparison_args (code=GE, parg1=0xeffff218,
parg2=0xeffff21c, pmode1=0xeffff220, pmode2=0xeffff224) at
/mnt/scratch/gcc-4.7-r180192/gcc/cse.c:2975
#1  0x806fe620 in record_jump_equiv (taken=<optimized out>, insn=0xc0a07440) at
/mnt/scratch/gcc-4.7-r180192/gcc/cse.c:3920
#2  cse_extended_basic_block (ebb_data=<optimized out>) at
/mnt/scratch/gcc-4.7-r180192/gcc/cse.c:6432
#3  cse_main (f=0xc09e3f80, nregs=185) at
/mnt/scratch/gcc-4.7-r180192/gcc/cse.c:6527
#4  0x806fe720 in rest_of_handle_cse () at
/mnt/scratch/gcc-4.7-r180192/gcc/cse.c:7379
#5  0x804ba474 in execute_one_pass (pass=0x8088bc8c) at
/mnt/scratch/gcc-4.7-r180192/gcc/passes.c:2064
#6  0x804ba780 in execute_pass_list (pass=0x8088bc8c) at
/mnt/scratch/gcc-4.7-r180192/gcc/passes.c:2119
#7  0x804ba790 in execute_pass_list (pass=0x80889834) at
/mnt/scratch/gcc-4.7-r180192/gcc/passes.c:2120
#8  0x8057b212 in tree_rest_of_compilation (fndecl=0xc0547600) at
/mnt/scratch/gcc-4.7-r180192/gcc/tree-optimize.c:420
#9  0x8035bb5a in cgraph_expand_function (node=0xc04d3d10) at
/mnt/scratch/gcc-4.7-r180192/gcc/cgraphunit.c:1804
#10 0x8035d3f2 in cgraph_expand_all_functions () at
/mnt/scratch/gcc-4.7-r180192/gcc/cgraphunit.c:1871
#11 cgraph_optimize () at /mnt/scratch/gcc-4.7-r180192/gcc/cgraphunit.c:2168
#12 0x8035d57e in cgraph_finalize_compilation_unit () at
/mnt/scratch/gcc-4.7-r180192/gcc/cgraphunit.c:1312
#13 0x80049b26 in gnat_write_global_declarations () at
/mnt/scratch/gcc-4.7-r180192/gcc/ada/gcc-interface/utils.c:4920
#14 0x8053e70a in compile_file () at
/mnt/scratch/gcc-4.7-r180192/gcc/toplev.c:581
#15 do_compile () at /mnt/scratch/gcc-4.7-r180192/gcc/toplev.c:1930
#16 toplev_main (argc=21, argv=0xeffff444) at
/mnt/scratch/gcc-4.7-r180192/gcc/toplev.c:2006
#17 0xc012dee8 in __libc_start_main () from /lib/libc.so.6
#18 0x800279a2 in _start ()
(gdb) list
2970    
2971      arg1 = *parg1, arg2 = *parg2;
2972    
2973      /* If ARG2 is const0_rtx, see what ARG1 is equivalent to.  */
2974    
2975      while (arg2 == CONST0_RTX (GET_MODE (arg1)))
2976        {
2977          /* Set nonzero when we find something of interest.  */
2978          rtx x = 0;
2979          int reverse_code = 0;
(gdb) print *parg1
$1 = (rtx) 0x0

We're at the start of find_comparison_args, and *parg1 is NULL. No wonder we
SEGV then at line 2975.

(gdb) up
#1  0x806fe620 in record_jump_equiv (taken=<optimized out>, insn=0xc0a07440) at
/mnt/scratch/gcc-4.7-r180192/gcc/cse.c:3920
3920      code = find_comparison_args (code, &op0, &op1, &mode0, &mode1);
(gdb) list
3915         know that it isn't valid for floating-point.  */
3916      code = GET_CODE (XEXP (SET_SRC (set), 0));
3917      op0 = fold_rtx (XEXP (XEXP (SET_SRC (set), 0), 0), insn);
3918      op1 = fold_rtx (XEXP (XEXP (SET_SRC (set), 0), 1), insn);
3919    
3920      code = find_comparison_args (code, &op0, &op1, &mode0, &mode1);
3921      if (! cond_known_true)
3922        {
3923          code = reversed_comparison_code_parts (code, op0, op1, insn);
3924    
(gdb) print op0
$2 = (rtx) 0x0
(gdb) call debug_rtx(set)
(set (pc)
    (if_then_else (ge (cc0)
            (const_int 0 [0]))
        (label_ref:SI 471)
        (pc)))
(gdb) call debug_rtx(insn)
(jump_insn 298 457 458 43 (set (pc)
        (if_then_else (ge (cc0)
                (const_int 0 [0]))
            (label_ref:SI 471)
            (pc))) a-calfor.adb:758 398 {bge}
     (expr_list:REG_BR_PROB (const_int 5000 [0x1388])
        (nil))
 -> 471)

record_jump_equiv gets a jump_insn with a condition whose OP0 was (cc0) but
fold_rtx turned it into NULL.  So we're calling find_comparison_args with a
pointer to NULL, causing it to SEGV.

A quick look at the start of fold_rtx reveals:

  /* Try to perform some initial simplifications on X.  */
  code = GET_CODE (x);
  switch (code)
    {
...
#ifdef HAVE_cc0
    case CC0:
      return prev_insn_cc0;
#endif

Remember PR49847?  A consequence of r180192 is that it may separate CC0 setters
from users in EH contexts.  And that's clearly what's happening here.  Patching
the above case to return x when prev_insn_cc0 is NULL eliminates the SEGV when
compiling a-calfor.adb, and allows compilation to proceed through many more
.adb files; a debug printf shows that the case above with NULL prev_insn_cc0
triggers many times when compiling the 68060-optimized Ada runtime.  I'm
currently doing a clean bootstrap with that patch.


  parent reply	other threads:[~2013-03-22 14:30 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-30 15:47 [Bug ada/48835] New: Porting GNAT to GNU/Linux/m68k tg at mirbsd dot org
2011-04-30 16:25 ` [Bug ada/48835] " mikpe at it dot uu.se
2011-04-30 21:58 ` schwab@linux-m68k.org
2011-04-30 22:16 ` tg at mirbsd dot org
2011-04-30 22:20 ` tg at mirbsd dot org
2011-04-30 22:29 ` tg at mirbsd dot org
2011-05-01  7:58 ` schwab@linux-m68k.org
2011-06-10 20:55 ` tg at mirbsd dot org
2011-06-11 12:33 ` mikpe at it dot uu.se
2011-06-13 21:16 ` ebotcazou at gcc dot gnu.org
2011-06-14  8:13 ` mikpe at it dot uu.se
2011-06-14  8:44 ` ebotcazou at gcc dot gnu.org
2011-06-14 10:59 ` tg at mirbsd dot org
2011-06-14 11:28 ` ebotcazou at gcc dot gnu.org
2011-06-17 10:03 ` mikpe at it dot uu.se
2011-06-23  8:37 ` mikpe at it dot uu.se
2011-06-29  7:41 ` mikpe at it dot uu.se
2011-07-01  7:54 ` mikpe at it dot uu.se
2011-07-09 10:58 ` mikpe at it dot uu.se
2011-07-11 22:28 ` mikpe at it dot uu.se
2011-07-11 22:52 ` tg at mirbsd dot org
2011-07-12 15:44 ` mikpe at it dot uu.se
2011-07-12 17:06 ` ebotcazou at gcc dot gnu.org
2011-07-14  8:45 ` mikpe at it dot uu.se
2011-07-15 10:13 ` mikpe at it dot uu.se
2011-07-16 13:22 ` mikpe at it dot uu.se
2011-07-16 16:18 ` tg at mirbsd dot de
2011-07-17 10:19 ` mikpe at it dot uu.se
2011-07-19  9:12 ` mikpe at it dot uu.se
2011-09-10 10:15 ` mikpe at it dot uu.se
2011-09-10 13:36 ` tg at mirbsd dot org
2011-09-21  8:22 ` mikpe at it dot uu.se
2011-09-25 19:03 ` mikpe at it dot uu.se
2011-10-12 17:21 ` mikpe at it dot uu.se
2011-10-14  7:54 ` mikpe at it dot uu.se
2011-10-14  7:58 ` mikpe at it dot uu.se
2011-10-14  8:40 ` tg at mirbsd dot org
2011-10-16 13:20 ` rsandifo at gcc dot gnu.org
2011-10-17 16:26 ` mikpe at it dot uu.se
2011-10-17 20:30 ` tg at mirbsd dot org
2011-10-17 22:22 ` ebotcazou at gcc dot gnu.org
2011-11-21 10:11 ` mikpe at it dot uu.se
2011-12-07  9:59 ` mikpe at it dot uu.se
2011-12-07 11:07 ` schwab@linux-m68k.org
2011-12-07 12:04 ` mikpe at it dot uu.se
2011-12-07 12:48 ` schwab@linux-m68k.org
2011-12-07 13:10 ` schwab@linux-m68k.org
2011-12-07 21:13 ` mikpe at it dot uu.se
2011-12-08 10:05 ` mikpe at it dot uu.se
2011-12-08 16:04 ` ebotcazou at gcc dot gnu.org
2011-12-09  9:47 ` mikpe at it dot uu.se
2012-02-11 14:44 ` ebotcazou at gcc dot gnu.org
2012-03-10  0:53 ` [Bug ada/48835] porting GNAT to m68k-linux tg at mirbsd dot org
2012-03-12 22:16 ` mikpe at it dot uu.se
2013-03-20 11:06 ` mikpe at it dot uu.se
2013-03-22 14:30 ` mikpe at it dot uu.se [this message]
2014-01-06  7:40 ` ebotcazou at gcc dot gnu.org
2014-03-13 15:45 ` ebotcazou at gcc dot gnu.org
2014-05-02 16:42 ` schwab@linux-m68k.org

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=bug-48835-4-2HVkGBQsVL@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).