[patch] Do not crash on empty epilogues

Bernd Schmidt bernds@codesourcery.com
Tue Jan 4 01:35:00 GMT 2011


On 01/04/2011 12:22 AM, Ulrich Weigand wrote:
> GCC now crashes on the SPU when compiling functions with the "naked"
> attribute.  The problem is this code in thread_prologue_and_epilogue_insns:
> 
>         seq = gen_epilogue ();
>         emit_jump_insn (seq);
> 
> Naked functions have no epilogue, and thus gen_epilogue returns NULL.
> However, emit_jump_insn crashes on a NULL input (as opposed to emit_insn
> b.t.w., which is why this problem doesn't show up for the prologue).
> 
> This used to be OK since the SPU gen_epilogue would always generate
> at least a NOTE.  But this was removed by Andrew Pinksi to fix PR 43156.
> 
> A couple of other targets that support naked functions work around this
> problem by generating some dummy insn (e.g. an UNSPEC_VOLATILE that
> expands to no assembler code).  But this seems a bit silly to me; GCC
> common code simply shouldn't crash on empty epilogues.
> 
> The following patch fixes the crash for me.
> 
> Tested on spu-elf.
> 
> OK for mainline?

Ok. It would be nice to also avoid emitting the NOTE_INSN_EPILOGUE_BEG;
such a change is ok too if you want to make it. The same thing could
also be done for sibcall epilogues.

Another way to fix it in the backend is to ensure HAVE_epilogue is false
if the epilogue would be empty.


Bernd



More information about the Gcc-patches mailing list