This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
warn for dead function calls [4/4] stor-layout.c fallout
- From: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- To: Richard Biener <rguenther at suse dot de>, gcc Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 26 Jul 2016 05:06:08 +0530
- Subject: warn for dead function calls [4/4] stor-layout.c fallout
- Authentication-results: sourceware.org; auth=none
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