From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6348 invoked by alias); 2 Apr 2003 20:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 6323 invoked by uid 71); 2 Apr 2003 20:56:01 -0000 Date: Wed, 02 Apr 2003 20:56:00 -0000 Message-ID: <20030402205601.6322.qmail@sources.redhat.com> To: wilson@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Richard Zidlicky Subject: Re: c/7871: ICE on legal code, global register variables problems Reply-To: Richard Zidlicky X-SW-Source: 2003-04/txt/msg00078.txt.bz2 List-Id: The following reply was made to PR c/7871; it has been noted by GNATS. From: Richard Zidlicky To: Jim Wilson Cc: Richard Henderson , gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org, wilson@gcc.gnu.org Subject: Re: c/7871: ICE on legal code, global register variables problems Date: Wed, 2 Apr 2003 22:49:26 +0200 On Mon, Mar 10, 2003 at 12:16:23AM -0500, Jim Wilson wrote: > Let me recap a bit. The current code calls mark_set_1 (...CLOBBER...) > and mark_used_regs. This causes CALL_INSNs to get a REG_UNDEAD note for > a global_reg, which confuses combine into deleting the insn that > initializes the global_reg. > > If I change this to mark_set_1 (...SET...), then there are no > REG_DEAD/REG_UNUSED notes which is correct. However, there are > LOG_LINKS from the insn that sets the global_reg to the CALL_INSN, and > from the CALL_INSN to the insn that uses the global_reg. This causes > combine to merge the 3 instructions together, and the result is that the > first insn that sets the global_reg gets simplified away. This could > perhaps be fixed by modifying combine to know that calls and global_regs > are special. > > If I avoid calling mark_set_1, then there are no REG_DEAD/REG_UNUSED > notes, but there is still a LOG_LINK from the first insn that sets the > global_reg to the CALL_INSN. When combine merges an unrelated insn into > the CALL_INSN, it sees a LOG_LINK that doesn't appear to belong on the > CALL_INSN, so it moves it to the next insn which uses the global_reg. > Combine then merges two instructions that set/use the global_reg, and > the first global_reg set before the call disappears again. > > Thus it seems that in order to get the right behavior, we need to avoid > adding any REG_NOTES or LOG_LINKS for global_regs. how does this differ from ´normal´ global variables? > I had to go back to gcc-2.95.1 to find a compiler that worked for my two > testcases, and it has this behavior. interesting, gcc-3.0.3 worked fine with my application. With Richard Henderson´s testcase 3.0.3 produces an ICE x5.c: In function `main': x5.c:20: Internal compiler error in verify_wide_reg_1, at flow.c:2769 It works with ´-O3´ though. > I am off on a trip, so it will be a while before I am able to continue > working on this. fine, I have just returned after a longer trip myself. > 2003-03-10 James E Wilson > > * flow.c (mark_set_1): Handle global_regs like the frame pointer. > > Index: flow.c > =================================================================== > RCS file: /cvs/gcc/gcc/gcc/flow.c,v > retrieving revision 1.549 > diff -p -r1.549 flow.c > *** flow.c 28 Feb 2003 10:11:47 -0000 1.549 > --- flow.c 10 Mar 2003 05:05:08 -0000 > *************** mark_set_1 (pbi, code, reg, cond, insn, > *** 2709,2714 **** > --- 2709,2715 ---- > #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM > && ! (regno_first == ARG_POINTER_REGNUM && fixed_regs[regno_first]) > #endif > + && ! (regno_first < FIRST_PSEUDO_REGISTER && global_regs[regno_first]) > ) > { > int some_was_live = 0, some_was_dead = 0; my application is still miscompiled with this patch. Double checked by replacing it with my patch and it works again. Tested only gcc-3.2, should this make any difference? I can try to identify the piece of code that was micompiled if it helps but it will likely be a big unreadable ´*.i´ file. Richard