This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/35785] gcc.c-torture/compile/pr11832.c doesn't work for Linux/ia64
- From: "wilson at tuliptree dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Apr 2008 06:26:42 -0000
- Subject: [Bug rtl-optimization/35785] gcc.c-torture/compile/pr11832.c doesn't work for Linux/ia64
- References: <bug-35785-682@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from wilson at tuliptree dot org 2008-04-03 06:26 -------
Subject: Re: New: gcc.c-torture/compile/pr11832.c
doesn't work for Linux/ia64
hjl dot tools at gmail dot com wrote:
> (set (pc)^M
> (reg:DI 2 loc79)) 329 {indirect_jump} (nil))^M
This is a problem with the seqabstr pass, which is confusingly in the
rtl-factoring.c file. It is allocating a hard register, but not
checking that the register is OK for a jump instruction. On IA-64, we
can't use a general reg here, we need one of the branch registers.
I see a REGNO_OK_FOR_INDIRECT_JUMP_P macro which we could define in the
ia64.h file to fix the problem. This macro is of course undocumented.
Someone should file a PR for that and assign it to the author of this code.
I tried adding the obvious definition to ia64.h and now it fails in a
different place. rtl-factoring.c aka seqabstr is doing
> /* Emit an insn saving the return address to the link register before the
> sequence. */
> saveinsn = emit_insn_after (gen_move_insn (pattern_seqs->link_reg,
> gen_symbol_ref_rtx_for_label
> (retlabel)), BB_END (bb));
It is trying to load a label_ref directly into a branch register which
is certainly not going to work on an IA-64. Since this is after reload,
there is nothing the ia64.md backend can do to fix this. This requires
a rtl-factoring.c aka seqabstr fix. It needs to allocate two registers
for a machine like IA-64, a general reg to load the label into, and a
branch reg to move the label value to for the branch.
I tried writing a quick patch, taking advantage of the fact that
REGNO_OK_FOR_INDIRECT_JUMP_P is undocumented and unused, hence I can
redfine it anyway I need in order to make the IA-64 port work. I didn't
give this much thought; this can clearly be improved.
I'll attach the two patches I have. I'm not sure if this will actually
work, but at least the compiler doesn't crash anymore, and I don't see
anything obviously wrong with the code.
Jim
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35785