This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c/7871: ICE on legal code, global register variables problems


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  <wilson at tuliptree dot org>
> 
> 	* 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]