[Bug target/85666] gcc-8.0.1 fails to build mmix target: gcc/libgcc/libgcc2.h:203:20: internal compiler error: in leaf_function_p, at final.c:4488

slyfox at inbox dot ru gcc-bugzilla@gcc.gnu.org
Sat May 5 22:28:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85666

--- Comment #1 from Sergei Trofimovich <slyfox at inbox dot ru> ---
looks like leaf_function_p() predicate fails right at start of cfgexpand when
it tries to pick stack frame size. leaf_function_p() has a few hints that it's
knowingly trying to do it before expand finishes:

Crash happens at:
    https://github.com/gcc-mirror/gcc/blob/master/gcc/cfgexpand.c#L6630

 static rtx_insn *
 expand_used_vars (void)
 {
  tree var, outer_block = DECL_INITIAL (current_function_decl);
  auto_vec<tree> maybe_local_decls;
  rtx_insn *var_end_seq = NULL;
  unsigned i;
  unsigned len;
  bool gen_stack_protect_signal = false;

  /* Compute the phase of the stack frame for this function.  */
  {
    int align = PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT;
    int off = targetm.starting_frame_offset () % align; /// <- here
    frame_phase = off ? align - off : 0;
  }
 ...

targetm.starting_frame_offset is 

 static HOST_WIDE_INT
 mmix_starting_frame_offset (void)
 {
  return
    (-8
     + (MMIX_CFUN_HAS_LANDING_PAD
        -16 : (MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS ? -8 : 0))); // <- here
 }

MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS triggers assertion:
  https://github.com/gcc-mirror/gcc/blob/master/gcc/config/mmix/mmix.c#L61

 #define MMIX_CFUN_NEEDS_SAVED_EH_RETURN_ADDRESS                        \
  (flag_exceptions                                              \
   && ((reload_completed && df_regs_ever_live_p (MMIX_rJ_REGNUM))       \
 || !leaf_function_p ())) /// <- here


More information about the Gcc-bugs mailing list