On Sat, Jan 11, 2025 at 01:52:59AM -0800, Andrew Pinski wrote:
> The problem is for inline-asm goto, the outer rtl insn type
> is a jump_insn and get_attr_length does not handle ASM specially
> unlike if the outer rtl insn type was just insn.
> 
> This fixes the issue by adding support for both CALL_INSN and JUMP_INSN
> with asm.
> 
> OK? Bootstrapped and tested on x86_64-linux-gnu.
> 
>       PR middle-end/118411
> 
> gcc/ChangeLog:
> 
>       * final.cc (get_attr_length_1): Handle asm for CALL_INSN
>       and JUMP_INSNs.
> 
> Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>
> ---
>  gcc/final.cc | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/final.cc b/gcc/final.cc
> index 19c5d390c78..12c6eb0ac09 100644
> --- a/gcc/final.cc
> +++ b/gcc/final.cc
> @@ -363,7 +363,11 @@ get_attr_length_1 (rtx_insn *insn, int (*fallback_fn) 
> (rtx_insn *))
>  
>        case CALL_INSN:
>        case JUMP_INSN:
> -     length = fallback_fn (insn);
> +     body = PATTERN (insn);
> +     if (GET_CODE (body) == ASM_INPUT || asm_noperands (body) >= 0)
> +       length = asm_insn_count (body) * fallback_fn (insn);
> +     else
> +       length = fallback_fn (insn);
>       break;

A CALL_INSN can't be ever an inline asm, and ASM_INPUT (i.e. asm
("something");) can't be even JUMP_INSN.
So, shouldn't this be instead
      case JUMP_INSN:
        if (asm_noperands (body) >= 0)
          {
            length = asm_insn_count (body) * fallback_fn (insn);
            break;
          }
        /* FALLTHRU */
      case CALL_INSN:
        length = fallback_fn (insn);
        break;
?

        Jakub

Reply via email to