public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tim Rye <timjrye@gmail.com>
To: Ian Lance Taylor <iant@google.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: Can be gcc portable to architecture without indexed addressing mode?
Date: Wed, 01 Aug 2012 14:54:00 -0000	[thread overview]
Message-ID: <CAP6CXZf=dGBN43Z=Jvu0O+JRoEjKj503nwSS2Lf8iVCTPJN5AA@mail.gmail.com> (raw)
In-Reply-To: <CAKOQZ8yc2f6f831r6UqZ7wgYh4W2znZTy_GXSUgNgUVk1OdrHA@mail.gmail.com>

Hi Ian,

Thanks for the speedy response.

> You should not be seeing such addresses if your legitimate_address_p
> target hook rejects them.

I'm pretty certain my legitimate_address_p does reject them. It's very
simple, and basically only accepts addresses which are constant or in
registers:

-------------

static bool mytarget_legitimate_address_p(enum machine_mode mode, rtx
x, bool strict) {

  while (GET_CODE(x) == MEM)
    x = XEXP(x,0);

  if (CONSTANT_P(x))
    return true;

  if (GET_CODE(x) == SUBREG && !strict)
    x = SUBREG_REG(x);

  if (GET_CODE(x) == REG) {

    if (!strict)
      return true;

    int regno = (int) REGNO(x);

    if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber)
      regno = reg_renumber[regno];

    return ((regno >= FIRST_WRITABLE_REG) && (regno <= LAST_WRITABLE_REG));
  }

  return false;
}

-------------

> I think you are going to have to start debugging what the compiler is
> doing.  In particular, look at the dumps for the passes after reload.
> Does the invalid address somehow survive reload, or does it somehow
> get introduce afterward?

I should have mentioned in my first email that the compiler is
actually failing during reload, it isn't able to compile the source
file I give it. I get an ICE:

mul.c:37:1: internal compiler error: in change_address_1, at emit-rtl.c:1996

The stack trace at this point looks like this:

-------------

(gdb) where
#0  fancy_abort (file=0xb2c8c8
"../../gcc-4.7.1-mytarget/gcc/emit-rtl.c", line=1996,
    function=0xb2ca20 "change_address_1") at
../../gcc-4.7.1-mytarget/gcc/diagnostic.c:898
#1  0x00000000005c4109 in change_address_1 (memref=0x2a95691a08,
mode=HImode, addr=0x2a956919f0,
    validate=1) at ../../gcc-4.7.1-mytarget/gcc/emit-rtl.c:1996
#2  0x00000000005c48a8 in replace_equiv_address (memref=0x2a95691a08,
addr=0x2a956919f0)
    at ../../gcc-4.7.1-mytarget/gcc/emit-rtl.c:2207
#3  0x00000000005c2e5a in operand_subword (op=0x2a956919a8, offset=1,
validate_address=1, mode=SImode)
    at ../../gcc-4.7.1-mytarget/gcc/emit-rtl.c:1401
#4  0x00000000005e7dc9 in emit_move_multi_word (mode=SImode,
x=0x2a9568c420, y=0x2a956919a8)
    at ../../gcc-4.7.1-mytarget/gcc/expr.c:3334
#5  0x00000000005e80c5 in emit_move_insn_1 (x=0x2a9568c420, y=0x2a95691960)
    at ../../gcc-4.7.1-mytarget/gcc/expr.c:3417
#6  0x00000000007255bd in gen_move_insn (x=0x2a9568c420, y=0x2a95691960)
    at ../../gcc-4.7.1-mytarget/gcc/optabs.c:4708
#7  0x000000000078cfe3 in gen_reload (out=0x2a9568c420,
in=0x2a95691960, opnum=1, type=RELOAD_FOR_INPUT)
    at ../../gcc-4.7.1-mytarget/gcc/reload1.c:8677
#8  0x000000000078aaa0 in emit_input_reload_insns (chain=0xed9330,
rl=0xe480a8, old=0x2a95679880, j=1)
    at ../../gcc-4.7.1-mytarget/gcc/reload1.c:7563
#9  0x000000000078b48c in do_input_reload (chain=0xed9330, rl=0xe480a8, j=1)
    at ../../gcc-4.7.1-mytarget/gcc/reload1.c:7850
#10 0x000000000078bb63 in emit_reload_insns (chain=0xed9330) at
../../gcc-4.7.1-mytarget/gcc/reload1.c:8042
#11 0x00000000007851f2 in reload_as_needed (live_known=1) at
../../gcc-4.7.1-mytarget/gcc/reload1.c:4655
#12 0x000000000077ddf9 in reload (first=0x2a9567f1c0, global=1)
    at ../../gcc-4.7.1-mytarget/gcc/reload1.c:1057
#13 0x00000000006bf9c2 in do_reload () at
../../gcc-4.7.1-mytarget/gcc/ira.c:3733
#14 0x00000000006bfb4f in rest_of_handle_reload () at
../../gcc-4.7.1-mytarget/gcc/ira.c:3824
#15 0x0000000000738777 in execute_one_pass (pass=0xde2c20) at
../../gcc-4.7.1-mytarget/gcc/passes.c:2084
#16 0x0000000000738abf in execute_pass_list (pass=0xde2c20) at
../../gcc-4.7.1-mytarget/gcc/passes.c:2139
#17 0x0000000000738adb in execute_pass_list (pass=0xde3260) at
../../gcc-4.7.1-mytarget/gcc/passes.c:2140
#18 0x0000000000824e2c in tree_rest_of_compilation (fndecl=0x2a95661200)
    at ../../gcc-4.7.1-mytarget/gcc/tree-optimize.c:422
#19 0x000000000056428e in cgraph_expand_function (node=0x2a9567b000)
    at ../../gcc-4.7.1-mytarget/gcc/cgraphunit.c:1837
#20 0x0000000000564464 in cgraph_expand_all_functions () at
../../gcc-4.7.1-mytarget/gcc/cgraphunit.c:1904
#21 0x0000000000564d8f in cgraph_optimize () at
../../gcc-4.7.1-mytarget/gcc/cgraphunit.c:2218
#22 0x0000000000562eb6 in cgraph_finalize_compilation_unit ()
    at ../../gcc-4.7.1-mytarget/gcc/cgraphunit.c:1344
#23 0x00000000004726a8 in c_write_global_declarations () at
../../gcc-4.7.1-mytarget/gcc/c-decl.c:10032
#24 0x00000000007c41eb in compile_file () at
../../gcc-4.7.1-mytarget/gcc/toplev.c:573
#25 0x00000000007c6166 in do_compile () at
../../gcc-4.7.1-mytarget/gcc/toplev.c:1938
#26 0x00000000007c62ac in toplev_main (argc=4, argv=0x7fbfffedc8)
    at ../../gcc-4.7.1-mytarget/gcc/toplev.c:2014
#27 0x00000000004f5d17 in main (argc=4, argv=0x7fbfffedc8) at
../../gcc-4.7.1-mytarget/gcc/main.c:36

-------------

Does this offer any more clues as to what I've done wrong? Surely
there must be a way to fix this without hacking into GCC's source
code!

Thanks again,
Tim

  reply	other threads:[~2012-08-01 14:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-01 11:57 Tim Rye
2012-08-01 13:08 ` Ian Lance Taylor
2012-08-01 14:54   ` Tim Rye [this message]
2012-08-01 15:02     ` Ian Lance Taylor
  -- strict thread matches above, loose matches on Subject: below --
2010-03-17  7:51 이환희
2010-03-17 15:18 ` Andrew Haley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP6CXZf=dGBN43Z=Jvu0O+JRoEjKj503nwSS2Lf8iVCTPJN5AA@mail.gmail.com' \
    --to=timjrye@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=iant@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).