From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11417 invoked by alias); 6 Jan 2015 21:18:55 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10850 invoked by uid 48); 6 Jan 2015 21:18:49 -0000 From: "karolas801 at student dot polsl.pl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/64515] New: Segmentation fault during linker operation in gcc for arm-none-eabi Date: Tue, 06 Jan 2015 21:18:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.8.4 X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: karolas801 at student dot polsl.pl X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg00334.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D64515 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=3D34390&action=3Dedit 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 fau= lt msg_t TestThread(void *p) { ^ Please submit a full bug report, with preprocessed source if appropriate. See 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=C5=82=C4=85d 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 2= 013 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: 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: List-Archive: List-Post: List-Help: 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" 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: In-Reply-To: References: 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?id=64479 --- Comment #2 from Oleg Endo --- 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.