On 2023-08-15 15:30, Paul Koning wrote:

On Aug 15, 2023, at 8:56 AM, MegaIng <trampch...@hotmail.de> wrote:


Am 2023-08-15 um 14:48 schrieb Paul Koning:
On Aug 15, 2023, at 8:06 AM, Richard Biener via Gcc <gcc@gcc.gnu.org> wrote:

On Tue, Aug 15, 2023 at 1:38 PM MegaIng via Gcc <gcc@gcc.gnu.org> wrote:
...
And a bit more concrete with something I am having a hard time
debugging. I am getting errors `invalid_void`, seemingly triggered by an
absent of `gen_return` when compiling with anything higher than -O0. How
do I correctly provide an implementation for that? Or disable it's
usage? Our epilogue is non-trivial, and it doesn't look like the other
backends use something like `(define_insn "return" ...)`.
Somebody else has to answer this.
Again using pdp11 as an example -- it doesn't define any of the *return patterns either.  
Instead it has a define_expand "epilogue" which calls a function to generate 
all the necessary elements, the last of which is a machine-specific pattern that will 
produce the final return instruction.

This is using the RTL flavor of prologue/epilogue.  At one point in the past 
that target directly emitted the assembly code for those, which isn't the 
recommended approach.  I tried the RTL flavor and found it to be a better 
answer, and it certainly works for all the optimization levels.
Yeah, I am also using define_expand with prologue and epilogue, but for some 
reason gcc still calls gen_return from cfgrtl.cc line 1705 (might be 
out-of-sync with master) inside force_nonfallthru_and_redirect, and I don't 
really understand how to avoid that call. Do I need to define some extra target 
hooks or undefine some that I have?
I can't think of anything, but I wrote that code a while ago.

Does your epilog RTL end with an jump type RTL that will produce the actual function 
return instruction?  See pdp11.cc line 446 -- that's the final instruction of the epilog. 
 I made it an "emit_jump_insn" because that seemed the right thing to do, but 
it may be it's necessary for that to be a jump type RTL.

Yes, I also tried switching to `emit_jump_insn(ret_rtx)` instead, which a few backends use, but this doesn't make a difference. It seems to be that the error is unrelated to the epilogue. It fails during the "branch reordiering" pass, using code the docs attributed to a different pass from what I can tell.

during RTL pass: bbro
../test2.c: In function ‘display’:
../test2.c:18:1: internal compiler error: in invalid_void, at ./insn-target-def.h:189
   18 | }
      | ^
0x77bf12 invalid_void
        ./insn-target-def.h:189
0x9d4a64 force_nonfallthru_and_redirect(edge_def*, basic_block_def*, rtx_def*)
        ../../gcc/cfgrtl.cc:1705
0x9d618c fixup_reorder_chain
        ../../gcc/cfgrtl.cc:4080
0x9d618c cfg_layout_finalize()
        ../../gcc/cfgrtl.cc:4575
0x14d8d50 execute
        ../../gcc/bb-reorder.cc:2682

I will try if I can find any difference in the settings between our setup and what pdp11 does.

MegaIng

Reply via email to