[patch] Do not crash on empty epilogues
Ulrich Weigand
uweigand@de.ibm.com
Mon Jan 3 23:33:00 GMT 2011
Hello,
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?
Bye,
Ulrich
ChangeLog:
* function.c (thread_prologue_and_epilogue_insns): Do not crash
on empty epilogue sequences.
Index: gcc/function.c
===================================================================
*** gcc/function.c (revision 168294)
--- gcc/function.c (working copy)
*************** thread_prologue_and_epilogue_insns (void
*** 5461,5467 ****
start_sequence ();
epilogue_end = emit_note (NOTE_INSN_EPILOGUE_BEG);
seq = gen_epilogue ();
! emit_jump_insn (seq);
/* Retain a map of the epilogue insns. */
record_insns (seq, NULL, &epilogue_insn_hash);
--- 5461,5468 ----
start_sequence ();
epilogue_end = emit_note (NOTE_INSN_EPILOGUE_BEG);
seq = gen_epilogue ();
! if (seq)
! emit_jump_insn (seq);
/* Retain a map of the epilogue insns. */
record_insns (seq, NULL, &epilogue_insn_hash);
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
More information about the Gcc-patches
mailing list