diff mbox series

[arm] Add -mverbose-cost-dump and de-verbosify cost dumps

Message ID 5A329E8E.6080101@foss.arm.com
State New
Headers show
Series [arm] Add -mverbose-cost-dump and de-verbosify cost dumps | expand

Commit Message

Kyrill Tkachov Dec. 14, 2017, 3:53 p.m. UTC
Hi all,

This patch adds an -mverbose-cost-dump option, similar to the one in 
aarch64.
It makes the RTX cost dump print the RTX we're costing in the backend, 
as well as its cost.
This can be distracting in other cost-related RTL dumps like combine's.

So now we don't dump the backend information by default, but provide the 
power-user option -mverbose-cost-dump
to enable the old verbose dumping.

This option is for GCC developers debugging the compiler only, so no 
documentation are added.
It's also trivially simple in functionality so no test is added either.

Bootstrapped and tested on arm-none-linux-gnueabihf.

Committed to trunk.

Thanks,
Kyrill

2017-12-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * config/arm/arm.opt (mverbose-cost-dump): New option.
     * config/arm/arm.c (arm_rtx_costs): Use it.

Comments

Sandra Loosemore Dec. 14, 2017, 5:09 p.m. UTC | #1
On 12/14/2017 08:53 AM, Kyrill Tkachov wrote:
> Hi all,
> 
> This patch adds an -mverbose-cost-dump option, similar to the one in 
> aarch64.
> It makes the RTX cost dump print the RTX we're costing in the backend, 
> as well as its cost.
> This can be distracting in other cost-related RTL dumps like combine's.
> 
> So now we don't dump the backend information by default, but provide the 
> power-user option -mverbose-cost-dump
> to enable the old verbose dumping.
> 
> This option is for GCC developers debugging the compiler only, so no 
> documentation are added.

No, it doesn't work that way.  There is a section in invoke.texi "GCC 
Developer Options" that is specifically for options that are only 
interesting to GCC developers debugging the compiler.  Please document 
this new option there.

-Sandra
Kyrill Tkachov Dec. 14, 2017, 5:56 p.m. UTC | #2
Hi Sandra,

On 14/12/17 17:09, Sandra Loosemore wrote:
> On 12/14/2017 08:53 AM, Kyrill Tkachov wrote:
>> Hi all,
>>
>> This patch adds an -mverbose-cost-dump option, similar to the one in 
>> aarch64.
>> It makes the RTX cost dump print the RTX we're costing in the 
>> backend, as well as its cost.
>> This can be distracting in other cost-related RTL dumps like combine's.
>>
>> So now we don't dump the backend information by default, but provide 
>> the power-user option -mverbose-cost-dump
>> to enable the old verbose dumping.
>>
>> This option is for GCC developers debugging the compiler only, so no 
>> documentation are added.
>
> No, it doesn't work that way.  There is a section in invoke.texi "GCC 
> Developer Options" that is specifically for options that are only 
> interesting to GCC developers debugging the compiler.  Please document 
> this new option there.
>
> -Sandra

Thanks for pointing me to this. I had assumed that we only want
to document target-independent options as I didn't see any other
target-dependent options in that section, but you are right.

There is no reason from a readers perspective not to document the
target-specific ones as well.

This patch adds a target-specific developer options subsection and adds
a short entry for the aarch64 and arm ones that I'm aware of.

make pdf works fine for me and the resulting pdf looks reasonable to my 
eyes.

That said, I'm not very familiar with the texi directives and I'm not 
sure what
the argument to the @table directive means. I've used @gcctabopt as I've 
seen it used
in other @table directives. Please let me know if I should use something 
else.

Ok for trunk?

Thanks,
Kyrill

2017-12-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * doc/invoke.texi (GCC Developer options): Add Target-specific
     developer options subsection.  Populate it with AArch64 and ARM
     options.
commit 34622cad273e03df44d2aaabc5e4bb664af50862
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Thu Dec 14 17:44:22 2017 +0000

    [doc] Add target-specific developer options subsection

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 0d565b4..00de74c 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -14223,6 +14223,24 @@ Print the compiler's built-in specs---and don't do anything else.  (This
 is used when GCC itself is being built.)  @xref{Spec Files}.
 @end table
 
+@subsection Target-specific developer options
+Some targets define additional debug options that are documented here.
+@subsubsection AArch64 developer options
+@table @gcctabopt
+@item -mverbose-cost-dump
+Enable verbose cost model dumping in the debug dump files.
+@item -moverride=
+Override CPU optimization parameters.
+@end table
+
+@subsubsection ARM developer options
+@table @gcctabopt
+@item -mverbose-cost-dump
+Enable verbose cost model dumping in the debug dump files.
+@item -mflip-thumb
+Switch ARM/Thumb modes on alternating functions.
+@end table
+
 @node Submodel Options
 @section Machine-Dependent Options
 @cindex submodel options
Sandra Loosemore Dec. 14, 2017, 6:23 p.m. UTC | #3
On 12/14/2017 10:56 AM, Kyrill Tkachov wrote:
> 
> 2017-12-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
> 
>      * doc/invoke.texi (GCC Developer options): Add Target-specific
>      developer options subsection.  Populate it with AArch64 and ARM
>      options.
 >
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index 0d565b4..00de74c 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -14223,6 +14223,24 @@ Print the compiler's built-in specs---and don't do anything else.  (This
>  is used when GCC itself is being built.)  @xref{Spec Files}.
>  @end table
>  
> +@subsection Target-specific developer options

Throughout this patch, please capitalize the first word of the section 
titles, and add @node and @cindex for each section.  There are plenty of 
examples in this chapter to copy the style from.

> +Some targets define additional debug options that are documented here.
> +@subsubsection AArch64 developer options
> +@table @gcctabopt
> +@item -mverbose-cost-dump
> +Enable verbose cost model dumping in the debug dump files.
> +@item -moverride=
> +Override CPU optimization parameters.

What parameters are these?  What is the syntax?  This isn't enough 
information to be useful.

> +@end table
> +
> +@subsubsection ARM developer options
> +@table @gcctabopt
> +@item -mverbose-cost-dump
> +Enable verbose cost model dumping in the debug dump files.
> +@item -mflip-thumb
> +Switch ARM/Thumb modes on alternating functions.
> +@end table
> +
>  @node Submodel Options
>  @section Machine-Dependent Options
>  @cindex submodel options

Please also list the new options in the "Option Summary" section.  Note 
that the list for developer options is currently mostly alphabetized.

-Sandra
Kyrill Tkachov Dec. 14, 2017, 6:48 p.m. UTC | #4
On 14/12/17 18:23, Sandra Loosemore wrote:
> On 12/14/2017 10:56 AM, Kyrill Tkachov wrote:
>>
>> 2017-12-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>>
>>      * doc/invoke.texi (GCC Developer options): Add Target-specific
>>      developer options subsection.  Populate it with AArch64 and ARM
>>      options.
> >
>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>> index 0d565b4..00de74c 100644
>> --- a/gcc/doc/invoke.texi
>> +++ b/gcc/doc/invoke.texi
>> @@ -14223,6 +14223,24 @@ Print the compiler's built-in specs---and 
>> don't do anything else.  (This
>>  is used when GCC itself is being built.)  @xref{Spec Files}.
>>  @end table
>>
>> +@subsection Target-specific developer options
>
> Throughout this patch, please capitalize the first word of the section 
> titles, and add @node and @cindex for each section.  There are plenty 
> of examples in this chapter to copy the style from.
>

Thanks, done.

>> +Some targets define additional debug options that are documented here.
>> +@subsubsection AArch64 developer options
>> +@table @gcctabopt
>> +@item -mverbose-cost-dump
>> +Enable verbose cost model dumping in the debug dump files.
>> +@item -moverride=
>> +Override CPU optimization parameters.
>
> What parameters are these?  What is the syntax?  This isn't enough 
> information to be useful.
>

I'm afraid I don't know. I've not used this option myself, I'm just 
aware of its existence.
Do you think it's better to leave it out altogether and document it 
separately at a later date
(or ping its author to document it perhaps)?

>> +@end table
>> +
>> +@subsubsection ARM developer options
>> +@table @gcctabopt
>> +@item -mverbose-cost-dump
>> +Enable verbose cost model dumping in the debug dump files.
>> +@item -mflip-thumb
>> +Switch ARM/Thumb modes on alternating functions.
>> +@end table
>> +
>>  @node Submodel Options
>>  @section Machine-Dependent Options
>>  @cindex submodel options
>
> Please also list the new options in the "Option Summary" section. Note 
> that the list for developer options is currently mostly alphabetized.
>

Thanks, done. I haven't created a new Target-specific developers options 
table but instead listed the targets the options apply to in parentheses.
Attached is the latest iteration.

Thank you for the review,
Kyrill

2017-12-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * doc/invoke.texi (GCC Developer options): Add Target-specific
     developer options subsection.  Populate it with AArch64 and ARM
     options.
     (Options Summary): List the above.
commit 1c92b22d63cc16296cbbbcf4791951971b62094d
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Thu Dec 14 17:44:22 2017 +0000

    [doc] Add target-specific developer options subsection

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 0d565b4..b8936d1 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -574,6 +574,8 @@ Objective-C and Objective-C++ Dialects}.
 -fsel-sched-verbose  -fsel-sched-dump-cfg  -fsel-sched-pipelining-verbose @gol
 -fstats  -fstack-usage  -ftime-report  -ftime-report-details @gol
 -fvar-tracking-assignments-toggle  -gtoggle @gol
+-mflip-thumb (ARM) -moverride=@var{string} (AArch64) @gol
+-mverbose-cost-dump (ARM, AArch64) @gol
 -print-file-name=@var{library}  -print-libgcc-file-name @gol
 -print-multi-directory  -print-multi-lib  -print-multi-os-directory @gol
 -print-prog-name=@var{program}  -print-search-dirs  -Q @gol
@@ -14223,6 +14225,31 @@ Print the compiler's built-in specs---and don't do anything else.  (This
 is used when GCC itself is being built.)  @xref{Spec Files}.
 @end table
 
+@node Target-specific Developer Options
+@cindex target-specific developer options
+@subsection Target-specific Developer Options
+Some targets define additional debug options that are documented here.
+
+@node AArch64 Developer Options
+@cindex aarch64 developer options
+@subsubsection AArch64 Developer Options
+@table @gcctabopt
+@item -moverride=
+Override CPU optimization parameters.
+@item -mverbose-cost-dump
+Enable verbose cost model dumping in the debug dump files.
+@end table
+
+@node ARM Developer Options
+@cindex arm developer options
+@subsubsection ARM Developer Options
+@table @gcctabopt
+@item -mflip-thumb
+Switch ARM/Thumb modes on alternating functions.
+@item -mverbose-cost-dump
+Enable verbose cost model dumping in the debug dump files.
+@end table
+
 @node Submodel Options
 @section Machine-Dependent Options
 @cindex submodel options
Kyrill Tkachov Dec. 14, 2017, 7:16 p.m. UTC | #5
On 14/12/17 18:48, Kyrill Tkachov wrote:
>
> On 14/12/17 18:23, Sandra Loosemore wrote:
> > On 12/14/2017 10:56 AM, Kyrill Tkachov wrote:
> >>
> >> 2017-12-14  Kyrylo Tkachov <kyrylo.tkachov@arm.com>
> >>
> >>      * doc/invoke.texi (GCC Developer options): Add Target-specific
> >>      developer options subsection.  Populate it with AArch64 and ARM
> >>      options.
> > >
> >> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> >> index 0d565b4..00de74c 100644
> >> --- a/gcc/doc/invoke.texi
> >> +++ b/gcc/doc/invoke.texi
> >> @@ -14223,6 +14223,24 @@ Print the compiler's built-in specs---and
> >> don't do anything else.  (This
> >>  is used when GCC itself is being built.) @xref{Spec Files}.
> >>  @end table
> >>
> >> +@subsection Target-specific developer options
> >
> > Throughout this patch, please capitalize the first word of the section
> > titles, and add @node and @cindex for each section. There are plenty
> > of examples in this chapter to copy the style from.
> >
>
> Thanks, done.
>
> >> +Some targets define additional debug options that are documented here.
> >> +@subsubsection AArch64 developer options
> >> +@table @gcctabopt
> >> +@item -mverbose-cost-dump
> >> +Enable verbose cost model dumping in the debug dump files.
> >> +@item -moverride=
> >> +Override CPU optimization parameters.
> >
> > What parameters are these?  What is the syntax?  This isn't enough
> > information to be useful.
> >
>
> I'm afraid I don't know. I've not used this option myself, I'm just
> aware of its existence.
> Do you think it's better to leave it out altogether and document it
> separately at a later date
> (or ping its author to document it perhaps)?
>
> >> +@end table
> >> +
> >> +@subsubsection ARM developer options
> >> +@table @gcctabopt
> >> +@item -mverbose-cost-dump
> >> +Enable verbose cost model dumping in the debug dump files.
> >> +@item -mflip-thumb
> >> +Switch ARM/Thumb modes on alternating functions.
> >> +@end table
> >> +
> >>  @node Submodel Options
> >>  @section Machine-Dependent Options
> >>  @cindex submodel options
> >
> > Please also list the new options in the "Option Summary" section. Note
> > that the list for developer options is currently mostly alphabetized.
> >
>
> Thanks, done. I haven't created a new Target-specific developers options
> table but instead listed the targets the options apply to in parentheses.
> Attached is the latest iteration.
>

Actually trying to build the tree normally, not through make pdf I get 
errors such as:
" Node `Target-specific Developer Options' requires a sectioning command 
(e.g., @unnumberedsubsec)."

that I don't know how to fix yet.
So I'll work on getting that fixed first...

Sorry for the noise,
Kyrill

> Thank you for the review,
> Kyrill
>
> 2017-12-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
>      * doc/invoke.texi (GCC Developer options): Add Target-specific
>      developer options subsection.  Populate it with AArch64 and ARM
>      options.
>      (Options Summary): List the above.
Sandra Loosemore Dec. 15, 2017, 5:50 a.m. UTC | #6
On 12/14/2017 11:48 AM, Kyrill Tkachov wrote:
> 
> [snip]
> 
> Thanks, done. I haven't created a new Target-specific developers options 
> table but instead listed the targets the options apply to in parentheses.
> Attached is the latest iteration.
> 
> Thank you for the review,
> Kyrill
> 
> 2017-12-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
> 
>      * doc/invoke.texi (GCC Developer options): Add Target-specific
>      developer options subsection.  Populate it with AArch64 and ARM
>      options.
>      (Options Summary): List the above.

Hmmm, there are still various problems here, and now I notice that 
there's already an entry for -moverride= in the AArch64 Options section. 
  I need to go through the docs for all targets and make sure everything 
is treated uniformly, so I think it would be more efficient for me to 
take this over than to continue to iterate with you to get the patch 
right.  I'll try to get to it this weekend.

-Sandra
Sandra Loosemore Dec. 18, 2017, 4:09 a.m. UTC | #7
On 12/14/2017 10:50 PM, Sandra Loosemore wrote:
> On 12/14/2017 11:48 AM, Kyrill Tkachov wrote:
>>
>> [snip]
>>
>> Thanks, done. I haven't created a new Target-specific developers 
>> options table but instead listed the targets the options apply to in 
>> parentheses.
>> Attached is the latest iteration.
>>
>> Thank you for the review,
>> Kyrill
>>
>> 2017-12-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>>
>>      * doc/invoke.texi (GCC Developer options): Add Target-specific
>>      developer options subsection.  Populate it with AArch64 and ARM
>>      options.
>>      (Options Summary): List the above.
> 
> Hmmm, there are still various problems here, and now I notice that 
> there's already an entry for -moverride= in the AArch64 Options section. 
>   I need to go through the docs for all targets and make sure everything 
> is treated uniformly, so I think it would be more efficient for me to 
> take this over than to continue to iterate with you to get the patch 
> right.  I'll try to get to it this weekend.

OK, I've checked in the attached patch.

I apologize for having given you a bum steer on this previously.  :-( 
When I dug around in the existing documentation lists, I found a dozen 
or more existing target-specific developer options already listed in the 
sections for the respective targets (FRV, in particular, has a whole 
pile of them documented as "for debugging the compiler").  I thought it 
made more sense in terms of the highly target-specific-ness of what many 
of these options do to leave them all where they are now, as well as 
less work than moving them all to another section.  So I similarly added 
the docs for the missing ARM and AArch64 developer options to the 
existing sections for those respective targets as well.

-Sandra
2017-12-17  Sandra Loosemore  <sandra@codesourcery.com>
	    Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

	gcc/
	* doc/invoke.texi (Option Summary): Add -mverbose-cost-dump
	to AArch64 and ARM lists, plus missing -mflip-thumb for ARM.
	(AArch64 Options): Document -mverbose-cost-dump.
	(ARM Options): Likewise, plus -mflip-thumb.
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi	(revision 255768)
+++ gcc/doc/invoke.texi	(working copy)
@@ -598,7 +598,8 @@ Objective-C and Objective-C++ Dialects}.
 -mlow-precision-recip-sqrt  -mlow-precision-sqrt  -mlow-precision-div @gol
 -mpc-relative-literal-loads @gol
 -msign-return-address=@var{scope} @gol
--march=@var{name}  -mcpu=@var{name}  -mtune=@var{name}  -moverride=@var{string}}
+-march=@var{name}  -mcpu=@var{name}  -mtune=@var{name}  @gol
+-moverride=@var{string}  -mverbose-cost-dump}
 
 @emph{Adapteva Epiphany Options}
 @gccoptlist{-mhalf-reg-file  -mprefer-short-insn-regs @gol
@@ -648,7 +649,7 @@ Objective-C and Objective-C++ Dialects}.
 -mpic-register=@var{reg} @gol
 -mnop-fun-dllimport @gol
 -mpoke-function-name @gol
--mthumb  -marm @gol
+-mthumb  -marm  -mflip-thumb @gol
 -mtpcs-frame  -mtpcs-leaf-frame @gol
 -mcaller-super-interworking  -mcallee-super-interworking @gol
 -mtp=@var{name}  -mtls-dialect=@var{dialect} @gol
@@ -659,6 +660,7 @@ Objective-C and Objective-C++ Dialects}.
 -mslow-flash-data @gol
 -masm-syntax-unified @gol
 -mrestrict-it @gol
+-mverbose-cost-dump @gol
 -mpure-code @gol
 -mcmse}
 
@@ -14556,6 +14558,11 @@ across releases.
 
 This option is only intended to be useful when developing GCC.
 
+@item -mverbose-cost-dump
+@opindex mverbose-cost-dump
+Enable verbose cost model dumping in the debug dump files.  This option is
+provided for use in debugging the compiler.
+
 @item -mpc-relative-literal-loads
 @itemx -mno-pc-relative-literal-loads
 @opindex mpc-relative-literal-loads
@@ -16237,6 +16244,12 @@ You can also override the ARM and Thumb
 by using the @code{target("thumb")} and @code{target("arm")} function attributes
 (@pxref{ARM Function Attributes}) or pragmas (@pxref{Function Specific Option Pragmas}).
 
+@item -mflip-thumb 
+@opindex mflip-thumb
+Switch ARM/Thumb modes on alternating functions.
+This option is provided for regression testing of mixed Thumb/ARM code
+generation, and is not intended for ordinary use in compiling code.
+
 @item -mtpcs-frame
 @opindex mtpcs-frame
 Generate a stack frame that is compliant with the Thumb Procedure Call
@@ -16351,6 +16364,11 @@ an option used only for regression testi
 intended for ordinary use in compiling code.  This option is disabled
 by default.
 
+@item -mverbose-cost-dump
+@opindex mverbose-cost-dump
+Enable verbose cost model dumping in the debug dump files.  This option is
+provided for use in debugging the compiler.
+
 @item -mpure-code
 @opindex mpure-code
 Do not allow constant data to be placed in code sections.
Kyrill Tkachov Dec. 18, 2017, 9:10 a.m. UTC | #8
On 18/12/17 04:09, Sandra Loosemore wrote:
> On 12/14/2017 10:50 PM, Sandra Loosemore wrote:
>> On 12/14/2017 11:48 AM, Kyrill Tkachov wrote:
>>>
>>> [snip]
>>>
>>> Thanks, done. I haven't created a new Target-specific developers 
>>> options table but instead listed the targets the options apply to in 
>>> parentheses.
>>> Attached is the latest iteration.
>>>
>>> Thank you for the review,
>>> Kyrill
>>>
>>> 2017-12-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>>>
>>>      * doc/invoke.texi (GCC Developer options): Add Target-specific
>>>      developer options subsection.  Populate it with AArch64 and ARM
>>>      options.
>>>      (Options Summary): List the above.
>>
>> Hmmm, there are still various problems here, and now I notice that 
>> there's already an entry for -moverride= in the AArch64 Options 
>> section.   I need to go through the docs for all targets and make 
>> sure everything is treated uniformly, so I think it would be more 
>> efficient for me to take this over than to continue to iterate with 
>> you to get the patch right.  I'll try to get to it this weekend.
>
> OK, I've checked in the attached patch.
>
> I apologize for having given you a bum steer on this previously. :-( 
> When I dug around in the existing documentation lists, I found a dozen 
> or more existing target-specific developer options already listed in 
> the sections for the respective targets (FRV, in particular, has a 
> whole pile of them documented as "for debugging the compiler").  I 
> thought it made more sense in terms of the highly target-specific-ness 
> of what many of these options do to leave them all where they are now, 
> as well as less work than moving them all to another section.  So I 
> similarly added the docs for the missing ARM and AArch64 developer 
> options to the existing sections for those respective targets as well.
>

Thanks Sandra, this does look better now.
Kyrill

> -Sandra
diff mbox series

Patch

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index f34b6e0..9b29a0a 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -11068,7 +11068,7 @@  arm_rtx_costs (rtx x, machine_mode mode ATTRIBUTE_UNUSED, int outer_code,
 				current_tune->insn_extra_cost,
 				total, speed);
 
-  if (dump_file && (dump_flags & TDF_DETAILS))
+  if (dump_file && arm_verbose_cost)
     {
       print_rtl_single (dump_file, x);
       fprintf (dump_file, "\n%s cost: %d (%s)\n", speed ? "Hot" : "Cold",
diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt
index 6060516..48f64588 100644
--- a/gcc/config/arm/arm.opt
+++ b/gcc/config/arm/arm.opt
@@ -254,6 +254,10 @@  mvectorize-with-neon-double
 Target Report RejectNegative Mask(NEON_VECTORIZE_DOUBLE)
 Use Neon double-word (rather than quad-word) registers for vectorization.
 
+mverbose-cost-dump
+Common Undocumented Var(arm_verbose_cost) Init(0)
+Enable more verbose RTX cost dumps during debug.  For GCC developers use only.
+
 mword-relocations
 Target Report Var(target_word_relocations) Init(TARGET_DEFAULT_WORD_RELOCATIONS)
 Only generate absolute relocations on word sized values.