[PR middle-end/85598] make -Wprintf* pass use loop info for PHI's
Jakub Jelinek
jakub@redhat.com
Thu Jan 31 14:45:00 GMT 2019
On Thu, Jan 31, 2019 at 09:30:13AM -0500, Aldy Hernandez wrote:
> > > (LOOPS_HAVE_PREHEADERS). This avoids unnecessary changes to the CFG.
> > > But really, I'm just guessing here. LOOPS_NORMAL would also work,
> > > albeit creating forwarder blocks.
> > >
> > > Tested on x86-64 Linux.
> > >
> > > What do you think?
> >
> > As far as I understand fold_return_value is true/false independent
> > of -W* flags (but dependent on -fprintf-return-value or so). This means
> > that your patch avoids the risk of CFG changes dependent on
> > -W* flags. This means you could safely use LOOPS_NORMAL
>
> But isn't my code inside of ::execute, which is still gated by
> fold_return_value AND all the -W* flags:?
>
> bool
> pass_sprintf_length::gate (function *)
> {
> return ((warn_format_overflow > 0
> || warn_format_trunc > 0
> || flag_printf_return_value)
> && (optimize > 0) == fold_return_value);
> }
>
> Thus, I think we need to move the loop initialization somewhere else ??.
Then perhaps turn the gate into just return (optimize > 0) == fold_return_value;
and in execute do what you're adding and guard the rest with the above
condition? As -fprintf-return-value is on by default for C-family, it shouldn't
change much.
+ adjust comment on the gate of course.
Jakub
More information about the Gcc-patches
mailing list