On Fri, Feb 24, 2017 at 6:51 PM, Martin Sebor <mse...@gmail.com> wrote:
> On 02/24/2017 03:10 AM, Richard Biener wrote:
>>
>> On Fri, Feb 24, 2017 at 1:35 AM, Martin Sebor <mse...@gmail.com> wrote:
>>>
>>> Bug 79691 - -Wformat-truncation suppressed by (and only by) -Og
>>> points out that the gimple-ssa-sprintf pass doesn't run when
>>> this optimization option is used.  That's because I forgot to
>>> add it to the set of optimization passes that run with that
>>> option.  The attached trivial patch tested on x86_64 corrects
>>> the oversight.
>>>
>>> Is this okay for 7.0?
>>
>>
>> Any reason for the placement before copy-prop?  I'd have done it
>> after pass_late_warn_uninitialized for example.
>
>
> I wanted to make sure that folded sprintf return values would be
> eligible for further copy propagation.  E.g., that a + b would
> be folded into a constant:
>
>   int foo (void)
>   {
>     int a = snprintf (0, 0, "%i", 123);
>     int b = snprintf (0, 0, "%i", 1234);
>     return a + b;
>   }
>
> But I could have easily missed some important use case where this
> placement will compromise the warning.  I don't have any tests
> for this one way or the other so I'm happy to go with your
> recommendation.  Let me know which you think is more appropriate
> (if you have a suggestion for a test case I'd be grateful).
Hmm, I see.  Note that I'd have expected this kind of constant folding
to happen in gimple-fold.c, but well.

>>
>> Also doesn't pass_sprintf_length rely on get_range_info ()?  With -Og
>> nothing populates those so you'll always get effectively VARYING ranges.
>
>
> It does when it's available but as Jakub noted, it works without
> it as well (at -O0).

Good.

Your original patch is ok.

Thanks,
Richard.

> Thanks
> Martin

Reply via email to