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]

Re: [PATCH] squash spurious warnings in dominance.c


On Mon, Apr 24, 2017 at 11:07 PM, Martin Sebor <msebor@gmail.com> wrote:
> On 04/24/2017 01:32 AM, Richard Biener wrote:
>>
>> On Sat, Apr 22, 2017 at 2:51 AM, Martin Sebor <msebor@gmail.com> wrote:
>>>
>>> Bug 80486 - spurious -Walloc-size-larger-than and
>>> -Wstringop-overflow in dominance.c during profiledbootstrap
>>> points out a number of warnings that show up in dominance.c
>>> during a profiledbootstrap.  I'm pretty sure the warnings
>>> are due to the size check the C++ new expression introduces
>>> to avoid unsigned overflow before calling operator new, and
>>> by some optimization like jump threading introducing a branch
>>> with the call to the allocation function and memset with
>>> the excessive constant size.
>>>
>>> Two ways to avoid it come to mind: 1) use the libiberty
>>> XCNEWVEC and XNEWVEC macros instead of C++ new expressions,
>>> and 2) constraining the size variable to a valid range.
>>>
>>> Either of these approaches should result in better code than
>>> the new expression because they both eliminate the test for
>>> the overflow.  Attached is a patch that implements (1). I
>>> chose it mainly because it seems in line with GCC's memory
>>> management policy and with avoiding exceptions.
>>>
>>> An alternate patch should be straightforward.  Either add
>>> an assert like the one below or change the type of
>>> m_n_basic_blocks from size_t to unsigned.  This approach,
>>> though less intrusive, will likely bring the warning back
>>> in ILP32 builds; I'm not sure if it matters.
>>
>>
>> Please change m_n_basic_blocks (and local copies) from size_t
>> to unsigned int.  This is an odd inconsistency that's worth fixing
>> in any case.
>
>
> Attached is this version of the patch.  It also eliminates
> the warnings and passes profiledbootstrap/regression test
> on x86_64.

Ok.

Thanks,
Richard.

> Martin
>


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