This is the mail archive of the
mailing list for the GCC project.
Re: warn for dead function calls [4/4] stor-layout.c fallout
- From: Richard Biener <rguenther at suse dot de>
- To: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- Cc: gcc Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 26 Jul 2016 13:37:52 +0200 (CEST)
- Subject: Re: warn for dead function calls [4/4] stor-layout.c fallout
- Authentication-results: sourceware.org; auth=none
- References: <CAAgBjMkj3hHKomRkhHR1hiZT0v1LBebBJq1wABZuu0-yfi3DMA@mail.gmail.com>
On Tue, 26 Jul 2016, Prathamesh Kulkarni wrote:
> 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))
> 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)
> 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))
I'm surprised it's only one case that you hit ;) Be prepared for
other targets to be broken similarly.
This hints at the general issue of issueing warnings after optimization,
they can easily become false positives.