Set global epilogue_completed when skipping pro_and_epilogue pass When compiling RTL functions marked to start at a pass after the reload pass, `skip_pass` is used to mark the reload pass as having completed since many patterns use the `reload_completed` variable to determine whether to run or not.
Here we do the same for the `epilogue_completed` variable and the pro_and_epilogue pass. Also include a testcase that relies on the availability of a define_split in the aarch64 backend that is conditioned on this `epilogue_completed` variable. regtest done on native aarch64 regtest done on native x64_86 gcc/ChangeLog: 2019-11-15 Matthew Malcomson <matthew.malcom...@arm.com> * passes.c (skip_pass): Set epilogue_completed if skipping the pro_and_epilogue pass. gcc/testsuite/ChangeLog: 2019-11-15 Matthew Malcomson <matthew.malcom...@arm.com> * gcc.dg/rtl/aarch64/test-epilogue-set.c: New test. ############### Attachment also inlined for ease of reply ############### diff --git a/gcc/passes.c b/gcc/passes.c index f838b586bff2bef6b075e7f7d59837bb3da00683..1851759349ced0f043cb3f5cb5e685ae4e05a95e 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -2388,6 +2388,11 @@ skip_pass (opt_pass *pass) if (strcmp (pass->name, "reload") == 0) reload_completed = 1; + /* Similar for pass "pro_and_epilogue" and the "epilogue_completed" global + variable. */ + if (strcmp (pass->name, "pro_and_epilogue") == 0) + epilogue_completed = 1; + /* The INSN_ADDRESSES vec is normally set up by shorten_branches; set it up for the benefit of passes that run after this. */ diff --git a/gcc/testsuite/gcc.dg/rtl/aarch64/test-epilogue-set.c b/gcc/testsuite/gcc.dg/rtl/aarch64/test-epilogue-set.c new file mode 100644 index 0000000000000000000000000000000000000000..e0b893c066771493c0b71bf70efa9e454f5c8131 --- /dev/null +++ b/gcc/testsuite/gcc.dg/rtl/aarch64/test-epilogue-set.c @@ -0,0 +1,25 @@ +/* { dg-do compile { target aarch64-*-* } } */ + +/* + Should compile rather than ICE. + Compilation requires setting the "epilogue_completed" variable. + */ +int __RTL (startwith ("cprop_hardreg")) +f () +{ +(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)))) + ;; 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 +}
diff --git a/gcc/passes.c b/gcc/passes.c index f838b586bff2bef6b075e7f7d59837bb3da00683..1851759349ced0f043cb3f5cb5e685ae4e05a95e 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -2388,6 +2388,11 @@ skip_pass (opt_pass *pass) if (strcmp (pass->name, "reload") == 0) reload_completed = 1; + /* Similar for pass "pro_and_epilogue" and the "epilogue_completed" global + variable. */ + if (strcmp (pass->name, "pro_and_epilogue") == 0) + epilogue_completed = 1; + /* The INSN_ADDRESSES vec is normally set up by shorten_branches; set it up for the benefit of passes that run after this. */ diff --git a/gcc/testsuite/gcc.dg/rtl/aarch64/test-epilogue-set.c b/gcc/testsuite/gcc.dg/rtl/aarch64/test-epilogue-set.c new file mode 100644 index 0000000000000000000000000000000000000000..e0b893c066771493c0b71bf70efa9e454f5c8131 --- /dev/null +++ b/gcc/testsuite/gcc.dg/rtl/aarch64/test-epilogue-set.c @@ -0,0 +1,25 @@ +/* { dg-do compile { target aarch64-*-* } } */ + +/* + Should compile rather than ICE. + Compilation requires setting the "epilogue_completed" variable. + */ +int __RTL (startwith ("cprop_hardreg")) +f () +{ +(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)))) + ;; 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 +}