public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Question about dump_printf/dump_printf_loc
@ 2017-05-05 22:37 Steve Ellcey
  2017-05-08  7:09 ` Richard Biener via gcc
  2017-05-08 22:12 ` Jeff Law
  0 siblings, 2 replies; 3+ messages in thread
From: Steve Ellcey @ 2017-05-05 22:37 UTC (permalink / raw)
  To: gcc

I have a simple question about dump_printf and dump_printf_loc.  I notice
that most (all?) of the uses of these function are of the form:

	if (dump_enabled_p ())
		dump_printf_loc (MSG_*, ......);

Since dump_enabled_p() is just checking to see if dump_file or alt_dump_file
is set and since dump_printf_loc has checks for these as well, is there
any reason why we shouldn't or couldn't just use:

	dump_printf_loc (MSG_*, ......);

with out the call to dump_enabled_p and have the dump function do nothing
when there is no dump file set?  I suppose the first version would have
some performance advantage since dump_enabled_p is an inlined function,
but is that enough of a reason to do it?  The second version seems like
it would look cleaner in the code where we are making these calls.

Steve Ellcey
sellcey@cavium.com

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

* Re: Question about dump_printf/dump_printf_loc
  2017-05-05 22:37 Question about dump_printf/dump_printf_loc Steve Ellcey
@ 2017-05-08  7:09 ` Richard Biener via gcc
  2017-05-08 22:12 ` Jeff Law
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener via gcc @ 2017-05-08  7:09 UTC (permalink / raw)
  To: sellcey; +Cc: GCC Development

On Sat, May 6, 2017 at 12:37 AM, Steve Ellcey <sellcey@cavium.com> wrote:
> I have a simple question about dump_printf and dump_printf_loc.  I notice
> that most (all?) of the uses of these function are of the form:
>
>         if (dump_enabled_p ())
>                 dump_printf_loc (MSG_*, ......);
>
> Since dump_enabled_p() is just checking to see if dump_file or alt_dump_file
> is set and since dump_printf_loc has checks for these as well, is there
> any reason why we shouldn't or couldn't just use:
>
>         dump_printf_loc (MSG_*, ......);
>
> with out the call to dump_enabled_p and have the dump function do nothing
> when there is no dump file set?  I suppose the first version would have
> some performance advantage since dump_enabled_p is an inlined function,
> but is that enough of a reason to do it?  The second version seems like
> it would look cleaner in the code where we are making these calls.

The purpose of dump_enabled_p () is to save compile-time for the common case,
esp. when guarding multiple dump_* calls.  But also for the single-called case.
You could try improve things by having inline wrappers for all dump_* cases that
inline a dump_enabled_p () call but that would be somewhat gross.

Richard.

> Steve Ellcey
> sellcey@cavium.com

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

* Re: Question about dump_printf/dump_printf_loc
  2017-05-05 22:37 Question about dump_printf/dump_printf_loc Steve Ellcey
  2017-05-08  7:09 ` Richard Biener via gcc
@ 2017-05-08 22:12 ` Jeff Law
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2017-05-08 22:12 UTC (permalink / raw)
  To: sellcey, gcc

On 05/05/2017 04:37 PM, Steve Ellcey wrote:
> I have a simple question about dump_printf and dump_printf_loc.  I notice
> that most (all?) of the uses of these function are of the form:
> 
> 	if (dump_enabled_p ())
> 		dump_printf_loc (MSG_*, ......);
> 
> Since dump_enabled_p() is just checking to see if dump_file or alt_dump_file
> is set and since dump_printf_loc has checks for these as well, is there
> any reason why we shouldn't or couldn't just use:
> 
> 	dump_printf_loc (MSG_*, ......);
> 
> with out the call to dump_enabled_p and have the dump function do nothing
> when there is no dump file set?  I suppose the first version would have
> some performance advantage since dump_enabled_p is an inlined function,
> but is that enough of a reason to do it?  The second version seems like
> it would look cleaner in the code where we are making these calls.
> 
I doubt the performance difference is measurable.  More likely than not 
it's just habit.

I tend to perfer the second as it makes the code easier (IMHO) to read.

jeff

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

end of thread, other threads:[~2017-05-08 22:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 22:37 Question about dump_printf/dump_printf_loc Steve Ellcey
2017-05-08  7:09 ` Richard Biener via gcc
2017-05-08 22:12 ` Jeff Law

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).