This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

warn for dead function calls [4/4] stor-layout.c fallout


The following is an interesting case which broke stor-layout.c.
The patch warned for the following call to be dead from
bit_field_mode_iterator::next_mode() to get_mode_alignment ():

      /* Stop if the mode requires too much alignment.  */
      if (GET_MODE_ALIGNMENT (m_mode) > m_align
          && SLOW_UNALIGNED_ACCESS (m_mode, m_align))
        break;

GET_MODE_ALIGNMENT (MODE) is just #defined as get_mode_alignment (MODE)
in machmode.h

SLOW_UNALIGNED_ACCESS (MODE, ALIGN) is #defined to STRICT_ALIGNMENT
in defaults.h, and i386.h sets STRICT_ALIGNMENT to 0.
So essentially it comes down to:

if (get_mode_alignment (m_mode) > m_align && 0)
  break;

which clearly makes get_mode_alignment(m_mode) a dead call
since it's a pure function.
However if a target overrides SLOW_UNALIGNED_ACCESS(mode, align)
and sets it to some runtime value, then the call won't be dead for that target.

Should we split the above  in two different if conditions ?
if (GET_MODE_ALIGNMENT (m_mode) > m_align)
  if (SLOW_UNALIGNED_ACCESS (m_mode, m_align))
    break;

Thanks,
Prathamesh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]