[PATCH 2/3] Add lto-dump tool.

2019-03-14 Thread marxin

gcc/ChangeLog:

2019-03-14  Hrishikesh Kulkarni  
Martin Liska  

* Makefile.in: Add lto-dump.texi.
* cgraph.h: Add new functions dump_visibility and
dump_type_name.
* doc/gcc.texi: Include lto-dump section.
* doc/lto-dump.texi: New file.
* dumpfile.c (dump_switch_p_1): Use parse_dump_option.
(parse_dump_option): Factor out this function.
* dumpfile.h (enum dump_flag): Add new value TDF_ERROR.
(parse_dump_option): Export the function.
* symtab.c (symtab_node::dump_visibility): New function.
(symtab_node::dump_type_name): Likewise.

gcc/lto/ChangeLog:

2019-03-14  Hrishikesh Kulkarni  
Martin Liska  

* Make-lang.in: Add lto_dump-related definition.
* config-lang.in: Likewise.
* lang.opt: Add new language LTODump and options related
to LTO dump tool.
* lto-common.c (lto_read_decls): Support type statistics dump.
(lto_file_read): Likewise for object files.
* lto-dump.c: New file.
* lto-lang.c (lto_option_lang_mask): Move from ..
* lto.c (lto_option_lang_mask): .. here.
* lto.h (lto_option_lang_mask): New declaration.
---
 gcc/Makefile.in|   2 +-
 gcc/cgraph.h   |   6 +
 gcc/doc/gcc.texi   |   5 +
 gcc/doc/lto-dump.texi  | 131 
 gcc/dumpfile.c |  85 ++
 gcc/dumpfile.h |   5 +
 gcc/lto/Make-lang.in   |  20 ++-
 gcc/lto/config-lang.in |   4 +-
 gcc/lto/lang.opt   |  62 
 gcc/lto/lto-common.c   |  40 +
 gcc/lto/lto-dump.c | 344 +
 gcc/lto/lto-lang.c |   6 -
 gcc/lto/lto.c  |   6 +
 gcc/lto/lto.h  |   2 +
 gcc/symtab.c   |  17 ++
 15 files changed, 692 insertions(+), 43 deletions(-)
 create mode 100644 gcc/doc/lto-dump.texi
 create mode 100644 gcc/lto/lto-dump.c

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 508c674cbdc..c7e4ae94103 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3158,7 +3158,7 @@ TEXI_GCC_FILES = gcc.texi gcc-common.texi gcc-vers.texi frontends.texi	\
 	 gcov.texi trouble.texi bugreport.texi service.texi		\
 	 contribute.texi compat.texi funding.texi gnu.texi gpl_v3.texi	\
 	 fdl.texi contrib.texi cppenv.texi cppopts.texi avr-mmcu.texi	\
-	 implement-c.texi implement-cxx.texi gcov-tool.texi gcov-dump.texi
+	 implement-c.texi implement-cxx.texi gcov-tool.texi gcov-dump.texi lto-dump.texi
 
 # we explicitly use $(srcdir)/doc/tm.texi here to avoid confusion with
 # the generated tm.texi; the latter might have a more recent timestamp,
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 9a19d83fffb..e2c2c00b5ed 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -119,6 +119,12 @@ public:
   /* Return dump name with assembler name.  */
   const char *dump_asm_name () const;
 
+  /* Return visibility name.  */
+  const char *dump_visibility () const;
+
+  /* Return type_name name.  */
+  const char *dump_type_name () const;
+
   /* Add node into symbol table.  This function is not used directly, but via
  cgraph/varpool node creation routines.  */
   void register_symbol (void);
diff --git a/gcc/doc/gcc.texi b/gcc/doc/gcc.texi
index 5297b9cb5d0..4d03e3a6d96 100644
--- a/gcc/doc/gcc.texi
+++ b/gcc/doc/gcc.texi
@@ -68,6 +68,8 @@ Texts being (a) (see below), and with the Back-Cover Texts being (b)
 * gcov: (gcc) Gcov.@command{gcov}---a test coverage program.
 * gcov-tool: (gcc) Gcov-tool.  @command{gcov-tool}---an offline gcda profile processing program.
 * gcov-dump: (gcc) Gcov-dump.  @command{gcov-dump}---an offline gcda and gcno profile dump tool.
+* lto-dump: (gcc) lto-dump.@command{lto-dump}---Tool for
+dumping LTO object files.
 @end direntry
 This file documents the use of the GNU compilers.
 @sp 1
@@ -142,6 +144,8 @@ Introduction, gccint, GNU Compiler Collection (GCC) Internals}.
 * Gcov::@command{gcov}---a test coverage program.
 * Gcov-tool::   @command{gcov-tool}---an offline gcda profile processing program.
 * Gcov-dump::   @command{gcov-dump}---an offline gcda and gcno profile dump tool.
+* lto-dump::@command{lto-dump}---Tool for dumping LTO
+object files.
 * Trouble:: If you have trouble using GCC.
 * Bugs::How, why and where to report bugs.
 * Service:: How To Get Help with GCC
@@ -170,6 +174,7 @@ Introduction, gccint, GNU Compiler Collection (GCC) Internals}.
 @include gcov.texi
 @include gcov-tool.texi
 @include gcov-dump.texi
+@include lto-dump.texi
 @include trouble.texi
 @include bugreport.texi
 @include service.texi
diff --git a/gcc/doc/lto-dump.texi b/gcc/doc/lto-dump.texi
new file mode 100644
index 000..d84397581c0
--- /dev/null
+++ b/gcc/doc/lto-dump.texi
@@ -0,0 +1,131 @@
+@c Copyright (C) 2018-2019 Free Software Foundation, Inc.
+@c This is part of the GCC manual.
+@c For copying conditions, see the file gcc.texi.
+
+@ignore
+@c man begin COPYRIGHT
+Copyrigh

Re: [PATCH 2/3] Add lto-dump tool.

2019-04-26 Thread Richard Biener
On Thu, Mar 14, 2019 at 3:00 PM marxin  wrote:
>

I think it's a good start.  Some minor nits:

+/* Dump the visibility of the symbol.  */
+
+const char *
+symtab_node::dump_visibility () const
+{
+  static const char * const visibility_types[]
+= { "default", "protected", "hidden", "internal" };
+  return visibility_types[DECL_VISIBILITY (decl)];
+}
+
+/* Dump the type_name of the symbol.  */
+const char *
+symtab_node::dump_type_name () const
+{
+  return symtab_type_names[type];
+}

Both method names are not very good.  I guess the first
should be get_visibilitiy_string and the second
get_symtab_type_string?  Because they do not actually
dump.

For the function statistics I wonder if we really need the
untransformed body or if we can resort to inline information
that must be also in the LTO stream.

Otherwise looks OK to me.

Thanks,
Richard.

> gcc/ChangeLog:
>
> 2019-03-14  Hrishikesh Kulkarni  
> Martin Liska  
>
> * Makefile.in: Add lto-dump.texi.
> * cgraph.h: Add new functions dump_visibility and
> dump_type_name.
> * doc/gcc.texi: Include lto-dump section.
> * doc/lto-dump.texi: New file.
> * dumpfile.c (dump_switch_p_1): Use parse_dump_option.
> (parse_dump_option): Factor out this function.
> * dumpfile.h (enum dump_flag): Add new value TDF_ERROR.
> (parse_dump_option): Export the function.
> * symtab.c (symtab_node::dump_visibility): New function.
> (symtab_node::dump_type_name): Likewise.
>
> gcc/lto/ChangeLog:
>
> 2019-03-14  Hrishikesh Kulkarni  
> Martin Liska  
>
> * Make-lang.in: Add lto_dump-related definition.
> * config-lang.in: Likewise.
> * lang.opt: Add new language LTODump and options related
> to LTO dump tool.
> * lto-common.c (lto_read_decls): Support type statistics dump.
> (lto_file_read): Likewise for object files.
> * lto-dump.c: New file.
> * lto-lang.c (lto_option_lang_mask): Move from ..
> * lto.c (lto_option_lang_mask): .. here.
> * lto.h (lto_option_lang_mask): New declaration.
> ---
>  gcc/Makefile.in|   2 +-
>  gcc/cgraph.h   |   6 +
>  gcc/doc/gcc.texi   |   5 +
>  gcc/doc/lto-dump.texi  | 131 
>  gcc/dumpfile.c |  85 ++
>  gcc/dumpfile.h |   5 +
>  gcc/lto/Make-lang.in   |  20 ++-
>  gcc/lto/config-lang.in |   4 +-
>  gcc/lto/lang.opt   |  62 
>  gcc/lto/lto-common.c   |  40 +
>  gcc/lto/lto-dump.c | 344 +
>  gcc/lto/lto-lang.c |   6 -
>  gcc/lto/lto.c  |   6 +
>  gcc/lto/lto.h  |   2 +
>  gcc/symtab.c   |  17 ++
>  15 files changed, 692 insertions(+), 43 deletions(-)
>  create mode 100644 gcc/doc/lto-dump.texi
>  create mode 100644 gcc/lto/lto-dump.c
>


Re: [PATCH 2/3] Add lto-dump tool.

2022-10-28 Thread Thomas Schwinge
Hi!

This minor clean-up had fallen out of me working on something else in
GCC's options machinery, several months ago:

On 2019-03-12T18:14:04+0100, marxin  wrote:
> gcc/lto/ChangeLog:

>   * lang.opt: Add new language LTODump and options related
>   to LTO dump tool.

As this new "Language" 'LTODump' does not share any options with 'LTO'
proper, it makes sense, in my opinion, to also make that obvious in
'gcc/lto/lang.opt', which your Subversion r270897 (Git
commit 66d62d9f2e6b059be6a018397fba555147133a9a) "Add lto-dump tool"
almost ;-) did:

> --- a/gcc/lto/lang.opt
> +++ b/gcc/lto/lang.opt
> @@ -24,6 +24,9 @@
>  Language
>  LTO
>
> +Language
> +LTODump
> +
>  Enum
>  Name(lto_linker_output) Type(enum lto_linker_output) UnknownError(unknown 
> linker output %qs)
>
> @@ -66,6 +69,65 @@ fwpa=
>  LTO Driver RejectNegative Joined Var(flag_wpa)
>  Whole program analysis (WPA) mode with number of parallel jobs specified.
>
> +
> +[LTODump option records]
> +
> +
>  fresolution=
>  LTO Joined
>  The resolution file.

OK to push the attached
"Better separate 'LTO' vs. 'LTODump' in 'gcc/lto/lang.opt'"?


Grüße
 Thomas


-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955
>From 7fe1d5b8d39d863285e14fbb186599dcf6bba986 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge 
Date: Fri, 1 Apr 2022 19:52:54 +0200
Subject: [PATCH] Better separate 'LTO' vs. 'LTODump' in 'gcc/lto/lang.opt'

Minor clean-up after Subversion r270897 (Git
commit 66d62d9f2e6b059be6a018397fba555147133a9a) "Add lto-dump tool".

No change in generated files.

	gcc/lto/
	* lang.opt: Better separate 'LTO' vs. 'LTODump'.
---
 gcc/lto/lang.opt | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/gcc/lto/lang.opt b/gcc/lto/lang.opt
index 550a50fc188..1ad2967d9cf 100644
--- a/gcc/lto/lang.opt
+++ b/gcc/lto/lang.opt
@@ -24,9 +24,6 @@
 Language
 LTO
 
-Language
-LTODump
-
 Enum
 Name(lto_linker_output) Type(enum lto_linker_output) UnknownError(unknown linker output %qs)
 
@@ -52,7 +49,6 @@ flinker-output=
 LTO Driver Joined RejectNegative Enum(lto_linker_output) Var(flag_lto_linker_output) Init(LTO_LINKER_OUTPUT_UNKNOWN)
 Set linker output type (used internally during LTO optimization).
 
-
 fltrans
 LTO Var(flag_ltrans)
 Run the link-time optimizer in local transformation (LTRANS) mode.
@@ -61,6 +57,10 @@ fltrans-output-list=
 LTO Joined Var(ltrans_output_list)
 Specify a file to which a list of files output by LTRANS is written.
 
+fresolution=
+LTO Joined
+The resolution file.
+
 fwpa
 LTO Driver
 Run the link-time optimizer in whole program analysis (WPA) mode.
@@ -70,6 +70,9 @@ LTO Driver RejectNegative Joined Var(flag_wpa)
 Whole program analysis (WPA) mode with number of parallel jobs specified.
 
 
+Language
+LTODump
+
 list
 LTODump Var(flag_lto_dump_list)
 Call the dump function for variables and function in IL.
@@ -131,8 +134,4 @@ callgraph
 LTODump Var(flag_dump_callgraph)
 Dump the symtab callgraph.
 
-fresolution=
-LTO Joined
-The resolution file.
-
 ; This comment is to ensure we retain the blank line above.
-- 
2.35.1



Re: [PATCH 2/3] Add lto-dump tool.

2022-10-28 Thread Jeff Law via Gcc-patches



On 10/28/22 04:14, Thomas Schwinge wrote:

Hi!

This minor clean-up had fallen out of me working on something else in
GCC's options machinery, several months ago:

On 2019-03-12T18:14:04+0100, marxin  wrote:

gcc/lto/ChangeLog:
   * lang.opt: Add new language LTODump and options related
   to LTO dump tool.

As this new "Language" 'LTODump' does not share any options with 'LTO'
proper, it makes sense, in my opinion, to also make that obvious in
'gcc/lto/lang.opt', which your Subversion r270897 (Git
commit 66d62d9f2e6b059be6a018397fba555147133a9a) "Add lto-dump tool"
almost ;-) did:


--- a/gcc/lto/lang.opt
+++ b/gcc/lto/lang.opt
@@ -24,6 +24,9 @@
  Language
  LTO

+Language
+LTODump
+
  Enum
  Name(lto_linker_output) Type(enum lto_linker_output) UnknownError(unknown 
linker output %qs)

@@ -66,6 +69,65 @@ fwpa=
  LTO Driver RejectNegative Joined Var(flag_wpa)
  Whole program analysis (WPA) mode with number of parallel jobs specified.

+
+[LTODump option records]
+
+
  fresolution=
  LTO Joined
  The resolution file.

OK to push the attached
"Better separate 'LTO' vs. 'LTODump' in 'gcc/lto/lang.opt'"?


OK.

jeff