On Fri, 15 Nov 2019, Matthew Malcomson wrote:

> The documentation for __RTL tests (see "(gccint) RTL Tests" info node) has the
> following snippet.
> 
> ```
>  The parser expects the RTL body to be in the format emitted by this
> dumping function:
> 
>      DEBUG_FUNCTION void
>      print_rtx_function (FILE *outfile, function *fn, bool compact);
> 
>  when "compact" is true.  So you can capture RTL in the correct format
> from the debugger using:
> 
>      (gdb) print_rtx_function (stderr, cfun, true);
> 
>  and copy and paste the output into the body of the C function.
> ```
> 
> Since r264944 print_rtx_function prints column number information, which the
> __RTL function parsing does not handle.
> 
> This patch handles column number information optionally, so pre-existing __RTL
> functions still work, and the above documentation quote still holds.
> I should note that none of the source information is used, so the only
> observable change is that the frontend does not complain when reading a column
> number.
> 
> Note: If people would prefer to require column information I could make a
> slightly neater code and update existing tests.
> I guess this would be OK since the intended use for __RTL functions is in 
> these
> testcases so there is no worry about other existing code.
> 
> bootstrapped and regtested on aarch64
> bootstrapped and regtested on x86_64
> 
> Ok for trunk?

OK.

Richard.

> Cheers,
> Matthew
> 
> 
> ###############     Attachment also inlined for ease of reply    
> ###############
> 
> 
> diff --git a/gcc/read-rtl-function.c b/gcc/read-rtl-function.c
> index 
> 53f7a94c1882018fede19fb5c760e71de65b6b61..210fd112f100d4e3ff5c8ad384746ae4b7844513
>  100644
> --- a/gcc/read-rtl-function.c
> +++ b/gcc/read-rtl-function.c
> @@ -112,7 +112,7 @@ class function_reader : public rtx_reader
>                                       int operand_idx, int bb_idx);
>  
>    void add_fixup_source_location (file_location loc, rtx_insn *insn,
> -                               const char *filename, int lineno);
> +                               const char *filename, int lineno, int colno);
>  
>    void add_fixup_expr (file_location loc, rtx x,
>                      const char *desc);
> @@ -1368,7 +1368,7 @@ function_reader::add_fixup_note_insn_basic_block 
> (file_location loc, rtx insn,
>  
>  void
>  function_reader::add_fixup_source_location (file_location, rtx_insn *,
> -                                         const char *, int)
> +                                         const char *, int, int)
>  {
>  }
>  
> @@ -1554,7 +1554,20 @@ function_reader::maybe_read_location (rtx_insn *insn)
>        require_char (':');
>        struct md_name line_num;
>        read_name (&line_num);
> -      add_fixup_source_location (loc, insn, filename, atoi 
> (line_num.string));
> +
> +      int column = 0;
> +      int ch = read_char ();
> +      if (ch == ':')
> +     {
> +       struct md_name column_num;
> +       read_name (&column_num);
> +       column = atoi (column_num.string);
> +     }
> +      else
> +     unread_char (ch);
> +      add_fixup_source_location (loc, insn, filename,
> +                              atoi (line_num.string),
> +                              column);
>      }
>    else
>      unread_char (ch);
> diff --git a/gcc/testsuite/gcc.dg/rtl/aarch64/rtl-handle-column-numbers.c 
> b/gcc/testsuite/gcc.dg/rtl/aarch64/rtl-handle-column-numbers.c
> new file mode 100644
> index 
> 0000000000000000000000000000000000000000..576f9b9a83d1eaad95c816409d274ddf6ad9fb92
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/rtl/aarch64/rtl-handle-column-numbers.c
> @@ -0,0 +1,20 @@
> +int __RTL (startwith ("cprop_hardreg"))
> +foo ()
> +{
> +(function "f"
> +  (insn-chain
> +    (block 2
> +      (edge-from entry (flags "FALLTHRU"))
> +      (cnote 6 [bb 2] NOTE_INSN_BASIC_BLOCK)
> +      (cinsn 100 (set (reg:DI x0)
> +               (plus:DI
> +                (reg:DI x1)
> +                (const_int 16777213)))
> +       "/home/user/somefile.c":10:3)
> +      ;; Extra insn, to avoid all of the above from being deleted by DCE
> +      (cinsn 10 (use (reg/i:DI x0)))
> +      (edge-to exit (flags "FALLTHRU"))
> +    ) ;; block 2
> +  ) ;; insn-chain
> +) ;; function
> +}
> 
> 

-- 
Richard Biener <rguent...@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

Reply via email to