[Bug target/18032] [4.0.0] SH: wrong code for EH

amylaar at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Mon Oct 18 15:49:00 GMT 2004


------- Additional Comments From amylaar at gcc dot gnu dot org  2004-10-18 15:49 -------
We don't emit call frame information for the epilogue.  If we did, than any
basic blocks that happen to come after the epilogue due to block reordering
would end up with incorrect cfi information, since we don't have any machinery
for writing compensating cfi when we skip over an epilogue.

Thus, the only way we have to make this work with the current infrastructure
is to avoid scheduling the epilogue with previous basic blocks when exception
handling is enabled (this also affects debugging information, but I'd say we
shouldn't pessimize -O2 code to get better debugging information).

There is already code in sh.c:sh_expand_epilogue to emit a blockage instruction
before the stack adjustments.  However, if a frame pointer is needed, the
initial adjustment of the frame pointer isn't adjusted, since this doesn't
matter for interrupts:
 
  if (frame_pointer_needed)
    {
      output_stack_adjust (frame_size, frame_pointer_rtx, e, &live_regs_mask);

      /* We must avoid moving the stack pointer adjustment past code
         which reads from the local frame, else an interrupt could
         occur after the SP adjustment and clobber data in the local
         frame.  */
      emit_insn (gen_blockage ());
      emit_insn (GEN_MOV (stack_pointer_rtx, frame_pointer_rtx));
    }

So, if flag_exceptions is set, we should emit this blockage before the frame
pointer adjustment.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amylaar at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18032



More information about the Gcc-bugs mailing list