Question about dump_printf/dump_printf_loc

Jeff Law law@redhat.com
Mon May 8 22:12:00 GMT 2017


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



More information about the Gcc mailing list