PR target/21299 (reload accepting invalid asm)

Ian Lance Taylor iant@google.com
Wed Aug 9 15:27:00 GMT 2006


Jan Hubicka <jh@suse.cz> writes:

> the testcase in PR specify destination for DImode register as "ab" instead of
> "A".

This is user error.  Obviously we shouldn't ICE, but we don't have to
handle it reasonably. 

> This hits difference in between reload and recog understanding of class
> specifier - while recog is testing each letter separately and thus DImode
> register won't fit to 'a' nor 'b' class, reload is always doing subunion of
> alternatives before verifying, so it actually converts "ab" into "A" and is
> satisfied.

I believe that both reload and recog are acting reasonably.  If you
specify more than register class in a constraint, then the register
must fit one of those constraints.  And, because the backend writer is
supposed to define a register class for the union of all register
classes which can appear together, then it is OK to use the short-cut
of simply requiring the register to belong to that union class.

In this case the user specified two register classes, neither of which
can hold a DImode value.  That is an error.  That error should never
occur in an MD file.  The only issue here is how to best handle this
error without ICEing.

I think the simplest way is likely to be in reload in the final pass
over the insns.  Do something like this:

  /* Clean up invalid ASMs so that they don't confuse later passes.
     See PR 21299.  */
  if (asm_noperands (PATTERN (insn)) >= 0)
    {
      extract_insn (insn);
      if (!constrain_operands (1))
        {
          error_for_asm (insn, "%<asm%> operand has impossible constraints");
          delete_insn (insn);
          continue;
        }
    }

Ian



More information about the Gcc-patches mailing list