public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/64515] New: Segmentation fault during linker operation in gcc for arm-none-eabi
@ 2015-01-06 21:18 karolas801 at student dot polsl.pl
  2015-01-06 22:24 ` [Bug c/64515] " karolas801 at student dot polsl.pl
  0 siblings, 1 reply; 2+ messages in thread
From: karolas801 at student dot polsl.pl @ 2015-01-06 21:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64515

            Bug ID: 64515
           Summary: Segmentation fault during linker operation in gcc for
                    arm-none-eabi
           Product: gcc
           Version: 4.8.4
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: karolas801 at student dot polsl.pl

Created attachment 34390
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34390&action=edit
full log from compilation

I was wondering the new ChibiOS RTOS version, so I clone it
(https://github.com/ChibiOS/ChibiOS branch master), go to:
testhal/STM32/STM32F1xx/USB_CDC
and type make. After compilation I saw linker error:

Linking build/ch.elf
../../../../test/rt/test.c: In function 'TestThread':
../../../../test/rt/test.c:314:7: internal compiler error: Segmentation fault
 msg_t TestThread(void *p) {
       ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: arm-none-eabi-gcc returned 1 exit status
/home/cruz/Embedded_systems/toolchain/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld:
lto-wrapper failed
collect2: error: ld returned 1 exit status
make: *** [build/ch.elf] Błąd 1

So I submit to you full bug report :)

My system:

lsb_release -a
No LSB modules are available.
Distributor ID:    LinuxMint
Description:    Linux Mint 16 Petra
Release:    16
Codename:    petra


kernel:
Linux cruz-laptop 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013
x86_64 x86_64 x86_64 GNU/Linux

In attachement full log from compilation.
>From gcc-bugs-return-472341-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Jan 06 21:39:44 2015
Return-Path: <gcc-bugs-return-472341-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 1478 invoked by alias); 6 Jan 2015 21:39:43 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 1320 invoked by uid 48); 6 Jan 2015 21:39:37 -0000
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/64479] [4.8 Regression][SH] wrong optimization delayed-branch
Date: Tue, 06 Jan 2015 21:39:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.8.4
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: olegendo at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-64479-4-HyjojeC7hG@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64479-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64479-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-01/txt/msg00335.txt.bz2
Content-length: 4014

https://gcc.gnu.org/bugzilla/show_bug.cgi?idd479

--- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> ---
The *cbranch_t splitter is done like 4 times, because there are 4 split passes.
 The last split pass is split5, which is done right after the delayed-branch
pass.  Before delayed-branch handling the call insn looks like:

(call_insn 13 79 14 2 (parallel [
            (call (mem:SI (reg/f:SI 1 r1 [167]) [0 bar S4 A32])
                (const_int 0 [0]))
            (use (reg:PSI 151 ))
            (clobber (reg:SI 146 pr))
        ]) sh_tmp.cpp:453 304 {calli}
     (expr_list:REG_DEAD (reg:PSI 151 )
        (expr_list:REG_DEAD (reg:SI 4 r4)
            (expr_list:REG_DEAD (reg/f:SI 1 r1 [167])
                (nil))))
    (expr_list:REG_UNUSED (use (reg:SI 4 r4))
        (nil)))

And modified_between_p returns true.

After delayed-branch pass the call insn looks like:

(insn 122 60 14 (sequence [
            (call_insn 13 60 12 (parallel [
                        (call (mem:SI (reg/f:SI 1 r1 [167]) [0 bar S4 A32])
                            (const_int 0 [0]))
                        (use (reg:PSI 151 ))
                        (clobber (reg:SI 146 pr))
                    ]) sh_tmp.cpp:453 304 {calli}
                 (expr_list:REG_DEAD (reg:PSI 151 )
                    (expr_list:REG_DEAD (reg:SI 4 r4)
                        (expr_list:REG_DEAD (reg/f:SI 1 r1 [167])
                            (nil))))
                (expr_list:REG_UNUSED (use (reg:SI 4 r4))
                    (nil)))
            (insn 12 13 14 (set (reg:SI 4 r4)
                    (reg/f:SI 15 r15)) 247 {movsi_ie}
                 (nil))
        ]) sh_tmp.cpp:453 -1
     (nil))

And modified_between_p returns false, because the function reg_set_p doesn't
handle sequence rtx codes.

This could be a fix:

Index: gcc/rtlanal.c
==================================================================--- gcc/rtlanal.c    (revision 218544)
+++ gcc/rtlanal.c    (working copy)
@@ -875,17 +875,24 @@
 {
   /* We can be passed an insn or part of one.  If we are passed an insn,
      check if a side-effect of the insn clobbers REG.  */
-  if (INSN_P (insn)
-      && (FIND_REG_INC_NOTE (insn, reg)
-      || (CALL_P (insn)
-          && ((REG_P (reg)
-           && REGNO (reg) < FIRST_PSEUDO_REGISTER
-           && overlaps_hard_reg_set_p (regs_invalidated_by_call,
-                           GET_MODE (reg), REGNO (reg)))
-          || MEM_P (reg)
-          || find_reg_fusage (insn, CLOBBER, reg)))))
-    return 1;
+  if (INSN_P (insn) && FIND_REG_INC_NOTE (insn, reg))
+    return true;

+  /* After delay slot handling, call and branch insns might be in a
+     sequence.  Check all the elements there.  */
+  if (INSN_P (insn) && GET_CODE (PATTERN (insn)) == SEQUENCE)
+    for (int i = 0; i < XVECLEN (PATTERN (insn), 0); ++i)
+      if (reg_set_p (reg, XVECEXP (PATTERN (insn), 0, i)))
+    return true;
+
+  if (CALL_P (insn)
+      && ((REG_P (reg) && REGNO (reg) < FIRST_PSEUDO_REGISTER
+       && overlaps_hard_reg_set_p (regs_invalidated_by_call,
+                       GET_MODE (reg), REGNO (reg)))
+      || MEM_P (reg)
+      || find_reg_fusage (insn, CLOBBER, reg)))
+    return true;
+
   return set_of (reg, insn) != NULL_RTX;
 }


I haven't checked it, but maybe this also helps PR 56451 in some way.


Alternatively, we can just disable the *cbranch_t splitter after the
delay-branch pass:

Index: gcc/config/sh/sh.md
==================================================================--- gcc/config/sh/sh.md    (revision 218544)
+++ gcc/config/sh/sh.md    (working copy)
@@ -8361,7 +8361,7 @@
 {
   return output_branch (sh_eval_treg_value (operands[1]), insn, operands);
 }
-  "&& 1"
+  "&& !crtl->dbr_scheduled_p"
   [(set (pc) (if_then_else (eq (reg:SI T_REG) (match_dup 2))
                (label_ref (match_dup 0))
                (pc)))]


Both patches fix the problem here, but I haven't tested them further.  My
feeling is that the function reg_set_p should be fixed.


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

* [Bug c/64515] Segmentation fault during linker operation in gcc for arm-none-eabi
  2015-01-06 21:18 [Bug c/64515] New: Segmentation fault during linker operation in gcc for arm-none-eabi karolas801 at student dot polsl.pl
@ 2015-01-06 22:24 ` karolas801 at student dot polsl.pl
  0 siblings, 0 replies; 2+ messages in thread
From: karolas801 at student dot polsl.pl @ 2015-01-06 22:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64515

--- Comment #1 from Karol <karolas801 at student dot polsl.pl> ---
Problem doesn't occurs in gcc 4.9 version


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

end of thread, other threads:[~2015-01-06 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-06 21:18 [Bug c/64515] New: Segmentation fault during linker operation in gcc for arm-none-eabi karolas801 at student dot polsl.pl
2015-01-06 22:24 ` [Bug c/64515] " karolas801 at student dot polsl.pl

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