public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Which compiler pass prints a warning?
@ 2016-09-17 17:09 Florian Weimer
  2016-09-18 18:23 ` Martin Sebor
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Weimer @ 2016-09-17 17:09 UTC (permalink / raw)
  To: gcc-help

For warnings issued by the optimizers, is there a way to get the name
of the pass which runs when the warning is generated?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Which compiler pass prints a warning?
  2016-09-17 17:09 Which compiler pass prints a warning? Florian Weimer
@ 2016-09-18 18:23 ` Martin Sebor
  2016-09-19 14:47   ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Sebor @ 2016-09-18 18:23 UTC (permalink / raw)
  To: Florian Weimer, gcc-help

On 09/17/2016 11:08 AM, Florian Weimer wrote:
> For warnings issued by the optimizers, is there a way to get the name
> of the pass which runs when the warning is generated?

I don't know of an easy or reliable way other than to grep the source
code for the text of warning (or its substrings when it's split across
multiple lines).  Short of that, I think it might be possible to come
close by looking at where in the output of -fdump-tree-all=/dev/stderr
the diagnostic appears and determining the pass from the context.
E.g., by

   gcc -O2 -S -Wall -fdump-tree-all=/dev/stdout z.c 2>&1 | less

and then searching the output for the warning and figuring out from
the contents of the dump around it what pass might have issued it.
Unfortunately, the dumps don't contain the name of their pass (I've
wished they did for other reasons) so this exercise isn't completely
straightforward either.

Martin

PS I think it would be useful to be able to more easily pinpoint
the source line responsible for emitting a diagnostic.  Others will
have a better idea of how feasible it might be to do but it seems
that having calls to error_at, warning_at, and others pass the
__FILE__ and __LINE__ of their caller to the diagnostic machinery
should make it possible to include this information in the text of
each diagnostic in response to some new option.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Which compiler pass prints a warning?
  2016-09-18 18:23 ` Martin Sebor
@ 2016-09-19 14:47   ` Jeff Law
  2016-09-19 16:39     ` Florian Weimer
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2016-09-19 14:47 UTC (permalink / raw)
  To: Martin Sebor, Florian Weimer, gcc-help

On 09/18/2016 12:23 PM, Martin Sebor wrote:
> On 09/17/2016 11:08 AM, Florian Weimer wrote:
>> For warnings issued by the optimizers, is there a way to get the name
>> of the pass which runs when the warning is generated?
>
> I don't know of an easy or reliable way other than to grep the source
> code for the text of warning (or its substrings when it's split across
> multiple lines).
Correct.  There's currently no way to know if a warning comes from the 
FE or any particular pass in the pipeline.  I believe everyone greps for 
the warning in the sources to figure that out.



Short of that, I think it might be possible to come
> close by looking at where in the output of -fdump-tree-all=/dev/stderr
> the diagnostic appears and determining the pass from the context.
> E.g., by
>
>   gcc -O2 -S -Wall -fdump-tree-all=/dev/stdout z.c 2>&1 | less
>
> and then searching the output for the warning and figuring out from
> the contents of the dump around it what pass might have issued it.
> Unfortunately, the dumps don't contain the name of their pass (I've
> wished they did for other reasons) so this exercise isn't completely
> straightforward either.
It'd probably work, but it isn't terribly user friendly :-)

> PS I think it would be useful to be able to more easily pinpoint
> the source line responsible for emitting a diagnostic.  Others will
> have a better idea of how feasible it might be to do but it seems
> that having calls to error_at, warning_at, and others pass the
> __FILE__ and __LINE__ of their caller to the diagnostic machinery
> should make it possible to include this information in the text of
> each diagnostic in response to some new option.
Seems like it may be worth investigating.  There are certainly times 
when knowing what pass spit out an error/warning would be helpful.

jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Which compiler pass prints a warning?
  2016-09-19 14:47   ` Jeff Law
@ 2016-09-19 16:39     ` Florian Weimer
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Weimer @ 2016-09-19 16:39 UTC (permalink / raw)
  To: Jeff Law; +Cc: Martin Sebor, gcc-help

* Jeff Law:

> On 09/18/2016 12:23 PM, Martin Sebor wrote:
>> On 09/17/2016 11:08 AM, Florian Weimer wrote:
>>> For warnings issued by the optimizers, is there a way to get the name
>>> of the pass which runs when the warning is generated?
>>
>> I don't know of an easy or reliable way other than to grep the source
>> code for the text of warning (or its substrings when it's split across
>> multiple lines).

> Correct.  There's currently no way to know if a warning comes from the
> FE or any particular pass in the pipeline.  I believe everyone greps
> for the warning in the sources to figure that out.

This doesn't really work for overflow warnings from fold, though.
(If they still exist, I haven't had to investigate one of those
with current GCC versions.)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-19 16:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-17 17:09 Which compiler pass prints a warning? Florian Weimer
2016-09-18 18:23 ` Martin Sebor
2016-09-19 14:47   ` Jeff Law
2016-09-19 16:39     ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).