This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unreviewed gcov patch


Nathan Sidwell <nathan@codesourcery.com> writes:
> Richard Sandiford wrote:
>> For the record, there's also a related gcov patch:
>> http://gcc.gnu.org/ml/gcc-patches/2005-03/msg01849.html
>
> This one is ok for mainline.  It's not a regression so don't put it
> on 4.0, thanks.

OK, thanks.  It turns out a few more uses of GCOV_TYPE_NODE had been
added in the meantime.  Rather than change them all to gcov_type_node (),
I just #defined GCOV_TYPE_NODE to gcov_type_node () in coverage.h.
This means that no changes are now needed to tree-profile.c.

One of the new uses of GCOV_TYPE_NODE is in value-prof.c, which didn't
use it before.  Since the definition of GCOV_TYPE_NODE has moved to
coverage.h, I had to #include coverage.h in value-prof.c.  This didn't
need a Makefile update since $(COVERAGE_H) is already a dependency of
value-prof.o.

I thought these changes were obvious enough relative to the last patch,
so I went ahead and applied this new version to mainline after bootstrapping
and regression testing on i686-pc-linux-gnu.

Richard


	* system.h (GCOV_SIZE_TYPE): Unposion.
	* gcov-io.h (GCOV_TYPE_NODE): Delete, replacing with...
	(GCOV_TYPE_SIZE): ...this new macro.
	* coverage.h (get_gcov_type, GCOV_TYPE_NODE): Declare.
	* coverage.c (get_gcov_type, get_gcov_unsigned_t): New functions.
	(rtl_coverage_counter_ref): Use GCOV_TYPE_SIZE.
	(build_fn_info_type, build_fn_info_value, build_ctr_info_type)
	(build_ctr_info_value, build_gcov_info): Use get_gcov_unsigned_t
	instead of unsigned_intSI_type_node.
	* rtl-profile.c (rtl_gen_interval_profiler, rtl_gen_pow2_profiler)
	(rtl_gen_one_value_profiler_no_edge_manipulation)
	(rtl_gen_const_delta_profiler): Use GCOV_TYPE_SIZE.
	* value-prof.c: Include coverage.h.

Index: system.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/system.h,v
retrieving revision 1.246
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.246 system.h
--- system.h	23 Mar 2005 19:46:44 -0000	1.246
+++ system.h	4 Apr 2005 19:36:13 -0000
@@ -646,8 +646,7 @@ #define realloc xrealloc
 	PROMOTED_MODE EXPAND_BUILTIN_VA_END				   \
 	LINKER_DOES_NOT_WORK_WITH_DWARF2 FUNCTION_ARG_KEEP_AS_REFERENCE	   \
 	GIV_SORT_CRITERION MAX_LONG_TYPE_SIZE MAX_LONG_DOUBLE_TYPE_SIZE	   \
-	MAX_WCHAR_TYPE_SIZE GCOV_TYPE_SIZE SHARED_SECTION_ASM_OP	   \
-	INTEGRATE_THRESHOLD                                                \
+	MAX_WCHAR_TYPE_SIZE SHARED_SECTION_ASM_OPINTEGRATE_THRESHOLD       \
 	FINAL_REG_PARM_STACK_SPACE MAYBE_REG_PARM_STACK_SPACE		   \
 	TRADITIONAL_PIPELINE_INTERFACE DFA_PIPELINE_INTERFACE		   \
 	DBX_OUTPUT_STANDARD_TYPES BUILTIN_SETJMP_FRAME_VALUE		   \
Index: gcov-io.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcov-io.h,v
retrieving revision 1.53
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.53 gcov-io.h
--- gcov-io.h	1 Apr 2005 14:08:00 -0000	1.53
+++ gcov-io.h	4 Apr 2005 19:36:14 -0000
@@ -214,11 +214,7 @@ typedef HOST_WIDEST_INT gcov_type;
 #include <sys/types.h>
 #endif
 #else /*!IN_GCOV */
-#if LONG_LONG_TYPE_SIZE > 32
-#define GCOV_TYPE_NODE intDI_type_node
-#else
-#define GCOV_TYPE_NODE intSI_type_node
-#endif
+#define GCOV_TYPE_SIZE (LONG_LONG_TYPE_SIZE > 32 ? 64 : 32)
 #endif
 
 #if defined (HOST_HAS_F_SETLKW)
Index: coverage.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/coverage.h,v
retrieving revision 1.8
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.8 coverage.h
--- coverage.h	18 Jan 2005 11:36:03 -0000	1.8
+++ coverage.h	4 Apr 2005 19:36:14 -0000
@@ -47,4 +47,8 @@ extern gcov_type *get_coverage_counts (u
 				       unsigned /*expected*/,
 				       const struct gcov_ctr_summary **);
 
+extern tree get_gcov_type (void);
+
+#define GCOV_TYPE_NODE get_gcov_type ()
+
 #endif
Index: coverage.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/coverage.c,v
retrieving revision 1.47
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.47 coverage.c
--- coverage.c	15 Sep 2004 20:47:39 -0000	1.47
+++ coverage.c	4 Apr 2005 19:36:14 -0000
@@ -120,7 +120,22 @@ static tree build_ctr_info_type (void);
 static tree build_ctr_info_value (unsigned, tree);
 static tree build_gcov_info (void);
 static void create_coverage (void);
+
+/* Return the type node for gcov_type.  */
+
+tree
+get_gcov_type (void)
+{
+  return lang_hooks.types.type_for_size (GCOV_TYPE_SIZE, false);
+}
+
+/* Return the type node for gcov_unsigned_t.  */
 
+static tree
+get_gcov_unsigned_t (void)
+{
+  return lang_hooks.types.type_for_size (32, true);
+}
 
 static hashval_t
 htab_counts_entry_hash (const void *of)
@@ -399,8 +414,7 @@ coverage_counter_alloc (unsigned counter
 rtx
 rtl_coverage_counter_ref (unsigned counter, unsigned no)
 {
-  unsigned gcov_size = tree_low_cst (TYPE_SIZE (GCOV_TYPE_NODE), 1);
-  enum machine_mode mode = mode_for_size (gcov_size, MODE_INT, 0);
+  enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0);
   rtx ref;
 
   gcc_assert (no < fn_n_ctrs[counter] - fn_b_ctrs[counter]);
@@ -412,7 +426,8 @@ rtl_coverage_counter_ref (unsigned count
 			       (tree_ctr_tables[counter]))));
         SYMBOL_REF_FLAGS (ctr_labels[counter]) = SYMBOL_FLAG_LOCAL;
       }
-  ref = plus_constant (ctr_labels[counter], gcov_size / BITS_PER_UNIT * no);
+  ref = plus_constant (ctr_labels[counter],
+		       GCOV_TYPE_SIZE / BITS_PER_UNIT * no);
   ref = gen_rtx_MEM (mode, ref);
   set_mem_alias_set (ref, new_alias_set ());
   MEM_NOTRAP_P (ref) = 1;
@@ -602,10 +617,10 @@ build_fn_info_type (unsigned int counter
   tree array_type;
 
   /* ident */
-  fields = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
+  fields = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
 
   /* checksum */
-  field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
+  field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
   TREE_CHAIN (field) = fields;
   fields = field;
 
@@ -636,12 +651,12 @@ build_fn_info_value (const struct functi
   tree array_value = NULL_TREE;
 
   /* ident */
-  value = tree_cons (fields, build_int_cstu (unsigned_intSI_type_node,
+  value = tree_cons (fields, build_int_cstu (get_gcov_unsigned_t (),
 					     function->ident), value);
   fields = TREE_CHAIN (fields);
 
   /* checksum */
-  value = tree_cons (fields, build_int_cstu (unsigned_intSI_type_node,
+  value = tree_cons (fields, build_int_cstu (get_gcov_unsigned_t (),
 					     function->checksum), value);
   fields = TREE_CHAIN (fields);
 
@@ -674,7 +689,7 @@ build_ctr_info_type (void)
   tree gcov_merge_fn_type;
 
   /* counters */
-  field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
+  field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
   TREE_CHAIN (field) = fields;
   fields = field;
 
@@ -711,7 +726,7 @@ build_ctr_info_value (unsigned int count
 
   /* counters */
   value = tree_cons (fields,
-		     build_int_cstu (unsigned_intSI_type_node,
+		     build_int_cstu (get_gcov_unsigned_t (),
 				     prg_n_ctrs[counter]),
 		     value);
   fields = TREE_CHAIN (fields);
@@ -785,11 +800,11 @@ build_gcov_info (void)
   const_type = build_qualified_type (type, TYPE_QUAL_CONST);
 
   /* Version ident */
-  field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
+  field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
   TREE_CHAIN (field) = fields;
   fields = field;
-  value = tree_cons (field, build_int_cstu (unsigned_intSI_type_node,
-					    GCOV_VERSION), value);
+  value = tree_cons (field, build_int_cstu (TREE_TYPE (field), GCOV_VERSION),
+		     value);
 
   /* next -- NULL */
   field = build_decl (FIELD_DECL, NULL_TREE, build_pointer_type (const_type));
@@ -798,11 +813,11 @@ build_gcov_info (void)
   value = tree_cons (field, null_pointer_node, value);
 
   /* stamp */
-  field = build_decl (FIELD_DECL, NULL_TREE, unsigned_intSI_type_node);
+  field = build_decl (FIELD_DECL, NULL_TREE, get_gcov_unsigned_t ());
   TREE_CHAIN (field) = fields;
   fields = field;
-  value = tree_cons (field, build_int_cstu (unsigned_intSI_type_node,
-					    local_tick), value);
+  value = tree_cons (field, build_int_cstu (TREE_TYPE (field), local_tick),
+		     value);
 
   /* Filename */
   string_type = build_pointer_type (build_qualified_type (char_type_node,
Index: rtl-profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl-profile.c,v
retrieving revision 2.5
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r2.5 rtl-profile.c
--- rtl-profile.c	29 Mar 2005 22:15:52 -0000	2.5
+++ rtl-profile.c	4 Apr 2005 19:36:14 -0000
@@ -83,14 +83,13 @@ rtl_gen_edge_profiler (int edgeno, edge 
 static void
 rtl_gen_interval_profiler (histogram_value value, unsigned tag, unsigned base)
 {
-  unsigned gcov_size = tree_low_cst (TYPE_SIZE (GCOV_TYPE_NODE), 1);
-  enum machine_mode mode = mode_for_size (gcov_size, MODE_INT, 0);
+  enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0);
   rtx mem_ref, tmp, tmp1, mr, val;
   rtx sequence;
   rtx more_label = gen_label_rtx ();
   rtx less_label = gen_label_rtx ();
   rtx end_of_code_label = gen_label_rtx ();
-  int per_counter = gcov_size / BITS_PER_UNIT;
+  int per_counter = GCOV_TYPE_SIZE / BITS_PER_UNIT;
   edge e = split_block (BLOCK_FOR_INSN (value->hvalue.rtl.insn),
 		   PREV_INSN (value->hvalue.rtl.insn));
 
@@ -169,13 +168,12 @@ rtl_gen_interval_profiler (histogram_val
 static void
 rtl_gen_pow2_profiler (histogram_value value, unsigned tag, unsigned base)
 {
-  unsigned gcov_size = tree_low_cst (TYPE_SIZE (GCOV_TYPE_NODE), 1);
-  enum machine_mode mode = mode_for_size (gcov_size, MODE_INT, 0);
+  enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0);
   rtx mem_ref, tmp, mr, uval;
   rtx sequence;
   rtx end_of_code_label = gen_label_rtx ();
   rtx loop_label = gen_label_rtx ();
-  int per_counter = gcov_size / BITS_PER_UNIT;
+  int per_counter = GCOV_TYPE_SIZE / BITS_PER_UNIT;
   edge e = split_block (BLOCK_FOR_INSN (value->hvalue.rtl.insn),
 		   PREV_INSN (value->hvalue.rtl.insn));
 
@@ -245,8 +243,7 @@ static rtx
 rtl_gen_one_value_profiler_no_edge_manipulation (histogram_value value,
 						 unsigned tag, unsigned base)
 {
-  unsigned gcov_size = tree_low_cst (TYPE_SIZE (GCOV_TYPE_NODE), 1);
-  enum machine_mode mode = mode_for_size (gcov_size, MODE_INT, 0);
+  enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0);
   rtx stored_value_ref, counter_ref, all_ref, stored_value, counter, all;
   rtx tmp, uval;
   rtx sequence;
@@ -340,8 +337,7 @@ static void
 rtl_gen_const_delta_profiler (histogram_value value, unsigned tag, unsigned base)
 {
   histogram_value one_value_delta;
-  unsigned gcov_size = tree_low_cst (TYPE_SIZE (GCOV_TYPE_NODE), 1);
-  enum machine_mode mode = mode_for_size (gcov_size, MODE_INT, 0);
+  enum machine_mode mode = mode_for_size (GCOV_TYPE_SIZE, MODE_INT, 0);
   rtx stored_value_ref, stored_value, tmp, uval;
   rtx sequence;
   edge e = split_block (BLOCK_FOR_INSN (value->hvalue.rtl.insn),
Index: value-prof.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/value-prof.c,v
retrieving revision 1.21
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.21 value-prof.c
--- value-prof.c	29 Mar 2005 11:45:50 -0000	1.21
+++ value-prof.c	4 Apr 2005 19:36:14 -0000
@@ -37,6 +37,7 @@ 02111-1307, USA.  */
 #include "tree-flow.h"
 #include "tree-flow-inline.h"
 #include "diagnostic.h"
+#include "coverage.h"
 #include "tree.h"
 #include "gcov-io.h"
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]