On Mon, Mar 07, 2022 at 07:19:09PM -0600, Segher Boessenkool wrote:
> On Mon, Mar 07, 2022 at 07:03:17PM -0500, Marek Polacek via Gcc-patches wrote:
> > In r270550, Jakub fixed classify_insn to handle asm goto: if the asm can
> > jump to a label, the insn should be a JUMP_INSN.
> > 
> > However, as the following testcase shows, non-null ASM_OPERANDS_LABEL_VEC
> > doesn't guarantee that the rtx has any actual labels it can branch to.
> 
> But it should.

Ok, that would make sense.  However...
 
> > Here, the rtvec has 0 elements because of the __thread variable: we perform
> > ix86_rewrite_tls_address which calls copy_isns and that allocates the rtvec:
> > 
> >     XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
> 
> So fix *that* instead?  Everywhere else does not use length zero RTL
> vectors.  copy_rtx makes sure to do the right thing here, for example.

...I don't see that.  In fact copy_rtx does the same thing as
copy_insn:

       case 'V':
         if (XVEC (orig, i) != NULL)
           {
             XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));

which will copy a zero-length vector too, right?  But even if it didn't
we'd still ICE on the original rtx as I found out.  The zero-length
rtvec is originally created in expand_asm_stmt:

  rtvec labelvec = rtvec_alloc (nlabels);

where nlabels is 0 but using NULL_RTVEC instead just means crashes everywhere.
  
So I'm afraid I don't have a better fix (except that I should have used
ASM_OPERANDS_LABEL_LENGTH).

> We do not have notation to create zero-length vectors in RTL source
> code either, btw.:
>     case 'V':
>       /* 'V' is an optional vector: if a closeparen follows,
>          just store NULL for this element.  */
> (optional vectors are at the end of an RTX), and if you write [] you
> will hit
>           fatal_with_file_and_line ("vector must have at least one element");

Marek

Reply via email to