On 11/14/19 11:22 AM, Matthew Malcomson wrote:
> Hi there,
>
> When compiling an __RTL function that has an unspecified "startwith"
> pass we currently don't run the cleanup pass, this means that we ICE on
> the next function (if it's a basic function).
> I asked about this on the GCC mailing list a while ago and Richard mentioned
> it might be a good idea to clear bad state so it doesn't leak to other
> functions.
> https://gcc.gnu.org/ml/gcc/2019-02/msg00106.html
>
> This change ensures that the clean_state pass is run even if the
> startwith pass is unspecified.
>
> We also ensure the name of the startwith pass is always freed correctly.
>
> As an example, before this change the following code would ICE when compiling
> the function `foo_a`.
>
> When compiled with
> ./aarch64-none-linux-gnu-gcc -O0 -S unspecified-pass-error.c -o test.s
>
> ```
> int __RTL () badfoo ()
> {
> (function "badfoo"
> (insn-chain
> (block 2
> (edge-from entry (flags "FALLTHRU"))
> (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK)
> (cinsn 101 (set (reg:DI x19) (reg:DI x0)))
> (cinsn 10 (use (reg/i:SI x19)))
> (edge-to exit (flags "FALLTHRU"))
> ) ;; block 2
> ) ;; insn-chain
> ) ;; function "foo2"
> }
>
> int
> foo_a ()
> {
> return 200;
> }
> ```
>
> Now it silently ignores the __RTL function and successfully compiles foo_a.
>
> regtest done on aarch64
> regtest done on x86_64
>
> OK for trunk?
>
> gcc/ChangeLog:
>
> 2019-11-14 Matthew Malcomson <matthew.malcom...@arm.com>
>
> * run-rtl-passes.c (run_rtl_passes): Accept and handle empty
> "initial_pass_name" argument -- by running "*clean_state" pass.
> Also free the "initial_pass_name" when done.
>
> gcc/c/ChangeLog:
>
> 2019-11-14 Matthew Malcomson <matthew.malcom...@arm.com>
>
> * c-parser.c (c_parser_parse_rtl_body): Always call
> run_rtl_passes, even if startwith pass is not provided.
>
> gcc/testsuite/ChangeLog:
>
> 2019-11-14 Matthew Malcomson <matthew.malcom...@arm.com>
>
> * gcc.dg/rtl/aarch64/unspecified-pass-error.c: New test.
OK
jeff