Summary: | [3.3 regression] [SH] segfault in gen_far_branch (config/sh/sh.c) | ||
---|---|---|---|
Product: | gcc | Reporter: | marcus |
Component: | target | Assignee: | Jorn Wolfgang Rennecke <amylaar> |
Status: | RESOLVED FIXED | ||
Severity: | critical | CC: | aoliva, dank, dhazeghi, gcc-bugs, joern.rennecke |
Priority: | P3 | Keywords: | ice-on-valid-code |
Version: | 3.3 | ||
Target Milestone: | 3.3.3 | ||
Host: | Target: | sh-unknown-elf | |
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2003-08-05 04:43:28 | |
Attachments: | modified testcase to show problem in 3.4 |
Description
marcus
2003-01-18 21:26:00 UTC
Fix: Use less optimization, or don't specify -fomit-frame-pointer. From: Dara Hazeghi <dhazeghi@yahoo.com> To: gcc-gnats@gcc.gnu.org, marcus@mc.pp.se Cc: Subject: Re: target/9365: [SH] segfault in gen_far_branch (config/sh/sh.c) Date: Fri, 9 May 2003 22:42:27 -0700 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit- trail&database=gcc&pr=9365 Hello, I can confirm that on 3.3 branch the testcase in this report fails, but on 3.2.3 and mainline (20030509) it compiles fine. Dara State-Changed-From-To: open->analyzed State-Changed-Why: Confirmed with 3.3 Postponed until GCC 3.3.2 -- SH is not a primary platform. Confirmed on i586-redhat-linux-gnu as of gcc version 3.3.2 20030904 (prerelease). Here is a dumb patch that makes the segfault go away, but I can't judge if the assembly code is valid. Index: config/sh/sh.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/sh/sh.c,v retrieving revision 1.188.2.6 diff -u -p -r1.188.2.6 sh.c --- config/sh/sh.c 25 Jun 2003 17:38:01 -0000 1.188.2.6 +++ config/sh/sh.c 7 Sep 2003 15:48:28 -0000 @@ -3233,13 +3233,16 @@ gen_far_branch (bp) JUMP_LABEL (jump) = bp->far_label; if (! invert_jump (insn, label, 1)) abort (); - (emit_insn_after - (gen_stuff_delay_slot - (GEN_INT (INSN_UID (XEXP (SET_SRC (PATTERN (jump)), 0))), - GEN_INT (recog_memoized (insn) == CODE_FOR_branch_false)), - insn)); - /* Prevent reorg from undoing our splits. */ - gen_block_redirect (jump, bp->address += 2, 2); + if (bp->far_label) + { + emit_insn_after ( + gen_stuff_delay_slot ( + GEN_INT (INSN_UID (XEXP (SET_SRC (PATTERN (jump)), 0))), + GEN_INT (recog_memoized (insn) == CODE_FOR_branch_false)), + insn); + /* Prevent reorg from undoing our splits. */ + gen_block_redirect (jump, bp->address += 2, 2); + } } /* Fix up ADDR_DIFF_VECs. */ I removed the 'host' field because the bug is not SPARC-specific. Is there a testcase in the test suite for this yet? I've prepared a patch to add a testcase for this PR to the testsuite; see http://www.kegel.com/crosstool/current/patches/gcc-3.3.1/pr9365-1-test.patch I'll submit it to gcc-patches in a couple days if nobody squawks. Postponed until GCC 3.3.3; SH is not a primary platform. Joern, Alexandre -- Do you think you would have a chance to look into this? -- Gaby (In reply to comment #9) > Joern, Alexandre -- > Do you think you would have a chance to look > into this? So no one of you can't comment on this PR? Created attachment 5480 [details]
modified testcase to show problem in 3.4
The code generated by the 3.4 compiler is more compact, so it needs a larger
testcase to trigger the problem.
Since this test is derived from the original one, we still have to resolve the
question of the copyright status.
Subject: Bug 9365 CVSROOT: /cvs/gcc Module name: gcc Changes by: amylaar@gcc.gnu.org 2004-01-14 18:02:44 Modified files: gcc : ChangeLog gcc/config/sh : sh.c Log message: PR target/9365 * sh.c (gen_block_redirect): Add special handling of RETURN. (gen_far_branch) Don't call gen_stuff_delay_slot if there is no far branch target (i.e. it's a return). Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2286&r2=2.2287 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.c.diff?cvsroot=gcc&r1=1.245&r2=1.246 Subject: Bug 9365 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: amylaar@gcc.gnu.org 2004-01-14 18:11:37 Modified files: gcc : ChangeLog gcc/config/sh : sh.c Log message: PR target/9365 * sh.c (gen_block_redirect): Add special handling of RETURN. (gen_far_branch) Don't call gen_stuff_delay_slot if there is no far branch target (i.e. it's a return). Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.881&r2=1.16114.2.882 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/sh/sh.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.188.2.8&r2=1.188.2.9 Fixed for 3.3.3 and 3.4. Subject: Re: [3.3 regression] [SH] segfault in gen_far_branch (config/sh/sh.c)
> ------- Additional Comments From pinskia at gcc dot gnu dot org 2004-01-14 18:41 -------
> Fixed for 3.3.3 and 3.4.
>
> --
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|ASSIGNED |RESOLVED
> Resolution| |FIXED
What about the Copyright of the testcase? Can add it to the gcc testsuite?
Subject: Re: [3.3 regression] [SH] segfault in gen_far_branch (config/sh/sh.c) "joern dot rennecke at superh dot com" <gcc-bugzilla@gcc.gnu.org> writes: > What about the Copyright of the testcase? Can add it to the gcc testsuite? Is that question directed at me? I consider my original testcase to be in the Public Domain. The code is trivial anyway. // Marcus My tweaks to Marcus's testcase, http://www.kegel.com/crosstool/current/patches/gcc-3.3.1/pr9365-1-test.patch, are public domain and trivial. Subject: Bug 9365 CVSROOT: /cvs/gcc Module name: gcc Changes by: amylaar@gcc.gnu.org 2004-01-15 12:40:06 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: pr9365-1.c Log message: 2004-01-15 Marcus Comstedt <marcus@mc.pp.se> Dan Kegel <dank@kegel.com> J"orn Rennecke <joern.rennecke@superh.com> PR target/9365 * gcc.dg/pr9365-1.c: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3377&r2=1.3378 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/pr9365-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1 |